commit e56d4f72abfa05e8a8b1cc6031c7b625c2f5085d Author: Suvodip Date: Fri Feb 28 17:08:43 2025 +0530 first commit diff --git a/.hta_config/conf-sample.php b/.hta_config/conf-sample.php new file mode 100644 index 0000000..ea51e7d --- /dev/null +++ b/.hta_config/conf-sample.php @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.hta_slug/_header.php b/.hta_slug/_header.php new file mode 100644 index 0000000..11333bb --- /dev/null +++ b/.hta_slug/_header.php @@ -0,0 +1,31 @@ + + + + + + + + + + '.$web_page_title.''; + if(isset($web_page_meta_description)) echo ''; + if(isset($web_page_meta_keywords)) echo ''; + if(isset($web_page_meta_author)) echo ''; + if(isset($web_page_meta_og_title)) echo ''; + if(isset($web_page_meta_og_description)) echo ''; + if(isset($web_page_meta_og_image)) echo ''; + if(isset($web_page_meta_og_url)) echo ''; + if(isset($web_page_meta_twitter_title)) echo ''; + if(isset($web_page_meta_twitter_description)) echo ''; + if(isset($web_page_meta_twitter_image)) echo ''; + if(isset($web_page_meta_twitter_card)) echo ''; + ?> + + + diff --git a/.hta_slug/_home.php b/.hta_slug/_home.php new file mode 100644 index 0000000..7fa87fb --- /dev/null +++ b/.hta_slug/_home.php @@ -0,0 +1,3 @@ +
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Quibusdam mollitia quidem sint dolores nostrum, similique nulla consequuntur. Animi neque labore praesentium ratione a? Facere, quasi ea reprehenderit eum tempora voluptatum. +
\ No newline at end of file diff --git a/.hta_slug/_nav.php b/.hta_slug/_nav.php new file mode 100644 index 0000000..b002639 --- /dev/null +++ b/.hta_slug/_nav.php @@ -0,0 +1,25 @@ + +
\ No newline at end of file diff --git a/.hta_slug/contact-us.php b/.hta_slug/contact-us.php new file mode 100644 index 0000000..27b18d4 --- /dev/null +++ b/.hta_slug/contact-us.php @@ -0,0 +1,23 @@ +
+
+
+

Contact Us

+

We'd love to hear from you! Fill out the form below.

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
\ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..ffcc268 --- /dev/null +++ b/.htaccess @@ -0,0 +1,8 @@ +RewriteEngine On +#RewriteCond %{HTTPS} !=on +#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] +RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] +RewriteRule ^(.*)$ https://%1/$1 [R=301,L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*) index.php diff --git a/billing2.zip b/billing2.zip new file mode 100644 index 0000000..1b0f4c4 Binary files /dev/null and b/billing2.zip differ diff --git a/customers/.hta_slug/_404.php b/customers/.hta_slug/_404.php new file mode 100644 index 0000000..e69de29 diff --git a/customers/.hta_slug/_home.php b/customers/.hta_slug/_home.php new file mode 100644 index 0000000..c21b770 --- /dev/null +++ b/customers/.hta_slug/_home.php @@ -0,0 +1 @@ +sample route home \ No newline at end of file diff --git a/customers/.hta_slug/billing-details.php b/customers/.hta_slug/billing-details.php new file mode 100644 index 0000000..e9d6e9d --- /dev/null +++ b/customers/.hta_slug/billing-details.php @@ -0,0 +1,106 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + die("Database connection failed: " . $e->getMessage()); +} + +// Handle Payment Status Update +if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["emiId"]) && isset($_POST["status"])) { + $emiId = $_POST["emiId"]; + $status = $_POST["status"]; + + try { + $stmt = $db->prepare("UPDATE billing SET emi".$emiId."Status = :status WHERE customerId = :customerId"); + $stmt->bindParam(':status', $status, PDO::PARAM_INT); + $stmt->bindParam(':customerId', $_POST["customerId"]); + $stmt->execute(); + echo json_encode(["success" => true, "message" => "Payment status updated"]); + } catch (PDOException $e) { + echo json_encode(["success" => false, "message" => "Error updating payment status"]); + } + exit; +} + +// Fetch Customer Billing Data +if (!isset($_GET['customerId'])) { + die("Invalid request: Customer ID is required."); +} + +$customerId = $_GET['customerId']; +$stmt = $db->prepare("SELECT * FROM billing WHERE customerId = :customerId"); +$stmt->bindParam(':customerId', $customerId); +$stmt->execute(); +$billingData = $stmt->fetch(PDO::FETCH_ASSOC); + +if (!$billingData) { + die("No billing data found for this customer."); +} +?> +
+

