MMCT TEAM
Server IP : 217.21.85.138  /  Your IP : 216.73.216.103
Web Server : LiteSpeed
System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u915722082 ( 915722082)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u915722082/.nvm/../public_html/invoice/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u915722082/.nvm/../public_html/invoice/add-product.php
<?php
	session_start();

	require_once 'db.php';

	if(!isset($_SESSION["logs"])){
		redirect("index.php");
	}

$data["forms_value"]=resultSet($con, "SELECT * FROM forms_value");
$data["bulkpackage"]=resultSet($con, "SELECT * FROM bulkpackage");
$data["package"]=resultSet($con, "SELECT * FROM package");
$data["attributes"]=resultSet($con,'SELECT * FROM attributes');

?>
<!DOCTYPE html>
<html lang="en">
	<head>
<base href="" />
		<title>TDS Admin Hub</title>
		<meta charset="utf-8" />
		<meta name="description" content="The most advanced Bootstrap 5 Admin Theme with 40 unique prebuilt layouts on Themeforest trusted by 100,000 beginners and professionals. Multi-demo, Dark Mode, RTL support and complete React, Angular, Vue, Asp.Net Core, Rails, Spring, Blazor, Django, Express.js, Node.js, Flask, Symfony & Laravel versions. Grab your copy now and get life-time updates for free." />
		<meta name="keywords" content="metronic, bootstrap, bootstrap 5, angular, VueJs, React, Asp.Net Core, Rails, Spring, Blazor, Django, Express.js, Node.js, Flask, Symfony & Laravel starter kits, admin themes, web design, figma, web development, free templates, free admin themes, bootstrap theme, bootstrap template, bootstrap dashboard, bootstrap dak mode, bootstrap button, bootstrap datepicker, bootstrap timepicker, fullcalendar, datatables, flaticon" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<meta property="og:locale" content="en_US" />
		<meta property="og:type" content="article" />
		<meta property="og:title" content="Metronic - The World's #1 Selling Bootstrap Admin Template - Metronic by KeenThemes" />
		<meta property="og:url" content="https://keenthemes.com/metronic" />
		<meta property="og:site_name" content="Metronic by Keenthemes" />
		<link rel="canonical" href="https://preview.keenthemes.com/metronic8" />
		<link rel="shortcut icon" href="assets/media/logos/favicon.ico" />
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700" />
		<link href="assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
		<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
		<script>// Frame-busting to prevent site from being loaded within a frame without permission (click-jacking) if (window.top != window.self) { window.top.location.replace(window.self.location.href); }</script>
		<style>
			 .file-upload-wrapper {
            margin: 20px 0;
        }

        .form-label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
            color: #181C32;
        }

        .file-upload-area {
            border: 1px dashed #E4E6EF;
            border-radius: 0.475rem;
            padding: 20px;
            text-align: center;
            background: #F9F9F9;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            min-height: 150px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .file-upload-area:hover, 
        .file-upload-area.dragover {
            background: #EEF6FF;
            border-color: #009EF7;
        }

        .upload-content {
            width: 100%;
        }

        .upload-icon {
            width: 35px;
            height: 35px;
            margin: 0 auto 10px;
            display: block;
            color: #009EF7;
        }

        .upload-text {
            color: #181C32;
            font-weight: 500;
            margin-bottom: 5px;
            font-size: 1rem;
        }

        .upload-hint {
            color: #B5B5C3;
            font-size: 0.9rem;
        }

        .preview-area {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 10px;
            margin-top: 15px;
        }

        .preview-item {
            position: relative;
            background: #fff;
            border-radius: 0.475rem;
            overflow: hidden;
        }

        .preview-item img {
            width: 100%;
            height: 120px;
            object-fit: cover;
        }

        .preview-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.7);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: white;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .preview-item:hover .preview-overlay {
            opacity: 1;
        }

        .file-size {
            font-size: 0.8rem;
            margin-bottom: 5px;
        }

        .remove-btn {
            background: none;
            border: none;
            color: #F1416C;
            cursor: pointer;
            padding: 5px;
        }

        .remove-btn:hover {
            color: #fff;
        }

        #file-input {
            display: none;
        }
			.specification-item {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.specification-item .specification-key {
  flex: 1;
  margin-right: 1rem;
}

.specification-item .specification-value {
  flex: 1;
  margin-right: 1rem;
}

.specification-item .btn-icon {
  flex-shrink: 0;
}
			.var-image{
				height:20px !important;
				width:20px !important;
			}
			
        .ck-editor__editable[role="textbox"] {
            min-height: 180px;
        }
.variation4 {
    border: 1px solid #ccc;
    padding: 5px;
    width: 200px;
}
.variation4 option {
    padding: 5px;
    background-color: #f2f2f2;
    border-bottom: 1px solid #ddd;
}

.variation4 option:last-child {
    border-bottom: none;
}
#image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.image-preview {
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 100px !important;
    max-height: 100px !important;
    object-fit: cover;
    border-radius: 4px;
	padding-bottom:30px !important;
}

.delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #F8285A;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.flatpickr-day.today {
	background: #c8c8c8 !important;
    color: #020303 !important;
    border-color: transparent;
}
.image-preview {
    position: relative;
    display: inline-block;
    margin-left: 10px;
}

.image-preview img {
    max-width: 50px;
    max-height: 50px;
    display: block;
}

.delete-button-container {
    display: inline-block;
    vertical-align: top;
    margin-left: 10px;
}

.btn-danger {
    position: relative;
    z-index: 1;
}
.image-preview {
    display: inline-block;
    position: relative;
    margin-left: 10px;
}

.image-preview img {
    max-width: 50px;
    max-height: 50px;
    display: block;
}

.delete-button-container {
    display: inline-block;
    vertical-align: top;
    margin-left: 10px;
}

