init wms
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require '../../../preset.php';
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM md_contact_type
|
||||
WHERE
|
||||
company_id = {$company_id}";
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute();
|
||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
||||
exit(json_encode($answer));
|
||||
}
|
||||
|
||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$answer["success"] = 1;
|
||||
exit(json_encode($answer));
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require '../../../preset.php';
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
|
||||
$id = (int)$data['id'];
|
||||
|
||||
// Initialize log array
|
||||
$table_log = [];
|
||||
|
||||
// Get existing log only if we are updating an existing record
|
||||
if ($id > 0) {
|
||||
$sql = "SELECT `log`
|
||||
FROM md_contact_type
|
||||
WHERE
|
||||
company_id = :company_id AND
|
||||
id = :id";
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([
|
||||
":company_id" => $company_id,
|
||||
"id" => $id
|
||||
]);
|
||||
|
||||
if ($sth->errorCode() !== '00000') {
|
||||
$error = $sth->errorInfo();
|
||||
$answer["message"] = $error[2] ?? $error[0];
|
||||
exit(json_encode($answer));
|
||||
}
|
||||
|
||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row) {
|
||||
$table_log = json_decode($row['log'] ?? '[]', true);
|
||||
}
|
||||
}
|
||||
|
||||
// Append the new log entry (assuming $logging is defined in your preset/utils)
|
||||
$table_log[] = $logging;
|
||||
|
||||
if ($id > 0) {
|
||||
// UPDATE existing record
|
||||
$sql = "UPDATE md_contact_type SET
|
||||
`contact_type` = :contact_type,
|
||||
`description` = :description,
|
||||
`status` = :status,
|
||||
`log` = :log
|
||||
WHERE id = :id AND company_id = :company_id";
|
||||
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([
|
||||
":id" => $id,
|
||||
":company_id" => $company_id,
|
||||
":contact_type" => $data["contact_type"],
|
||||
":description" => $data["description"],
|
||||
":status" => (int)$data["status"],
|
||||
":log" => json_encode($table_log),
|
||||
]);
|
||||
|
||||
} else {
|
||||
// INSERT new record
|
||||
$sql = "INSERT INTO md_contact_type
|
||||
(company_id, contact_type, `description`, `status`, `log`)
|
||||
VALUES
|
||||
(:company_id, :contact_type, :description, :status, :log)";
|
||||
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([
|
||||
":company_id" => $company_id,
|
||||
":contact_type" => $data["contact_type"],
|
||||
":description" => $data["description"],
|
||||
":status" => (int)$data["status"],
|
||||
":log" => json_encode($table_log),
|
||||
]);
|
||||
}
|
||||
|
||||
$answer["success"] = 1;
|
||||
exit(json_encode($answer));
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require '../../../preset.php';
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
|
||||
$id = (int)$data['id'];
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM md_contact_type
|
||||
WHERE
|
||||
company_id = {$company_id} and
|
||||
id = {$id}";
|
||||
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute();
|
||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
||||
exit(json_encode($answer));
|
||||
}
|
||||
|
||||
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
$answer["success"] = 1;
|
||||
exit(json_encode($answer));
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../config.php';
|
||||
require '../include_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
<?php require '../include_topbar.php';?>
|
||||
<?php require '../include_sidebar.php';?>
|
||||
|
||||
|
||||
<!-- MAIN CONTENT -->
|
||||
<main id="content" class="content py-15">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-5 gap-3">
|
||||
<div class="">
|
||||
<h1 class="fs-3 mb-1">Contact</h1>
|
||||
<p class="mb-0">Manage your contact</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-5 mb-5">
|
||||
<div class="col-xl-3 col-md-6 col-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-6">
|
||||
<div class="d-flex align-items-start gap-3">
|
||||
<div class="icon-shape icon-lg bg-primary bg-opacity-10 text-primary rounded-2">
|
||||
<i class="ti ti-category fs-4 "></i>
|
||||
</div>
|
||||
<div class="">
|
||||
<span>Total Categories</span>
|
||||
<h2 class="fw-bold mb-0">6</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-xl-3 col-md-6 col-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-6">
|
||||
<div class="d-flex align-items-start gap-3">
|
||||
<div class="icon-shape icon-lg bg-info bg-opacity-10 text-info rounded-2">
|
||||
<i class="ti ti-check fs-4 "></i>
|
||||
</div>
|
||||
<div class="">
|
||||
<span>Active</span>
|
||||
<h2 class="fw-bold mb-0">5</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-xl-3 col-md-6 col-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-6">
|
||||
<div class="d-flex align-items-start gap-3">
|
||||
<div class="icon-shape icon-lg bg-warning bg-opacity-10 text-warning rounded-2">
|
||||
<i class="ti ti-x fs-4 "></i>
|
||||
</div>
|
||||
<div class="">
|
||||
<span>Inactive</span>
|
||||
<h2 class="fw-bold mb-0">1</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-xl-3 col-md-6 col-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-6">
|
||||
<div class="d-flex align-items-start gap-3">
|
||||
<div class="icon-shape icon-lg bg-warning bg-opacity-10 text-warning rounded-2">
|
||||
<i class="ti ti-box-seam fs-4 "></i>
|
||||
</div>
|
||||
<div class="">
|
||||
<span>Total Products</span>
|
||||
<h2 class="fw-bold mb-0">356</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-pills mb-3 bg-light p-2 rounded-2 d-inline-flex" id="pills-tab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="pills-contact_type-tab" data-bs-toggle="pill"
|
||||
data-bs-target="#pills-contact_type" type="button" role="tab" aria-controls="pills-contact_type"
|
||||
aria-selected="true">Contact Type</button>
|
||||
</li>
|
||||
<li class="nav-item nav-item-secondary" role="presentation">
|
||||
<button class="nav-link" id="pills-contact-tab" data-bs-toggle="pill" data-bs-target="#pills-contact"
|
||||
type="button" role="tab" aria-controls="pills-contact" aria-selected="false">Contacts</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="row g-5 mb-5 tab-pane fade show active" id="pills-contact_type" role="tabpanel"
|
||||
aria-labelledby="pills-contact_type-tab">
|
||||
<div class="col-12">
|
||||
<div class="card overflow-hidden">
|
||||
<div class="card-body p-6">
|
||||
|
||||
<div class="mb-6 d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<h3 class="mb-1 fs-4">Contact Types</h3>
|
||||
<p class="mb-0">List of all Type of Contact</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="<?php echo $server_url?>contact/manage_contact_type.php" class="btn btn-primary">
|
||||
<span class="me-1"><i class="ti ti-plus"></i></span>
|
||||
<span>Add Contact Type</span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 mb-5">
|
||||
<div class="position-relative">
|
||||
<input type="search" class="form-control ps-9" placeholder="Search by product name or SKU">
|
||||
<span class="position-absolute top-25 ms-4">
|
||||
<i class="ti ti-search text-muted"></i>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0 text-nowrap table-hover table-centered" id="contact_type">
|
||||
<thead class="table-primary border-light">
|
||||
<tr>
|
||||
<th>Contact Type</th>
|
||||
<th>Description</th>
|
||||
<th>Contact</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tfoot class="">
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row g-5 mb-5 tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-5">
|
||||
<div class="mb-6 d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<h3 class="mb-1 fs-4">Contacts</h3>
|
||||
<p class="mb-0">List of all contact list</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="<?php echo $server_url?>contact/manage_contact.php" class="btn btn-secondary">
|
||||
<span class="me-1"><i class="ti ti-plus"></i></span>
|
||||
<span>Add Contact</span></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0 table-centered" id="product">
|
||||
<thead class="table-secondary border-light">
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th>SKU</th>
|
||||
<th>Current Stock</th>
|
||||
<th>Min Stock</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tfoot class="">
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<?php require "../include_ending.php";?>
|
||||
|
||||
<script>
|
||||
function retrieve_contact_type() {
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>contact/api/engine/contact_type.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
debugMode: 0,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
|
||||
// Register the array as a table name
|
||||
alasql('CREATE TABLE IF NOT EXISTS contact_type');
|
||||
alasql.tables.contact_type.data = res.output || [];
|
||||
|
||||
var total_records = alasql.tables.contact_type.data.length;
|
||||
|
||||
var table_id = 'contact_type';
|
||||
|
||||
var page = generate_pagination(table_id,total_records);
|
||||
$(`table#${table_id} tfoot`).html(page);
|
||||
|
||||
// dynamic function name
|
||||
if (typeof window[`change_page_${table_id}`] === "function") {
|
||||
window[`change_page_${table_id}`](1);
|
||||
} else {
|
||||
console.error(`Function change_page_${table_id} does not exist.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function change_page_contact_type(page_num) {
|
||||
|
||||
var offset = (page_num - 1) * prop_limit;
|
||||
|
||||
var page_data = alasql(`SELECT * FROM contact_type LIMIT ${prop_limit} OFFSET ${offset}`);
|
||||
|
||||
var body = ``;
|
||||
$.each(page_data, function(key, item) {
|
||||
body += `<tr>
|
||||
<td class="py-3">${item['contact_type']}</td>
|
||||
<td class="py-3">${item['description']}</td>
|
||||
<td class="py-3">${item['status']}</td>
|
||||
<td class="py-3">
|
||||
${(item['status'])?'<span class="badge bg-success">Active</span>':'<span class="badge bg-secondary">Inactive</span>'}
|
||||
</td>
|
||||
<td class="py-3">
|
||||
<a href="<?php echo $server_url?>contact/manage_contact_type.php?id=${item['id']}" class=""><i class="ti ti-eye fs-5"></i></a>
|
||||
<a href="#" class="link-danger"><i class="ti ti-trash ms-2 fs-5"></i></a>
|
||||
</td>
|
||||
</tr>`;
|
||||
})
|
||||
|
||||
$("table#contact_type > tbody").html(body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function retrieve_product() {
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>inventory/api/engine/product.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
onSuccess: function(res) {
|
||||
|
||||
// Register the array as a table name
|
||||
alasql('CREATE TABLE IF NOT EXISTS product');
|
||||
alasql.tables.product.data = res.output || [];
|
||||
|
||||
var total_records = alasql.tables.product.data.length;
|
||||
|
||||
var table_id = 'product';
|
||||
|
||||
var page = generate_pagination(table_id,total_records);
|
||||
$(`table#${table_id} tfoot`).html(page);
|
||||
|
||||
// dynamic function name
|
||||
if (typeof window[`change_page_${table_id}`] === "function") {
|
||||
window[`change_page_${table_id}`](1);
|
||||
} else {
|
||||
console.error(`Function change_page_${table_id} does not exist.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function change_page_product(page_num) {
|
||||
|
||||
var offset = (page_num - 1) * prop_limit;
|
||||
|
||||
var page_data = alasql(`SELECT * FROM product LIMIT ${prop_limit} OFFSET ${offset}`);
|
||||
|
||||
var body = ``;
|
||||
$.each(page_data, function(key, item) {
|
||||
body += `<tr>
|
||||
<td class="py-3">${item['product_name']}</td>
|
||||
<td class="py-3">${item['sku']}</td>
|
||||
<td class="py-3">${item['description']}</td>
|
||||
<td class="py-3">${item['status']}</td>
|
||||
<td class="py-3">
|
||||
${(item['status'])?'<span class="badge bg-success">Active</span>':'<span class="badge bg-secondary">Inactive</span>'}
|
||||
</td>
|
||||
<td class="py-3">
|
||||
<a href="<?php echo $server_url?>inventory/manage_product.php?id=${item['id']}" class=""><i class="ti ti-eye fs-5"></i></a>
|
||||
<a href="#" class="link-danger"><i class="ti ti-trash ms-2 fs-5"></i></a>
|
||||
</td>
|
||||
</tr>`;
|
||||
})
|
||||
|
||||
$("table#product > tbody").html(body);
|
||||
|
||||
}
|
||||
|
||||
$(async function() {
|
||||
try {
|
||||
await retrieve_contact_type();
|
||||
// await retrieve_product();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
// switching to nav-link from last leave
|
||||
$('button.nav-link').on('click', function() {
|
||||
nav_id = $(this).attr('id');
|
||||
sessionStorage.setItem("contact_nav_id", nav_id);
|
||||
})
|
||||
let nav_id = sessionStorage.getItem("contact_nav_id");
|
||||
if(nav_id){
|
||||
$(`button#${nav_id}`).trigger('click');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../config.php';
|
||||
require '../include_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
<?php require '../include_topbar.php';?>
|
||||
<?php require '../include_sidebar.php';?>
|
||||
|
||||
|
||||
<!-- MAIN CONTENT -->
|
||||
<main id="content" class="content py-15">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-5 gap-3">
|
||||
<div class="">
|
||||
<h1 class="fs-3 mb-1">Manage Contact</h1>
|
||||
<p class="mb-0">Create/Update contact records</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-5">
|
||||
<div class="col-lg-8 col-12">
|
||||
<div class="card mb-5 ">
|
||||
<div class="card-body p-6">
|
||||
<h2 class="fs-4 mb-3">Contact Information</h2>
|
||||
<div class="row g-5">
|
||||
<div class="col-lg-6">
|
||||
<label for="productName" class="form-label">Contact Name</label>
|
||||
<input type="text" name="" id="productName" class="form-control" placeholder="Name">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<label for="productName" class="form-label">Tax ID/Citizen ID</label>
|
||||
<input type="text" name="" id="productName" class="form-control" placeholder="xxxxxxxxxxxxx">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<label for="sku" class="form-label"> Organization</label>
|
||||
<input type="text" name="" id="sku" class="form-control" placeholder="company name">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<label for="sku" class="form-label"> Branch</label>
|
||||
<input type="text" name="" id="sku" class="form-control" placeholder="00000">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<label for="catogires" class="form-label"> Contact Type</label>
|
||||
<select name="" id="catogires" class="form-select">
|
||||
<option value="Leptop">Leptop</option>
|
||||
<option value="Desktop">Desktop</option>
|
||||
<option value="Accessories">Accessories</option>
|
||||
<option value="Phone">Phone</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<label for="address" class="form-label"> Billing Address</label>
|
||||
<textarea name="address" rows="3" id="address" class="form-control"
|
||||
placeholder="Customer Billing Address."></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card ">
|
||||
<div class="card-body p-6">
|
||||
<h2 class="fs-4 mb-3">Shipping Information</h2>
|
||||
<div class="row g-5">
|
||||
<div class="col-lg-12">
|
||||
<label for="shipping_location" class="form-label"> Shipping Location</label>
|
||||
<input type="text" name="" id="shipping_location" class="form-control" placeholder="">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<label for="shipping_address" class="form-label"> Shipping Address</label>
|
||||
<textarea name="shipping_address" rows="3" id="shipping_address" class="form-control"
|
||||
placeholder="Customer Shipping Address."></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-lg-4 col-12">
|
||||
<div class="card mb-5">
|
||||
<div class="card-body p-6">
|
||||
<h2 class="fs-4 mb-3">Contact Images</h2>
|
||||
<div id="my-dropzone" class="dropzone border border-dashed rounded-3">
|
||||
<div class="fallback"><input type="file" name="file" id="file" /></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card mb-5">
|
||||
<div class="card-body p-6">
|
||||
<div class="">
|
||||
<label for="status" class="form-label">Status</label>
|
||||
<select name="status" id="status" class="form-select">
|
||||
<option value="1"> Active </option>
|
||||
<option value="0"> Inactive </option>
|
||||
<option value="Draft"> Draft </option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card mb-5">
|
||||
<div class="card-body p-6">
|
||||
<div class="row g-5">
|
||||
<div class="col-lg-12">
|
||||
<label for="remark" class="form-label"> Remark</label>
|
||||
<textarea name="remark" rows="10" id="remark" class="form-control" placeholder=""></textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary" onclick="manage_contact();">Create</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php require "../include_ending.php";?>
|
||||
|
||||
<script>
|
||||
function manage_contact() {
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>contact/api/engine/manage_contact.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 1,
|
||||
debugMode: 1,
|
||||
action: 'manage',
|
||||
onSuccess: function(res) {
|
||||
|
||||
window.location.href = "<?php echo $server_url?>contact/contact.php";
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function retreive_for_edit() {
|
||||
|
||||
<?php if(empty($_GET['id'])){ ?>
|
||||
return false;
|
||||
<?php } ?>
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>contact/api/engine/retrieve_contact_type.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
|
||||
$.each(res.output, function(key, item) {
|
||||
$(`#${key}`).val(item);
|
||||
});
|
||||
|
||||
$(`button[type=submit]`).text('Update');
|
||||
|
||||
$(`button[type=reset]`).hide();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(async function() {
|
||||
try {
|
||||
await retreive_for_edit();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../config.php';
|
||||
require '../include_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
<?php require '../include_topbar.php';?>
|
||||
<?php require '../include_sidebar.php';?>
|
||||
|
||||
|
||||
<!-- MAIN CONTENT -->
|
||||
<main id="content" class="content py-15">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-5 gap-3">
|
||||
<div class="">
|
||||
<h1 class="fs-3 mb-1">Manage Type</h1>
|
||||
<p class="mb-0">Create/Update your contact type</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="contact_typeForm">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body p-6">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="contact_type" class="form-label">Type Name</label>
|
||||
<input type="text" class="form-control" id="contact_type" placeholder="Enter contact_type name" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="status" class="form-label">status</label>
|
||||
<select class="form-select" id="status" required>
|
||||
<option value="1">Active</option>
|
||||
<option value="0">inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" rows="4"
|
||||
placeholder="Enter product description"></textarea>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary" onclick="manage_type();">Create Type</button>
|
||||
<button type="reset" class="btn btn-secondary" onclick="reset_input('#contact_typeForm');">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php require "../include_ending.php";?>
|
||||
|
||||
<script>
|
||||
function manage_type() {
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>contact/api/engine/manage_contact_type.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 1,
|
||||
debugMode: 0,
|
||||
action: 'manage',
|
||||
onSuccess: function(res) {
|
||||
|
||||
window.location.href = "<?php echo $server_url?>contact/contact.php";
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function retreive_for_edit() {
|
||||
|
||||
<?php if(empty($_GET['id'])){ ?>
|
||||
return false;
|
||||
<?php } ?>
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>contact/api/engine/retrieve_contact_type.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
|
||||
$.each(res.output, function(key, item) {
|
||||
$(`#${key}`).val(item);
|
||||
});
|
||||
|
||||
$(`button[type=submit]`).text('Update');
|
||||
|
||||
$(`button[type=reset]`).hide();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(async function() {
|
||||
try {
|
||||
await retreive_for_edit();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user