Customer Billing Details

+ + + + + + + + + + + + + + + + + + "; + } + ?> + +
#EMI DateAmountStatusAction
{$i}{$emiDate}₹{$emiAmount}" . ($emiStatus == 1 ? "Paid" : "Unpaid") . " + +
+
+ + diff --git a/customers/.hta_slug/edit.php b/customers/.hta_slug/edit.php new file mode 100644 index 0000000..e4e93b6 --- /dev/null +++ b/customers/.hta_slug/edit.php @@ -0,0 +1,109 @@ +
+
+
+
+
+

Edit Customer Details

+
+
+ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + // Update customer details + $stmt = $db->prepare("UPDATE customers SET name = :name, mobile = :mobile, email = :email WHERE customerId = :customerId"); + $stmt->bindParam(':name', $_POST['name']); + $stmt->bindParam(':mobile', $_POST['mobile']); + $stmt->bindParam(':email', $_POST['email']); + + $stmt = $db->prepare("SELECT COUNT(*) FROM address WHERE customerId = :customerId"); + $stmt->bindParam(':customerId', $_POST['customerId']); + $stmt->execute(); + $addressExists = $stmt->fetchColumn(); + if ($addressExists) { + $stmt = $db->prepare("UPDATE address SET city = :city, district = :district, state = :state, pinCode = :pin WHERE customerId = :customerId"); + } else { + $stmt = $db->prepare("INSERT INTO address (customerId, city, district, state, pinCode) VALUES (:customerId, :city, :district, :state, :pin)"); + } + $stmt->bindParam(':city', $_POST['city']); + $stmt->bindParam(':district', $_POST['district']); + $stmt->bindParam(':state', $_POST['state']); + $stmt->bindParam(':pin', $_POST['pinCode']); + $stmt->bindParam(':customerId', $_POST['customerId']); + + if ($stmt->execute()) { + echo '
Customer details updated successfully.
'; + } else { + echo '
Error updating customer.
'; + } + } + + // Fetch customer data + $stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId"); + $stmt->bindParam(':customerId', $_GET['customerId']); + $stmt->execute(); + $customer = $stmt->fetch(PDO::FETCH_ASSOC); + + $stmtAddress = $db->prepare("SELECT * FROM address WHERE customerId = :customerId"); + $stmtAddress->bindParam(':customerId', $_GET['customerId']); + $stmtAddress->execute(); + $customerAddress = $stmtAddress->fetch(PDO::FETCH_ASSOC); + + } catch (PDOException $e) { + echo '
Error: ' . $e->getMessage() . '
'; + } + ?> + + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +
Customer not found!
+ +
+
+
+
+
\ No newline at end of file diff --git a/customers/.hta_slug/emi.php b/customers/.hta_slug/emi.php new file mode 100644 index 0000000..6740291 --- /dev/null +++ b/customers/.hta_slug/emi.php @@ -0,0 +1,100 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $customerId = $_POST['customerId']; + $totalAmount = $_POST['totalAmount']; + $tenure = min($_POST['tenure'], 18); // Limit tenure to 18 months + $firstEmiDate = $_POST['firstEmiDate']; + $emiAmount = $totalAmount / $tenure; + + // Prepare the query dynamically + $columns = ['customerId', 'totalAmount', 'tenure', 'emiAmount', 'firstEmiDate']; + $placeholders = [':customerId', ':totalAmount', ':tenure', ':emiAmount', ':firstEmiDate']; + $params = [ + ':customerId' => $customerId, + ':totalAmount' => $totalAmount, + ':tenure' => $tenure, + ':emiAmount' => $emiAmount, + ':firstEmiDate' => $firstEmiDate + ]; + + // Add EMI columns dynamically based on tenure + for ($i = 1; $i <= $tenure; $i++) { + $emiDate = date('Y-m-d', strtotime("+$i months", strtotime($firstEmiDate))); + $columns[] = "emi$i"; + $columns[] = "emi{$i}Date"; + $placeholders[] = ":emi$i"; + $placeholders[] = ":emi{$i}Date"; + $params[":emi$i"] = $emiAmount; + $params[":emi{$i}Date"] = $emiDate; + } + + // Construct SQL statement + $sql = "INSERT INTO billing (" . implode(',', $columns) . ") VALUES (" . implode(',', $placeholders) . ")"; + $stmt = $db->prepare($sql); + + // Execute the query + if ($stmt->execute($params)) { + echo '
New EMI plan for ' . htmlspecialchars($customerId) . ' saved successfully.
'; + } else { + echo '
Error executing statement: ' . $stmt->errorInfo()[2] . '
'; + } + } catch (PDOException $e) { + echo '
Error: ' . $e->getMessage() . '
'; + } +} + +// Fetch customer details +$customer = null; +if (!empty($_GET['customerId'])) { + try { + $db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId"); + $stmt->bindParam(':customerId', $_GET['customerId']); + if ($stmt->execute()) { + $customer = $stmt->fetch(PDO::FETCH_ASSOC); + } + } catch (PDOException $e) { + echo '
Error: ' . $e->getMessage() . '
'; + } +} +?> + +
+