.btn-danger {
    z-index: 1;
}
    </style>
	</head>
	<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true" data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true" class="app-default">
		<script>var defaultThemeMode = "light"; var themeMode; if ( document.documentElement ) { if ( document.documentElement.hasAttribute("data-bs-theme-mode")) { themeMode = document.documentElement.getAttribute("data-bs-theme-mode"); } else { if ( localStorage.getItem("data-bs-theme") !== null ) { themeMode = localStorage.getItem("data-bs-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-bs-theme", themeMode); }
		</script>
		<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
			<div class="app-page flex-column flex-column-fluid" id="kt_app_page">
				<div id="kt_app_header" class="app-header" data-kt-sticky="true" data-kt-sticky-activate="{default: true, lg: true}" data-kt-sticky-name="app-header-minimize" data-kt-sticky-offset="{default: '200px', lg: '0'}" data-kt-sticky-animation="false">
					<div class="app-container container-fluid d-flex align-items-stretch justify-content-between" id="kt_app_header_container">
						<div class="d-flex align-items-center d-lg-none ms-n3 me-1 me-md-2" title="Show sidebar menu">
							<div class="btn btn-icon btn-active-color-primary w-35px h-35px" id="kt_app_sidebar_mobile_toggle">
								<i class="ki-duotone ki-abstract-14 fs-2 fs-md-1">
									<span class="path1"></span>
									<span class="path2"></span>
								</i>
							</div>
						</div>
						<div class="d-flex align-items-center flex-grow-1 flex-lg-grow-0">
							<a href="index.php" class="d-lg-none">
								<img alt="Logo" src="assets/media/logos/default-small.svg" class="h-30px" />
							</a>
						</div>
						<div class="d-flex align-items-stretch justify-content-between flex-lg-grow-1" id="kt_app_header_wrapper">
							<div class="app-header-menu app-header-mobile-drawer align-items-stretch" data-kt-drawer="true" data-kt-drawer-name="app-header-menu" data-kt-drawer-activate="{default: true, lg: false}" data-kt-drawer-overlay="true" data-kt-drawer-width="250px" data-kt-drawer-direction="end" data-kt-drawer-toggle="#kt_app_header_menu_toggle" data-kt-swapper="true" data-kt-swapper-mode="{default: 'append', lg: 'prepend'}" data-kt-swapper-parent="{default: '#kt_app_body', lg: '#kt_app_header_wrapper'}">
								<div class="menu menu-rounded menu-column menu-lg-row my-5 my-lg-0 align-items-stretch fw-semibold px-2 px-lg-0" id="kt_app_header_menu" data-kt-menu="true">
								</div>
							</div>
							<div class="app-navbar flex-shrink-0">
								
								<div class="app-navbar-item ms-1 ms-md-4">
									<a href="#" class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-35px h-35px" data-kt-menu-trigger="{default:'click', lg: 'hover'}" data-kt-menu-attach="parent" data-kt-menu-placement="bottom-end">
										<i class="ki-duotone ki-night-day theme-light-show fs-1">
											<span class="path1"></span>
											<span class="path2"></span>
											<span class="path3"></span>
											<span class="path4"></span>
											<span class="path5"></span>
											<span class="path6"></span>
											<span class="path7"></span>
											<span class="path8"></span>
											<span class="path9"></span>
											<span class="path10"></span>
										</i>
										<i class="ki-duotone ki-moon theme-dark-show fs-1">
											<span class="path1"></span>
											<span class="path2"></span>
										</i>
									</a>
									<div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-title-gray-700 menu-icon-gray-500 menu-active-bg menu-state-color fw-semibold py-4 fs-base w-150px" data-kt-menu="true" data-kt-element="theme-mode-menu">
										<div class="menu-item px-3 my-0">
											<a href="#" class="menu-link px-3 py-2" data-kt-element="mode" data-kt-value="light">
												<span class="menu-icon" data-kt-element="icon">
													<i class="ki-duotone ki-night-day fs-2">
														<span class="path1"></span>
														<span class="path2"></span>
														<span class="path3"></span>
														<span class="path4"></span>
														<span class="path5"></span>
														<span class="path6"></span>
														<span class="path7"></span>
														<span class="path8"></span>
														<span class="path9"></span>
														<span class="path10"></span>
													</i>
												</span>
												<span class="menu-title">Light</span>
											</a>
										</div>
										<div class="menu-item px-3 my-0">
											<a href="#" class="menu-link px-3 py-2" data-kt-element="mode" data-kt-value="dark">
												<span class="menu-icon" data-kt-element="icon">
													<i class="ki-duotone ki-moon fs-2">
														<span class="path1"></span>
														<span class="path2"></span>
													</i>
												</span>
												<span class="menu-title">Dark</span>
											</a>
										</div>
										<div class="menu-item px-3 my-0">
											<a href="#" class="menu-link px-3 py-2" data-kt-element="mode" data-kt-value="system">
												<span class="menu-icon" data-kt-element="icon">
													<i class="ki-duotone ki-screen fs-2">
														<span class="path1"></span>
														<span class="path2"></span>
														<span class="path3"></span>
														<span class="path4"></span>
													</i>
												</span>
												<span class="menu-title">System</span>
											</a>
										</div>
									</div>
								</div>
								<div class="app-navbar-item ms-1 ms-md-4" id="kt_header_user_menu_toggle">
									<div class="cursor-pointer" data-kt-menu-trigger="{default: 'click', lg: 'hover'}" data-kt-menu-attach="parent" data-kt-menu-placement="bottom-end">
										<img src="assets/logo/LOGO-BLACK.png" class="rounde" alt="user" />
									</div>
									<div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-800 menu-state-bg menu-state-color fw-semibold py-4 fs-6 w-275px" data-kt-menu="true">
										<div class="menu-item px-3">
											<div class="menu-content d-flex align-items-center px-3">
												<div class=" me-5">
													<img alt="Logo" src="assets/logo/LOGO-BLACK.png" />
												</div>

											</div>
										</div>
										<div class="separator my-2"></div>
										<div class="menu-item px-5">
											<a href="_logout.php" class="menu-link px-5">Sign Out</a>
										</div>
									</div>
								</div>
								<div class="app-navbar-item d-lg-none ms-2 me-n2" title="Show header menu">
									<div class="btn btn-flex btn-icon btn-active-color-primary w-30px h-30px" id="kt_app_header_menu_toggle">
										<i class="ki-duotone ki-element-4 fs-1">
											<span class="path1"></span>
											<span class="path2"></span>
										</i>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
					<div id="kt_app_sidebar" class="app-sidebar flex-column" data-kt-drawer="true" data-kt-drawer-name="app-sidebar" data-kt-drawer-activate="{default: true, lg: false}" data-kt-drawer-overlay="true" data-kt-drawer-width="225px" data-kt-drawer-direction="start" data-kt-drawer-toggle="#kt_app_sidebar_mobile_toggle">
							<div class="app-sidebar-logo px-6" id="kt_app_sidebar_logo">
							<a href="products.php">
								<img alt="Logo" src="assets/media/logos/LOGO.png" class="h-25px app-sidebar-logo-default" />
								<img alt="Logo" src="assets/media/logos/default-small.svg" class="h-20px app-sidebar-logo-minimize" />
							</a>
						
							<div id="kt_app_sidebar_toggle" class="app-sidebar-toggle btn btn-icon btn-shadow btn-sm btn-color-muted btn-active-color-primary h-30px w-30px position-absolute top-50 start-100 translate-middle rotate" data-kt-toggle="true" data-kt-toggle-state="active" data-kt-toggle-target="body" data-kt-toggle-name="app-sidebar-minimize">
								<i class="ki-duotone ki-black-left-line fs-3 rotate-180">
									<span class="path1"></span>
									<span class="path2"></span>
								</i>
							</div>
						</div>
						<?php  require "sidebar.php"  ?>
					</div>
					<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
						<div class="d-flex flex-column flex-column-fluid">
							<div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
								<div id="kt_app_toolbar_container" class="app-container container-xxl d-flex flex-stack">
									<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
										<h1 class="page-heading d-flex text-gray-900 fw-bold fs-3 flex-column justify-content-center my-0">Add new product
										</h1>
										<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
											<li class="breadcrumb-item text-muted">
												<a class="text-muted text-hover-primary">Product</a>
											</li>
											<li class="breadcrumb-item">
												<span class="bullet bg-gray-500 w-5px h-2px"></span>
											</li>
											<li class="breadcrumb-item text-muted">Add new product
											</li>
										</ul>
									</div>
								</div>
							</div>
							<div id="kt_app_content" class="app-content flex-column-fluid">
								<div id="kt_app_content_container" class="app-container container-xxl">
									<form id="kt_ecommerce_add_category_form" class="form d-flex flex-column flex-lg-row" enctype="multipart/form-data" action="">
										
										<input type='hidden' name='action' id='action' value='Insert'>
										<div class="d-flex flex-column gap-7 gap-lg-10 w-100 w-lg-300px mb-7 me-lg-10">

										<div class="card card-flush py-4">
											<div class="card-header">
												<div class="card-title">
													<h2>Thumbnail</h2>
												</div>
											</div>
											<div class="card-body text-center pt-0">
													<style>
														.image-input-placeholder {
															background-image: url('assets/media/svg/files/blank-image.svg');
														}

														[data-bs-theme="dark"] .image-input-placeholder {
															background-image: url('assets/media/svg/files/blank-image-dark.svg');
														}                
													</style>
														
												<div class="image-input image-input-outline image-input-placeholder mb-3 image-input-empty" data-kt-image-input="true">
													<div class="image-input-wrapper w-150px h-150px"></div>
													<label class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="change" data-bs-toggle="tooltip" aria-label="Change avatar" data-bs-original-title="Change avatar" data-kt-initialized="1">
														<i class="ki-duotone ki-pencil fs-7"><span class="path1"></span><span class="path2"></span></i>
														<input type="file" name="img" id="img" accept=".png, .jpg, .jpeg">
														<input type="hidden" name="avatar_remove" value="0">
													</label>
													<span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="cancel" data-bs-toggle="tooltip" aria-label="Cancel avatar" data-bs-original-title="Cancel avatar" data-kt-initialized="1">
														<i class="ki-duotone ki-cross fs-2"><span class="path1"></span><span class="path2"></span></i>            </span>
													<span class="btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow" data-kt-image-input-action="remove" data-bs-toggle="tooltip" aria-label="Remove avatar" data-bs-original-title="Remove avatar" data-kt-initialized="1">
														<i class="ki-duotone ki-cross fs-2"><span class="path1"></span><span class="path2"></span></i>            </span>
												</div>
												<div class="text-muted fs-7">Set the product thumbnail image. Only *.png, *.jpg and *.jpeg image files are accepted</div>
											</div>
										</div>
											<div class="card card-flush py-4">
											<div class="card-header">
												<div class="card-title">
													<h2>Product Details</h2>
												</div>
											</div>
											<div class="card-body pt-0">
												<label class="form-label mt-xl-6">Type</label>
												<select id="category-select-2" name="ptype" class="form-select mb-2" data-control="select2" data-placeholder="Select Anyone">
												<option value="">Select Anyone</option>
												<option value="Raw Material">Raw Material</option>
												<option value="Finished Goods">Finished Goods</option>
												<option value="Packaging">Packaging </option>
											</select>
											<div id="packaging">
												<div class="separator separator-dashed my-10"></div>
												<label class="form-label mt-xl-5">Packaging Category</label>
												<select id="packagingCategory" name="productpackage" class="form-select mb-2" 
													data-control="select2" data-placeholder="Select Packaging Category">
													<option value="">Select Packaging Category</option>
													<optgroup label="Covers">
														<option value="INNER_PLAIN_COVER">Inner Plain Cover</option>
														<option value="OUTER_BRANDED_COVER">Outer Branded Cover</option>
													</optgroup>
													<optgroup label="Containers">
														<option value="BOTTLE_PLAIN">Bottle (Plain)</option>
														<option value="LABEL_BRANDED">Label (Branded)</option>
													</optgroup>
													<optgroup label="Bulk Packaging">
														<option value="Box">Box</option>
														<option value="Sack">Sack</option>
													</optgroup>
												</select>

												</select>
												<label class="form-label mt-xl-4">Form</label>
												<select  name="ftype" class="form-select mb-2" data-control="select2" data-placeholder="Select an option" multiple>
													<option value="">Select Anyone</option>
													<?php foreach ($data["forms_value"] as $row): ?>
														<option value="<?php echo $row['fid']; ?>"><?php echo $row['name']; ?></option>
													<?php endforeach; ?>
												</select>
												<div class="text-muted fs-7 mb-7">Choose form type</div>
											</div>
											
											<div id="dependent-fields">

												<label class="form-label mt-xl-4">Form</label>
												<select id='formtype' name="ftype" class="form-select mb-2" data-control="select2" data-placeholder="Select an option">
													<option value="">Select Anyone</option>
													<?php foreach ($data["forms_value"] as $row): ?>
														<option value="<?php echo $row['fid']; ?>" data-measurement='<?php echo $row['measurement'] ?>'><?php echo $row['name']; ?> </option>
													<?php endforeach; ?>
												</select>

												<div class="text-muted fs-7 mb-7">Choose form type</div>
												<div class="separator separator-dashed my-10"></div>


												<!-- <label class="form-label mt-xl-5"> Bulk Package Configuration</label>
												<select id='bulkpackaging'  name="bpid" class="form-select mb-2" data-control="select2" data-placeholder="Select Bulk Package" >
													
												</select>
												<div class="text-muted fs-7 mb-7">Choose  Bulk Package Configuration</div>

												<label class="form-label mt-xl-5">Package Configuration</label>
												<select id="subcategory-select" name="paid" class="form-select mb-2" data-control="select2" data-placeholder="Select an option" multiple >
													
												</select>

												<div class="text-muted fs-7 mb-7">Choose Package Configuration</div>

												<div class="separator separator-dashed my-10"></div> -->
												

												<label class="required form-label">HSN CODE</label>
												<input type="text" name="hsncode" class="form-control mb-2" placeholder="Enter HSN CODE" value="" />
												<div class="text-muted fs-7">Enter the HSN CODE Exactly</div>
											</div>
											
											</div>
											
										</div>
														
										</div>
										<div class="d-flex flex-column flex-row-fluid gap-7 gap-lg-10">
											<ul class="nav nav-custom nav-tabs nav-line-tabs nav-line-tabs-2x border-0 fs-4 fw-semibold mb-n2">
												<li class="nav-item">
													<a class="nav-link text-active-primary pb-4 active" data-bs-toggle="tab" href="#kt_ecommerce_add_product_general">General</a>
												</li>
												
											</ul>
											<div class="tab-content">
												<div class="tab-pane fade show active" id="kt_ecommerce_add_product_general" role="tab-panel">
													<div class="d-flex flex-column gap-7 gap-lg-10">
														<div class="card card-flush py-4">
															<div class="card-header">
																<div class="card-title">
																	<h2>General</h2>
																</div>
															</div>
															<div class="card-body pt-0">
																<div class="mb-10 fv-row">
																	<label class="required form-label">Product Name</label>
																	<input type="text" name="pname" class="form-control mb-2" placeholder="Enter Product Name" value="" />
																	<div class="text-muted fs-7">Enter the product name exactly as it should appear on your website
																	</div>
																</div>
																
															
															
																<div>
																	<label class="form-label">Description</label>
																	<textarea id="pdes" class="form-control"  name="pdes"></textarea>
																	<div class="text-muted fs-7">Enter a detailed product description that highlights the product's unique features</div>
																</div>
															</div>
														</div>
														<div class="card card-flush py-4">
															<div class="card-header">
																<div class="card-title">
																	<h2>Variations</h2>
																</div>
															</div>
															<div class="card-body pt-0">

                                                                    <div id="packaging-01">
                                                                        <div class="" data-kt-ecommerce-catalog-add-product="auto-options">
                                                                            <label class="form-label">Add Product Variations</label>
                                                                            <div id="kt_ecommerce_add_product_options">
                                                                                <div class="form-group">
                                                                                    <div data-repeater-list="kt_ecommerce_add_product_options" class="d-flex flex-column gap-3">
                                                                                    <div data-repeater-item="" class="form-group d-flex flex-wrap align-items-center gap-5 variation-item">
                                                                                            <div class="select-container w-100 w-md-200px">
                                                                                                <select class="variation3 form-select mb-2"  name="kt_ecommerce_add_product_options[0][variation3]" 
                                                                                                data-placeholder="Select Anyone">
                                                                                                <option value="">Select Anyone</option>
                                                                                            
                                                                                                    <?php foreach($data["attributes"] as $variation): ?>
                                                                                                        <option value="<?php echo $variation['VARIATION']; ?>"><?php echo $variation['VARIATION']; ?></option>
                                                                                                    <?php endforeach; ?>
                                                                                                
                                                                                                </select>
                                                                                            </div>
                                                                                            <div id="inputContainer" class="w-100 w-md-200px">
                                                                                                <select class="variation4 form-control" name="kt_ecommerce_add_product_options[0][variation4]" data-placeholder="Select variation values" data-kt-ecommerce-catalog-add-product="product_option" multiple>
                                                                                                </select>
                                                                                            </div>
                                                                                            <button type="button" data-repeater-delete="" class="btn btn-sm btn-icon btn-light-danger">
                                                                                                <i class="ki-duotone ki-cross fs-1">
                                                                                                    <span class="path1"></span>
                                                                                                    <span class="path2"></span>
                                                                                                </i>
                                                                                            </button>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                                <div class="form-group mt-5">
                                                                                    <button type="button" data-repeater-create="" class="btn btn-sm btn-light-primary" id="addVariationButton">
                                                                                        <i class="ki-duotone ki-plus fs-2"></i>Add another variation
                                                                                    </button>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <div id="dependent-fields-01">
                                                                        <div class="row">
                                                                            <div class="col-md-3">
                                                                                <label class="form-label mt-xl-5"> Bulk Package Configuration</label>
                                                                                <select id='bulkpackaging'  name="bpid" class="form-select mb-2" data-control="select2" data-placeholder="Select Bulk Package" >
                                                                                    
                                                                                </select>
                                                                                <!-- <div class="text-muted fs-7 mb-7">Choose  Bulk Package Configuration</div> -->

                                                                              
                                                                            </div>
                                                                            <div class="col-md-3">
                                                                            <label class="form-label mt-xl-5">Package Configuration</label>
                                                                                <select id="subcategory-select" name="paid" class="form-select mb-2" data-control="select2" data-placeholder="Select an option" multiple >
                                                                                    
                                                                                </select>

                                                                                <!-- <div class="text-muted fs-7 mb-7">Choose Package Configuration</div> -->
                                                                                 
                                                                            </div>
                                                                        </div>
                                                                    </div>
															</div>
														</div>
													</div>
													
												</div>
												
											
											<div class="d-flex justify-content-end mt-xl-5">
												<a href="products.php" id="kt_ecommerce_add_product_cancel" class="btn btn-light me-5">Cancel</a>
												<button name="btn-submit" type="submit" id="btn-submit" class="btn btn-primary">
													<span class="indicator-label">Submit</span>
													<span class="indicator-progress">Please wait... 
													<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
												</button>
											</div>
										</div>
									</form>
									<div id="combinationTable"></div>
								</div>
							</div>
						</div>
						<div id="kt_app_footer" class="app-footer">
							<div class="app-container container-fluid d-flex flex-column flex-md-row flex-center flex-md-stack py-3">
								<div class="text-gray-900 order-2 order-md-1">
									<span class="text-muted fw-semibold me-1">2025 &copy;</span>
									<a href="https://thedotstudios.com/" target="_blank" class="text-gray-800 text-hover-primary">Copyright  All rights reserved | Made with <span class="fa fa-heart text-danger"></span> <b> by TheDotStudios.</b></a>
								</div>
								<ul class="menu menu-gray-600 menu-hover-primary fw-semibold order-1">
									<li class="menu-item">
										<a href="https://thedotstudios.com/" target="_blank" class="menu-link px-2">About</a>
									</li>
									<li class="menu-item">
										<a href="https://thedotstudios.com/" target="_blank" class="menu-link px-2">Support</a>
									</li>
									<li class="menu-item">
										<!-- <a href="https://1.envato.market/EA4JP" target="_blank" class="menu-link px-2">Purchase</a> -->
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div id="kt_scrolltop" class="scrolltop" data-kt-scrolltop="true">
			<i class="ki-duotone ki-arrow-up">
				<span class="path1"></span>
				<span class="path2"></span>
			</i>
		</div>
		<script>var hostUrl = "assets/";</script>
		<script src="assets/plugins/global/plugins.bundle.js"></script>
		<script src="assets/js/scripts.bundle.js"></script>
		<script src="assets/plugins/custom/datatables/datatables.bundle.js"></script>
		<script src="assets/plugins/custom/formrepeater/formrepeater.bundle.js"></script>
		<script src="assets/js/widgets.bundle.js"></script>
		<script src="assets/js/custom/widgets.js"></script>
		<script src="assets/js/custom/apps/chat/chat.js"></script>
		<script src="assets/js/custom/utilities/modals/upgrade-plan.js"></script>
		<script src="assets/js/custom/utilities/modals/create-app.js"></script>
		<script src="assets/js/custom/utilities/modals/users-search.js"></script>
		<script src="https://cdn.ckeditor.com/ckeditor5/41.2.1/classic/ckeditor.js"></script>

<script>
    ClassicEditor
        .create(document.querySelector('#pdes'))
        .catch(error => {
            console.error(error);
        });
</script>
<script>
document.getElementById('img').addEventListener('change', function () {
    validateSingleFile(this);
});

document.getElementById('file-input').addEventListener('change', function () {
    validateMultipleFiles(this, 5);
});
function validateSingleFile(inputElement) {
    const allowedFormats = ['image/jpeg', 'image/png', 'image/jpg'];
    const file = inputElement.files[0];

    if (file) {
        if (!allowedFormats.includes(file.type)) {
            Swal.fire({
                icon: 'error',
                title: 'Invalid File Format',
                text: 'Please select a valid image file (PNG, JPG, JPEG).',
            });
            inputElement.value = '';
        }
    }
}

function validateMultipleFiles(inputElement, maxFiles) {
    const allowedFormats = ['image/jpeg', 'image/png', 'image/jpg'];
    const files = inputElement.files;
    if (files.length > maxFiles) {
        Swal.fire({
            icon: 'error',
            title: 'Too Many Files',
            text: `You can only select up to ${maxFiles} images.`,
        });
        inputElement.value = '';
        return;
    }

    // Validate each file format
    for (let i = 0; i < files.length; i++) {
        if (!allowedFormats.includes(files[i].type)) {
            Swal.fire({
                icon: 'error',
                title: 'Invalid File Format',
                text: 'Please select valid image files (PNG, JPG, JPEG).',
            });
            inputElement.value = '';
            return;
        }
    }
}

</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    const dropArea = document.getElementById('drop-area');
    const fileInput = document.getElementById('file-input');
    const previewArea = document.getElementById('preview-area');

    ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
        dropArea.addEventListener(eventName, preventDefaults, false);
        document.body.addEventListener(eventName, preventDefaults, false);
    });

    ['dragenter', 'dragover'].forEach(eventName => {
        dropArea.addEventListener(eventName, highlight, false);
    });

    ['dragleave', 'drop'].forEach(eventName => {
        dropArea.addEventListener(eventName, unhighlight, false);
    });

    dropArea.addEventListener('drop', handleDrop, false);
    dropArea.addEventListener('click', () => fileInput.click());
    fileInput.addEventListener('change', handleFiles);

    function preventDefaults(e) {
        e.preventDefault();
        e.stopPropagation();
    }

    function highlight(e) {
        dropArea.classList.add('dragover');
    }

    function unhighlight(e) {
        dropArea.classList.remove('dragover');
    }

    function handleDrop(e) {
        const dt = e.dataTransfer;
        const files = dt.files;
        handleFiles({ target: { files: files } });
    }

    function handleFiles(e) {
        const files = [...e.target.files];

        files.forEach(file => {
            if (file.size > 1048576) {
                Swal.fire({
                    title: "Error!",
                    text: "File size must be less than 1 MB",
                    icon: "error",
                    confirmButtonText: "OK"
                });
            } else {
                previewFile(file);
            }
        });
    }

    function formatFileSize(bytes) {
        if (bytes === 0) return '0 Bytes';
        const k = 1024;
        const sizes = ['Bytes', 'KB', 'MB', 'GB'];
        const i = Math.floor(Math.log(bytes) / Math.log(k));
        return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
    }

    function previewFile(file) {
        if (!file.type.startsWith('image/')) return;

        const reader = new FileReader();
        reader.readAsDataURL(file);

        reader.onloadend = function () {
            const div = document.createElement('div');
            div.className = 'preview-item';

            div.innerHTML = `
                <img src="${reader.result}" alt="${file.name}">
                <div class="preview-overlay">
                    <div class="file-size">${formatFileSize(file.size)}</div>
                    <button class="remove-btn" onclick="this.closest('.preview-item').remove()">Remove</button>
                </div>
            `;

            previewArea.appendChild(div);
        };
    }
});

</script>

<script>
    $(document).ready(function() {
        $('select[data-control="select2"]').select2({
            width: '100%',
            placeholder: function() {
                return $(this).data('placeholder');
            }
        });
        function toggleFields() {
            let selectedValue = $('#category-select-2').val();
            
            if (selectedValue === "Raw Material") {
                $('#dependent-fields').hide();
                $('#dependent-fields-01').hide();
                $('#packaging').hide();
                $('#packaging-01').show();
            } else if (selectedValue === "Finished Goods") {
                $('#dependent-fields').show();
                $('#dependent-fields-01').show();
                $('#packaging').hide();
                $('#packaging-01').hide();
            } else if (selectedValue === "Packaging") {
                $('#dependent-fields').hide();
                $('#dependent-fields-01').hide();
                $('#packaging').show();
                $('#packaging-01').show();
            } else {
                $('#dependent-fields').hide();
                $('#dependent-fields-01').hide();
                $('#packaging').hide();
            }
        }
        $('#category-select-2').on('change', toggleFields);
        toggleFields();
    });
</script>
	<script>
"use strict";

var KTAppEcommerceSaveProduct = function () {
    const variationCache = new Map();
    const selectedVariations = new Set();
    let isAddingNewRow = false;
    var initVariations = function() {
        const parseVariationValues = str => str ? str.split(',').map(v => v.trim()).filter(v => v) : [];
        const select2Helpers = {
            destroy: select => {
                try {
                    const $select = $(select);
                    if ($select.data('select2')) $select.select2('destroy');
                } catch (e) {
                    console.warn('Select2 destroy error:', e);
                }
            },
            
            init: select => {
                try {
                    const $select = $(select);
                    const $container = $select.closest('[data-repeater-item]');
                    
                    if ($container.length) {
                        select2Helpers.destroy($select);
                        $select.select2({
                            minimumResultsForSearch: 20,
                            dropdownParent: $container,
                            multiple: $select.hasClass('variation4'),
                            width: '100%'
                        });
                    }
                } catch (e) {
                    console.warn('Select2 init error:', e);
                }
            }
        };
        const updateVariation3Dropdowns = () => {
            $('.variation3').each(function() {
                const currentValue = $(this).val();
                $(this).find('option').each(function() {
                    const optionValue = $(this).val();
                    if (optionValue && optionValue !== currentValue) {
                        $(this).prop('disabled', selectedVariations.has(optionValue));
                    }
                });
                select2Helpers.init(this);
            });
        };
        const resetVariation4Select = select => {
            const $select = $(select);
            select2Helpers.destroy($select);
            $select.empty();
            select2Helpers.init($select);
        };
        const updateVariation4Select = (select, values) => {
            const $select = $(select);
            select2Helpers.destroy($select);
            $select.empty();
            
            values.forEach(value => {
                if (value.trim()) {
                    $select.append(new Option(value.trim(), value.trim(), false, false));
                }
            });
            
            select2Helpers.init($select);
        };
        const fetchVariationValues = async (variation, variation4Select, blockUI) => {
            try {
                if (variationCache.has(variation)) {
                    updateVariation4Select(variation4Select, variationCache.get(variation));
                    blockUI.release();
                    return;
                }
                const response = await $.ajax({
                    url: 'fetch_attributes.php',
                    method: 'POST',
                    data: { variation },
                    dataType: 'json'
                });

                if (response?.success && response.variation_values) {
                    const values = typeof response.variation_values === 'string' 
                        ? parseVariationValues(response.variation_values)
                        : Array.isArray(response.variation_values) 
                            ? response.variation_values 
                            : [];
                    
                    if (values.length > 0) {
                        variationCache.set(variation, values);
                        updateVariation4Select(variation4Select, values);
                    } else {
                        toastr.warning("No variation values found for " + variation);
                        resetVariation4Select(variation4Select);
                    }
                } else {
                    toastr.warning(response?.message || "No variation values found");
                    resetVariation4Select(variation4Select);
                }
            } catch (error) {
                console.error('Error fetching variations:', error);
                toastr.error("Failed to fetch variation values");
                resetVariation4Select(variation4Select);
            } finally {
                blockUI.release();
            }
        };

        const isRowEmpty = $row => {
            const variation3Value = $row.find('.variation3').val();
            const variation4Values = $row.find('.variation4').val();
            if (!variation3Value || variation3Value === '') {
                return true;
            }
            if (!variation4Values || (Array.isArray(variation4Values) && variation4Values.length === 0)) {
                return true;
            }
            return false;
        };

        $('#kt_ecommerce_add_product_options').repeater({
            initEmpty: false,
            defaultValues: {
                'variation3': '',
                'variation4': ''
            },
            show: function() {
                if (isAddingNewRow) return;
                isAddingNewRow = true;
                const $item = $(this);
                const $allItems = $('[data-repeater-item]');
                if ($allItems.length > 1) {
                    const $prevItem = $allItems.eq($allItems.length - 2);
                    
                    if (isRowEmpty($prevItem)) {
                        toastr.warning("Please complete the current variation before adding a new one.");
                        $item.remove();
                        isAddingNewRow = false;
                        return;
                    }
                }
                $item.slideDown();
                $item.find('select').each(function() {
                    const $select = $(this);
                    select2Helpers.destroy($select);
                    if ($select.hasClass('variation3')) {
                        $select.val('');
                    } else if ($select.hasClass('variation4')) {
                        $select.empty();
                    }
                    select2Helpers.init($select);
                });
                
                updateVariation3Dropdowns();
                isAddingNewRow = false;
            },
            hide: function(deleteElement) {
				const allItems = $(this).closest('[data-repeater-list]').find('[data-repeater-item]');
			if (allItems.length > 1) {
				$(this).slideUp(deleteElement);
			} else {
				const errorMsg = $('<div class="alert alert-danger mt-2 mb-2">Cannot delete the last row. At least one row is required.</div>');
				$(this).closest('[data-repeater-list]').append(errorMsg);
				setTimeout(() => {
					errorMsg.fadeOut(function() {
						$(this).remove();
					});
				}, 300);
				return false;
			}
                const $item = $(this);
                const variation = $item.find('.variation3').val();
                
                if (variation) {
                    selectedVariations.delete(variation);
                    updateVariation3Dropdowns();
                }
                
                $item.find('select').each(function() {
                    select2Helpers.destroy(this);
                });
                
                $item.slideUp(deleteElement);
            }
        });

        $(document).on('change', '.variation3', function() {
            const $select = $(this);
            const selectedVariation = $select.val();
            const previousValue = $select.data('previous-value');
            const $variationItem = $select.closest('[data-repeater-item]');
            const $variation4Select = $variationItem.find('.variation4');
            if (previousValue) {
                selectedVariations.delete(previousValue);
            }
            resetVariation4Select($variation4Select);
            if (selectedVariation && selectedVariation !== '') {
                selectedVariations.add(selectedVariation);
                $select.data('previous-value', selectedVariation);
                updateVariation3Dropdowns();
                const blockUI = new KTBlockUI($variationItem[0], {
                    message: '<div class="blockui-message"><span class="spinner-border text-primary"></span> Loading...</div>'
                });
                blockUI.block();
                fetchVariationValues(selectedVariation, $variation4Select, blockUI);
            }
        });
        let addButtonClickTimeout = null;
        $('[data-repeater-item] select').each(function() {
            const $select = $(this);
            if ($select.hasClass('variation3') && $select.val() && $select.val() !== '') {
                selectedVariations.add($select.val());
                $select.data('previous-value', $select.val());
                const $variationItem = $select.closest('[data-repeater-item]');
                const $variation4Select = $variationItem.find('.variation4');
                const blockUI = new KTBlockUI($variationItem[0], {
                    message: '<div class="blockui-message"><span class="spinner-border text-primary"></span> Loading...</div>'
                });
                blockUI.block();
                fetchVariationValues($select.val(), $variation4Select, blockUI);
            }
            
            select2Helpers.init($select);
        });
    };

    return {
        init: function () {
            initVariations();
        }
    };
}();
KTUtil.onDOMContentLoaded(function () {
    KTAppEcommerceSaveProduct.init();
});
	</script>

	<script>
		$(document).ready(function() {
			$('#kt_ecommerce_add_category_form').submit(function(e) {
				e.preventDefault(); 
				var formData = new FormData(this);
				var selectedPackages = $('#subcategory-select').val(); 
				var bulkPackages = $('#bulkpackaging').val(); 
				var categoryPackages = $('#category-select').val(); 
				if (selectedPackages) {
					console.log("Selected Packages:", selectedPackages);
					console.log("Comma-Separated Value:", selectedPackages.join(','));
					formData.append('paid', selectedPackages.join(','));
				}
				if (bulkPackages && bulkPackages.length > 0) {
	console.log("Selected Bulk Package:", bulkPackages[0]);
	formData.append('bpid', bulkPackages[0]);
}

if (categoryPackages && categoryPackages.length > 0) {
	console.log("Selected Package:", categoryPackages[0]);
	formData.append('ftype', categoryPackages[0]);
}

				$('#btn-submit').attr('disabled', true);
				$('#btn-submit .indicator-label').hide();
				$('#btn-submit .indicator-progress').show();
				$.ajax({
					url: 'ajax_product.php',
					type: 'POST',
					data: formData,
					contentType: false,
					processData: false,
					success: function(response) {
						try {
							var result = JSON.parse(response);
							if (result.status === 'success') {
								Swal.fire({
									text: "Product was added successfully!",
									icon: "success",
									buttonsStyling: false,
									confirmButtonText: "Ok, got it!",
									customClass: {
										confirmButton: "btn btn-primary"
									}
								}).then(function() {
									window.location = 'products.php';
								});
							} else {
								Swal.fire({
									text: result.message || "Sorry, an error occurred while adding the product.",
									icon: "error",
									buttonsStyling: false,
									confirmButtonText: "Ok, got it!",
									customClass: {
										confirmButton: "btn btn-primary"
									}
								});
							}
						} catch (e) {
							console.error("Error parsing JSON response:", e);
							Swal.fire({
								text: "Sorry, an error occurred while processing your request.",
								icon: "error",
								buttonsStyling: false,
								confirmButtonText: "Ok, got it!",
								customClass: {
									confirmButton: "btn btn-primary"
								}
							});
						}
					},
					error: function(xhr, status, error) {
						console.error("AJAX Error:", error);
						Swal.fire({
							text: "Sorry, an error occurred while processing your request.",
							icon: "error",
							buttonsStyling: false,
							confirmButtonText: "Ok, got it!",
							customClass: {
								confirmButton: "btn btn-primary"
							}
						});
					},
					complete: function() {
						$('#btn-submit').attr('disabled', false);
						$('#btn-submit .indicator-label').show();
						$('#btn-submit .indicator-progress').hide();
					}
				});
			});
		});




		$('#bulkpackaging').on('change', function () {
			var selectedBpid = $(this).val();
			// Ensure selectedBpid is always an array
			if (!Array.isArray(selectedBpid)) {
				selectedBpid = [selectedBpid];
			}
			
			$('#subcategory-select').empty();
			$.ajax({
				url: 'get_package_configurations.php',
				type: 'POST',
				data: { bpid: JSON.stringify(selectedBpid) },
				success: function (response) {
					console.log(response);
					$('#subcategory-select').html(response);
				},
				error: function (xhr, status, error) {
					console.error("Error:", error);
				}
			});
		});



	</script>