EMI Calculation

+ + +

Name:

+

Mobile:

+ +
Customer not found.
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
diff --git a/customers/.hta_slug/list.php b/customers/.hta_slug/list.php new file mode 100644 index 0000000..602a4f5 --- /dev/null +++ b/customers/.hta_slug/list.php @@ -0,0 +1,49 @@ + +
+

Customer List

+
+ + + + + + + + + + + + setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $stmt = $db->prepare("SELECT * FROM customers ORDER BY regDate DESC"); + $stmt->execute(); + $content = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $customerSerial = 1; // Moved outside loop + foreach ($content as $customer) { + ?> + + + + + + + + '; + } + ?> + +
Sl NoNameMobileEmailAction
+ Edit + Bill + Billing Info +
Error: ' . $e->getMessage() . '
+
+
diff --git a/customers/.hta_slug/new.php b/customers/.hta_slug/new.php new file mode 100644 index 0000000..a0f4609 --- /dev/null +++ b/customers/.hta_slug/new.php @@ -0,0 +1,51 @@ +
+
+
+
+
+

Customer Registration

+
+
+ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $stmt = $db->prepare("INSERT INTO customers (name, mobile, email) VALUES (:name, :mobile, :email)"); + $stmt->bindParam(':name', $_POST['name']); + $stmt->bindParam(':mobile', $_POST['mobile']); + $stmt->bindParam(':email', $_POST['email']); + + if ($stmt->execute()) { + echo '
New Customer ' . htmlspecialchars($_POST['name']) . ' created successfully.
'; + } else { + echo '
Error executing statement: ' . $stmt->errorInfo()[2] . '
'; + } + } catch (PDOException $e) { + echo '
Error: ' . $e->getMessage() . '
'; + } + } + ?> +
+
+ + +
+
+ + +
+ +
+ + +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/customers/.htaccess b/customers/.htaccess new file mode 100644 index 0000000..ffcc268 --- /dev/null +++ b/customers/.htaccess @@ -0,0 +1,8 @@ +RewriteEngine On +#RewriteCond %{HTTPS} !=on +#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] +RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] +RewriteRule ^(.*)$ https://%1/$1 [R=301,L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*) index.php diff --git a/customers/index.php b/customers/index.php new file mode 100644 index 0000000..b39e111 --- /dev/null +++ b/customers/index.php @@ -0,0 +1,18 @@ +