<script>
    $('#formtype').on('change', function () {
        // Clear the bulk packaging dropdown first when selection changes
        $('#bulkpackaging').empty();
        
        // Get selected options
        const selectedOptions = $(this).find('option:selected');
        
        // If no options selected, just return
        if (selectedOptions.length === 0) {
            return;
        }
        
        // Extract measurement data attributes
        const selectedMeasurements = selectedOptions
            .map(function () {
                return $(this).data('measurement');
            })
            .get()
            .filter(item => item); // Filter out undefined/null/empty values
        
        console.log('Selected Measurements:', selectedMeasurements); // Debug
        
        // Make sure we have measurement values
        if (selectedMeasurements.length === 0) {
            console.log('No valid measurements selected or data attributes missing');
            $('#bulkpackaging').append('<option value="">Please select valid form types</option>');
            return;
        }
        
        // Show loading indicator
        $('#bulkpackaging').append('<option value="">Loading...</option>');
        
        $.ajax({
            url: 'fetch_bulk_packages.php',
            type: 'POST',
            dataType: 'json',
            data: { measurements: selectedMeasurements },
            success: function (response) {
                console.log('Server response:', response); // Log the response
                
                // Clear loading indicator
                $('#bulkpackaging').empty();
                
                if (Array.isArray(response) && response.length > 0) {
                    // Add options to the dropdown
                    response.forEach(pkg => {
                        $('#bulkpackaging').append(
                            `<option value="${pkg.bpid}">${pkg.name}</option>`
                        );
                    });
                    $('#bulkpackaging').trigger('change');
                } else if (Array.isArray(response) && response.length === 0) {
                    $('#bulkpackaging').append(
                        '<option value="">No matching packages found</option>'
                    );
                } else if (response && response.error) {
                    console.error('Server error:', response.error, response.message || '');
                    $('#bulkpackaging').append(
                        '<option value="">Error loading packages</option>'
                    );
                }
            },
            error: function (xhr, status, error) {
                console.error('AJAX error:', error);
                console.error('Status:', status);
                console.error('Response text:', xhr.responseText);
                
                // Try to parse response if possible
                let errorMessage = 'Failed to load packages';
                try {
                    if (xhr.responseText && xhr.responseText.trim() !== '') {
                        const errorData = JSON.parse(xhr.responseText);
                        if (errorData && errorData.error) {
                            errorMessage = errorData.error;
                        }
                    } else {
                        errorMessage = 'Server returned empty response';
                    }
                } catch (e) {
                    errorMessage = 'Invalid server response';
                }

                $('#bulkpackaging').empty().append(
                    `<option value="">${errorMessage}</option>`
                );
            },
            // Add timeout
            timeout: 10000,
            complete: function() {
                // Ensure select2 is refreshed
                if ($('#bulkpackaging').data('select2')) {
                    $('#bulkpackaging').select2('destroy').select2();
                }
            }
        });
    });
</script>


</body>

</html>

MMCT - 2023