update for Audit form Contact for Accredia M18b

This commit is contained in:
Claudio 2024-09-18 16:01:31 +02:00
parent eb475f257e
commit 91ae77aff1
5 changed files with 332 additions and 200 deletions

View File

@ -1,5 +1,28 @@
<?php
include('include/headscript.php'); ?>
<?php
// Controlla se è necessario aggiungere un nuovo contatto
if (isset($_GET['add_new_contact'])) {
$InsertQuery = new WA_MySQLi_Query($cmctrfdb);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "contacts";
$InsertQuery->bindColumn("idtrf", "i", $_GET['idtrf'], "WA_DEFAULT");
$InsertQuery->bindColumn("kindofcontacts", "s", "audit", "WA_DEFAULT");
$InsertQuery->bindColumn("companyid", "i", $idcompany, "WA_DEFAULT");
// Inserisci il nuovo record vuoto
$InsertQuery->saveInSession("");
$InsertQuery->execute();
// Ottieni l'ultimo ID inserito usando l'oggetto di connessione
$new_contact_id = $cmctrfdb->insert_id;
// Reindirizza al popup per modificare il nuovo contatto
header("Location: contactpopaudit.php?kindcontacts=audit&idtrf=" . $_GET['idtrf'] . "&idcontacts=" . $new_contact_id);
exit;
}
?>
<?php
// pickup the get variable
$formname = "nocontact";
@ -39,12 +62,119 @@ if (isset($_GET["kindcontactscopy"])) {
if (isset($_POST["kindcontactscopy"])) {
$kindcontactscopy = $_POST["kindcontactscopy"];
}
// Aggiungere un nuovo contatto quando si clicca su "Aggiungi"
if (isset($_POST['add_new_contact'])) {
$InsertQuery = new WA_MySQLi_Query($cmctrfdb);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "contacts";
$InsertQuery->bindColumn("idtrf", "i", "$idtrf", "WA_DEFAULT");
$InsertQuery->bindColumn("kindofcontacts", "s", "audit", "WA_DEFAULT");
// Inserisci un nuovo record vuoto con i campi necessari
$InsertQuery->saveInSession("");
$InsertQuery->execute();
// Ottieni l'id del nuovo contatto
$new_contact_id = $InsertQuery->getLastInsertID();
// Reindirizza al popup di modifica per il nuovo contatto
header("Location: contactpopaudit.php?kindcontacts=audit&idtrf=$idtrf&idcontacts=$new_contact_id");
exit;
}
?>
<?php
$countrylist = new WA_MySQLi_RS("countrylist", $cmctrfdb, 0);
$countrylist->setQuery("SELECT * FROM countries ORDER BY countries.namecountry");
$countrylist->execute();
?>
<?php
// edit contact search engine
if ($formname == "searchnamedet") {
// Recupera i dati da GET o POST
if (isset($_GET["companynamevalue"])) {
$compname = $_GET["companynamevalue"];
} elseif (isset($_POST["companynamevalue"])) {
$compname = $_POST["companynamevalue"];
}
$companyid = 0;
// Esegui la query per ottenere i dettagli del contatto
$searchctdetail = new WA_MySQLi_RS("searchctdetail", $cmctrfdb, 1);
$searchctdetail->setQuery("SELECT * FROM contacts WHERE contacts.companyname='$compname'");
$searchctdetail->execute();
// Popola i valori del contatto dai risultati della query
$companynamet = !empty($searchctdetail->getColumnVal("companyname")) ? $searchctdetail->getColumnVal("companyname") : "";
$piva = !empty($searchctdetail->getColumnVal("piva")) ? $searchctdetail->getColumnVal("piva") : "";
$address = !empty($searchctdetail->getColumnVal("address")) ? $searchctdetail->getColumnVal("address") : "";
$city = !empty($searchctdetail->getColumnVal("city")) ? $searchctdetail->getColumnVal("city") : "";
$cap = !empty($searchctdetail->getColumnVal("cap")) ? $searchctdetail->getColumnVal("cap") : "";
$country = !empty($searchctdetail->getColumnVal("country")) ? $searchctdetail->getColumnVal("country") : "";
$telephone = !empty($searchctdetail->getColumnVal("telephone")) ? $searchctdetail->getColumnVal("telephone") : "";
$email = !empty($searchctdetail->getColumnVal("email")) ? $searchctdetail->getColumnVal("email") : "";
$contactname = !empty($searchctdetail->getColumnVal("contactname")) ? $searchctdetail->getColumnVal("contactname") : "";
$contactsurname = !empty($searchctdetail->getColumnVal("contactsurname")) ? $searchctdetail->getColumnVal("contactsurname") : "";
// Recupera i nuovi campi da GET o POST (se presenti)
$projectperson = !empty($searchctdetail->getColumnVal("projectperson")) ? $searchctdetail->getColumnVal("projectperson") : "";
$salesperson = !empty($searchctdetail->getColumnVal("salesperson")) ? $searchctdetail->getColumnVal("salesperson") : "";
$productionperson = !empty($searchctdetail->getColumnVal("productionperson")) ? $searchctdetail->getColumnVal("productionperson") : "";
$csperson = !empty($searchctdetail->getColumnVal("csperson")) ? $searchctdetail->getColumnVal("csperson") : "";
$qualityperson = !empty($searchctdetail->getColumnVal("qualityperson")) ? $searchctdetail->getColumnVal("qualityperson") : "";
$purchaseperson = !empty($searchctdetail->getColumnVal("purchaseperson")) ? $searchctdetail->getColumnVal("purchaseperson") : "";
$activities = !empty($searchctdetail->getColumnVal("activities")) ? $searchctdetail->getColumnVal("activities") : "";
$otheractivities = !empty($searchctdetail->getColumnVal("otheractivities")) ? $searchctdetail->getColumnVal("otheractivities") : "";
$otheractivitiesperson = !empty($searchctdetail->getColumnVal("otheractivitiesperson")) ? $searchctdetail->getColumnVal("otheractivitiesperson") : "";
$languageforaudit = !empty($searchctdetail->getColumnVal("languageforaudit")) ? $searchctdetail->getColumnVal("languageforaudit") : "";
$outsourcing_process = !empty($searchctdetail->getColumnVal("outsourcing_process")) ? $searchctdetail->getColumnVal("outsourcing_process") : "";
// Aggiornamento del database
$UpdateQuery = new WA_MySQLi_Query($cmctrfdb);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "contacts";
// Colonne per l'aggiornamento
$UpdateQuery->bindColumn("companyname", "s", $companynamet, "WA_DEFAULT");
$UpdateQuery->bindColumn("piva", "s", $piva, "WA_DEFAULT");
$UpdateQuery->bindColumn("address", "s", $address, "WA_DEFAULT");
$UpdateQuery->bindColumn("city", "s", $city, "WA_DEFAULT");
$UpdateQuery->bindColumn("cap", "s", $cap, "WA_DEFAULT");
$UpdateQuery->bindColumn("country", "s", $country, "WA_DEFAULT");
$UpdateQuery->bindColumn("telephone", "s", $telephone, "WA_DEFAULT");
$UpdateQuery->bindColumn("email", "s", $email, "WA_DEFAULT");
$UpdateQuery->bindColumn("contactname", "s", $contactname, "WA_DEFAULT");
$UpdateQuery->bindColumn("contactsurname", "s", $contactsurname, "WA_DEFAULT");
// Nuovi campi
$UpdateQuery->bindColumn("projectperson", "s", $projectperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("salesperson", "s", $salesperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("productionperson", "s", $productionperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("csperson", "s", $csperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("qualityperson", "s", $qualityperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("purchaseperson", "s", $purchaseperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("activities", "s", $activities, "WA_DEFAULT");
$UpdateQuery->bindColumn("otheractivities", "s", $otheractivities, "WA_DEFAULT");
$UpdateQuery->bindColumn("otheractivitiesperson", "s", $otheractivitiesperson, "WA_DEFAULT");
$UpdateQuery->bindColumn("languageforaudit", "s", $languageforaudit, "WA_DEFAULT");
$UpdateQuery->bindColumn("outsourcing_process", "s", $outsourcing_process, "WA_DEFAULT");
// Filtro per ID del contatto
$UpdateQuery->addFilter("idcontacts", "=", "i", $idcontacts);
$UpdateQuery->execute();
// Reindirizzamento
$UpdateGoTo = "";
if (function_exists("rel2abs")) {
$UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : "";
}
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<?php
//edit contact details
if ($formname == "editcontactsdetails") {
@ -132,6 +262,11 @@ if ($formname == "editcontactsdetails") {
} else {
$purchaseperson = "";
}
if (isset($_POST["activities"])) {
$activities = $_POST["activities"];
} else {
$activities = "";
}
if (isset($_POST["otheractivities"])) {
$otheractivities = $_POST["otheractivities"];
} else {
@ -177,6 +312,7 @@ if ($formname == "editcontactsdetails") {
$UpdateQuery->bindColumn("csperson", "s", "$csperson", "WA_DEFAULT");
$UpdateQuery->bindColumn("qualityperson", "s", "$qualityperson", "WA_DEFAULT");
$UpdateQuery->bindColumn("purchaseperson", "s", "$purchaseperson", "WA_DEFAULT");
$UpdateQuery->bindColumn("activities", "s", "$activities", "WA_DEFAULT");
$UpdateQuery->bindColumn("otheractivities", "s", "$otheractivities", "WA_DEFAULT");
$UpdateQuery->bindColumn("otheractivitiesperson", "s", "$otheractivitiesperson", "WA_DEFAULT");
$UpdateQuery->bindColumn("languageforaudit", "s", "$languageforaudit", "WA_DEFAULT");
@ -192,186 +328,6 @@ if ($formname == "editcontactsdetails") {
}
?>
<?php //copy mycompany
if ($formname == "copymycompany") {
$contactsdet = new WA_MySQLi_RS("contactsdet", $cmctrfdb, 1);
$contactsdet->setQuery("SELECT * FROM company WHERE company.idcompany='$idcompany'");
$contactsdet->execute();
if (!is_null($contactsdet->getColumnVal("companyname_company"))) {
$companynamet = $contactsdet->getColumnVal("companyname_company");
} else {
$companynamet = "";
}
if (!is_null($contactsdet->getColumnVal("piva_company"))) {
$piva = $contactsdet->getColumnVal("piva_company");
} else {
$piva = "";
}
if (!is_null($contactsdet->getColumnVal("address_company"))) {
$address = $contactsdet->getColumnVal("address_company");
} else {
$address = "";
}
if (!is_null($contactsdet->getColumnVal("city_company"))) {
$city = $contactsdet->getColumnVal("city_company");
} else {
$city = "";
}
if (!is_null($contactsdet->getColumnVal("zip_company"))) {
$cap = $contactsdet->getColumnVal("zip_company");
} else {
$cap = "";
}
if (!is_null($contactsdet->getColumnVal("country_company"))) {
$country = $contactsdet->getColumnVal("country_company");
} else {
$country = "";
}
if (!is_null($contactsdet->getColumnVal("telephone_company"))) {
$telephone = $contactsdet->getColumnVal("telephone_company");
} else {
$telephone = "";
}
if (!is_null($contactsdet->getColumnVal("email_company"))) {
$email = $contactsdet->getColumnVal("email_company");
} else {
$email = "";
}
if (!is_null($contactsdet->getColumnVal("maincontactname_company"))) {
$contactname = $contactsdet->getColumnVal("maincontactname_company");
} else {
$contactname = "";
}
if (!is_null($contactsdet->getColumnVal("maincontactsurname_company"))) {
$contactsurname = $contactsdet->getColumnVal("maincontactsurname_company");
} else {
$contactsurname = "";
}
if (!is_null($idcompany)) {
$companyid = $idcompany;
} else {
$companyid = "";
}
$UpdateQuery = new WA_MySQLi_Query($cmctrfdb);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "contacts";
$UpdateQuery->bindColumn("companyname", "s", "$companynamet", "WA_DEFAULT");
$UpdateQuery->bindColumn("piva", "s", "$piva", "WA_DEFAULT");
$UpdateQuery->bindColumn("address", "s", "$address", "WA_DEFAULT");
$UpdateQuery->bindColumn("city", "s", "$city", "WA_DEFAULT");
$UpdateQuery->bindColumn("cap", "s", "$cap", "WA_DEFAULT");
$UpdateQuery->bindColumn("country", "s", "$country", "WA_DEFAULT");
$UpdateQuery->bindColumn("telephone", "s", "$telephone", "WA_DEFAULT");
$UpdateQuery->bindColumn("email", "s", "$email", "WA_DEFAULT");
$UpdateQuery->bindColumn("contactname", "s", "$contactname", "WA_DEFAULT");
$UpdateQuery->bindColumn("contactsurname", "s", "$contactsurname", "WA_DEFAULT");
$UpdateQuery->bindColumn("companyid", "i", "$companyid", "WA_DEFAULT");
$UpdateQuery->addFilter("idcontacts", "=", "i", "" . ($idcontacts) . "");
$UpdateQuery->execute();
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : "";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<?php //copy contacts
if ($formname == "copycontacts") {
$contactsdet = new WA_MySQLi_RS("contactsdet", $cmctrfdb, 1);
$contactsdet->setQuery("SELECT * FROM contacts WHERE contacts.idtrf='$idtrf' AND contacts.kindofcontacts='$kindcontactscopy'");
$contactsdet->execute();
if (!is_null($contactsdet->getColumnVal("companyname"))) {
$companynamet = $contactsdet->getColumnVal("companyname");
} else {
$companynamet = "";
}
if (!is_null($contactsdet->getColumnVal("piva"))) {
$piva = $contactsdet->getColumnVal("piva");
} else {
$piva = "";
}
if (!is_null($contactsdet->getColumnVal("address"))) {
$address = $contactsdet->getColumnVal("address");
} else {
$address = "";
}
if (!is_null($contactsdet->getColumnVal("city"))) {
$city = $contactsdet->getColumnVal("city");
} else {
$city = "";
}
if (!is_null($contactsdet->getColumnVal("cap"))) {
$cap = $contactsdet->getColumnVal("cap");
} else {
$cap = "";
}
if (!is_null($contactsdet->getColumnVal("country"))) {
$country = $contactsdet->getColumnVal("country");
} else {
$country = "";
}
if (!is_null($contactsdet->getColumnVal("telephone"))) {
$telephone = $contactsdet->getColumnVal("telephone");
} else {
$telephone = "";
}
if (!is_null($contactsdet->getColumnVal("email"))) {
$email = $contactsdet->getColumnVal("email");
} else {
$email = "";
}
if (!is_null($contactsdet->getColumnVal("contactname"))) {
$contactname = $contactsdet->getColumnVal("contactname");
} else {
$contactname = "";
}
if (!is_null($contactsdet->getColumnVal("contactsurname"))) {
$contactsurname = $contactsdet->getColumnVal("contactsurname");
} else {
$contactsurname = "";
}
$companyid = 0;
$UpdateQuery = new WA_MySQLi_Query($cmctrfdb);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "contacts";
$UpdateQuery->bindColumn("companyname", "s", "$companynamet", "WA_DEFAULT");
$UpdateQuery->bindColumn("piva", "s", "$piva", "WA_DEFAULT");
$UpdateQuery->bindColumn("address", "s", "$address", "WA_DEFAULT");
$UpdateQuery->bindColumn("city", "s", "$city", "WA_DEFAULT");
$UpdateQuery->bindColumn("cap", "s", "$cap", "WA_DEFAULT");
$UpdateQuery->bindColumn("country", "s", "$country", "WA_DEFAULT");
$UpdateQuery->bindColumn("telephone", "s", "$telephone", "WA_DEFAULT");
$UpdateQuery->bindColumn("email", "s", "$email", "WA_DEFAULT");
$UpdateQuery->bindColumn("contactname", "s", "$contactname", "WA_DEFAULT");
$UpdateQuery->bindColumn("contactsurname", "s", "$contactsurname", "WA_DEFAULT");
$UpdateQuery->bindColumn("companyid", "i", "$companyid", "WA_DEFAULT");
$UpdateQuery->addFilter("idcontacts", "=", "i", "" . ($idcontacts) . "");
$UpdateQuery->execute();
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : "";
$UpdateQuery->redirect($UpdateGoTo);
}
if ($kindcontacts == "certificatetotest") {
$UpdateQuery = new WA_MySQLi_Query($cmctrfdb);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "`trf-details`";
$UpdateQuery->bindColumn("certotherclient", "s", "Y", "WA_DEFAULT");
$UpdateQuery->addFilter("idtrfdetails", "=", "i", "" . ($idtrf) . "");
$UpdateQuery->execute();
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : "";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<?php
$trfnumberfinal = new WA_MySQLi_RS("trfnumberfinal", $cmctrfdb, 0);
$trfnumberfinal->setQuery("SELECT * FROM `trf-details` WHERE `trf-details`.idtrfdetails='$idtrf'");
@ -456,7 +412,7 @@ unset($wa_repeatcount);
<!-- search on article -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="searchengine/scriptsearchcontact.js"></script>
<script type="text/javascript" src="searchengine/scriptsearchcontactaudit.js"></script>
<!-- submit form with button -->
<style>
@ -499,7 +455,13 @@ unset($wa_repeatcount);
<div class="card-body">
<h4 class="mt-0 header-title">CONTACT FORM</h4>
<?php echo $copycontactfrom; ?>
<?php include('include/querycontacts.php'); ?>
<?php
$contactdata = new WA_MySQLi_RS("contactdata", $cmctrfdb, 1);
$contactdata->setQuery("SELECT * FROM contacts WHERE contacts.idcontacts='$idcontacts'");
$contactdata->execute();
$compid = $contactdata->getColumnVal("companyid");
?>
<?php if ($compid < 1) { ?>
<a href="contactpop.php?idcontacts=<?php echo ($contactdata->getColumnVal("idcontacts")); ?>&kindcontactscopy=mycompany&idtrf=<?php echo $idtrf; ?>&formname=copymycompany&kindcontacts=<?php echo $kindcontacts; ?>"><button type="button" class="btn btn-outline-secondary waves-effect"><?php echo $anagraficamycompany; ?></button> </a> <?php } ?>
<?php if ($kindcontacts != "audit") { ?><?php if (in_array('audit', $contactlist)) { ?><a href="contactpop.php?idcontacts=<?php echo ($contactdata->getColumnVal("idcontacts")); ?>&kindcontactscopy=audit&idtrf=<?php echo $idtrf; ?>&formname=copycontacts&kindcontacts=<?php echo $kindcontacts; ?>"><button type="button" class="btn btn-outline-secondary waves-effect"><?php echo $anagraficaaudit; ?></button></a><?php }
@ -569,6 +531,7 @@ unset($wa_repeatcount);
<input type="text" class="form-control" id="contactname" name="contactname" value="<?php echo ($contactdata->getColumnVal("contactname")); ?>" placeholder="<?php echo $contactnametitle; ?>" required>
</div>
</div>
<input type="hidden" class="form-control" id="formname" name="formname" value="editcontactsdetails">
<div class="form-row">
<div class="col-md-4 mb-3">
@ -617,7 +580,7 @@ unset($wa_repeatcount);
</div>
<div class="col-md-3 mb-3">
<label for="otheractivitiesperson"><?php echo $other_activitypersontitle; ?></label>
<input type="text" class="form-control" id="otheractivitiesperson" name="otheractivitiesperson" value="<?php echo ($contactdata->getColumnVal("other_activitypersontitle")); ?>">
<input type="text" class="form-control" id="otheractivitiesperson" name="otheractivitiesperson" value="<?php echo ($contactdata->getColumnVal("otheractivitiesperson")); ?>">
</div>
</div>
<hr>
@ -627,8 +590,8 @@ unset($wa_repeatcount);
<input type="text" class="form-control" id="languageforaudit" name="languageforaudit" value="<?php echo ($contactdata->getColumnVal("languageforaudit")); ?>">
</div>
<div class="col-md-9 mb-3">
<label for="outsourcing process"><?php echo $outsourced_processestitle; ?></label>
<input type="text" class="form-control" id="outsourcing process" name="outsourcing process" value="<?php echo ($contactdata->getColumnVal("outsourcing process")); ?>">
<label for="outsourcing_process"><?php echo $outsourced_processestitle; ?></label>
<input type="text" class="form-control" id="outsourcing_process" name="outsourcing_process" value="<?php echo ($contactdata->getColumnVal("outsourcing_process")); ?>">
</div>
</div>

18
public/delete_contact.php Normal file
View File

@ -0,0 +1,18 @@
<?php
include('db-connect.php'); // Connessione al database
if (isset($_POST['idcontacts'])) {
$idcontacts = $_POST['idcontacts'];
// Esegui la query per eliminare il contatto
$deleteQuery = $cmctrfdb->prepare("DELETE FROM contacts WHERE idcontacts = ?");
$deleteQuery->bind_param("i", $idcontacts);
if ($deleteQuery->execute()) {
echo 'success';
} else {
echo 'error';
}
$deleteQuery->close();
}

View File

@ -0,0 +1,37 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
//Including Database configuration file.
include "../db.php";
$iduserlog = $_SESSION["iduserlogin"];
//Getting value of "search" variable from "script.js".
if (isset($_POST['companynamevalue'])) {
//Search box value assigning to $Name variable.
$Name = $_POST['companynamevalue'];
//Search query.
$Query = "SELECT DISTINCT contacts.companyname FROM contacts LEFT JOIN `trf-details` ON `trf-details`.idtrfdetails=contacts.idtrf WHERE contacts.companyname LIKE '%$Name%' AND `trf-details`.iduser='$iduserlog' LIMIT 5";
//Query execution
$ExecQuery = MySQLi_query($conn, $Query);
//Creating unordered list to display result.
echo '
<ul>
';
//Fetching result from database.
while ($Result = MySQLi_fetch_array($ExecQuery)) {
?>
<!-- Creating unordered list items.
Calling javascript function named as "fill" found in "script.js" file.
By passing fetched result as parameter. -->
<li onclick='fill("<?php echo $Result['companyname']; ?>")'>
<a>
<!-- Assigning searched result in "Search box" in "search.php" file. -->
<?php echo $Result['companyname']; ?>
</li></a>
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
<?php
}
}
?>
</ul>

View File

@ -0,0 +1,39 @@
//Getting value from "ajax.php".
function fill(Value) {
//Assigning value to "search" div in "search.php" file.
$('#companynamevalue').val(Value)
//Hiding "display" div in "search.php" file.
$('#display').hide()
}
$(document).ready(function () {
//On pressing a key on "Search box" in "search.php" file. This function will be called.
$('#companynamevalue').keyup(function () {
//Assigning search box value to javascript variable named as "name".
var name = $('#companynamevalue').val()
//Validating, if "name" is empty.
if (name == '') {
//Assigning empty value to "display" div in "search.php" file.
$('#display').html('')
}
//If name is not empty.
else {
//AJAX is called.
$.ajax({
//AJAX type is "Post".
type: 'POST',
//Data will be sent to "ajax.php".
url: 'searchengine/ajaxsearchcontact.php',
//Data, that will be sent to "ajax.php".
data: {
//Assigning value of "name" into "search" variable.
companynamevalue: name,
},
//If result found, this funtion will be called.
success: function (html) {
//Assigning result to "display" div in "search.php" file.
$('#display').html(html).show()
},
})
}
})
})

View File

@ -283,7 +283,7 @@ $idprotectioncategoryJson = json_encode($idproteccategorylistRecord);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> -->
<script src="https://kit.fontawesome.com/f13e61f9bf.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@ -518,31 +518,51 @@ $idprotectioncategoryJson = json_encode($idproteccategorylistRecord);
<p><?php echo $auditcompanylocation; ?></p>
<?php
$audticontactdata = new WA_MySQLi_RS("audticontactdata", $cmctrfdb, 1);
$audticontactdata->setQuery("SELECT * FROM contacts WHERE contacts.idtrf='$idtrf' AND contacts.kindofcontacts='audit'");
$audticontactdata->execute();
$auditcontactlist = new WA_MySQLi_RS("auditcontactlist", $cmctrfdb, 0);
$auditcontactlist->setQuery("SELECT * FROM contacts WHERE contacts.idtrf='$idtrf' AND contacts.kindofcontacts='audit'");
$auditcontactlist->execute();
?>
<table class="table mb-0">
<thead>
<tr>
<th scope="col"><?php echo $anagraficacompany; ?></th>
<th scope="col"><?php echo $anagraficaaddress; ?></th>
<th scope="col"><?php echo $anagraficacity; ?></th>
<th><?php echo $anagraficacompany; ?></th>
<th><?php echo $anagraficaaddress; ?></th>
<th><?php echo $anagraficacity; ?></th>
<th><?php echo "Action"; ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo ($audticontactdata->getColumnVal("companyname")); ?></td>
<td><?php echo ($audticontactdata->getColumnVal("address")); ?></td>
<td><?php echo ($audticontactdata->getColumnVal("city")); ?></td>
</tr>
<?php while (!$auditcontactlist->atEnd()) { ?>
<tr>
<td><?php echo $auditcontactlist->getColumnVal("companyname"); ?></td>
<td><?php echo $auditcontactlist->getColumnVal("address"); ?></td>
<td><?php echo $auditcontactlist->getColumnVal("city"); ?></td>
<td>
<!-- Pulsante di modifica -->
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&idcontacts=<?php echo ($auditcontactlist->getColumnVal("idcontacts")); ?>', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');">
<button type="button" class="btn btn-primary waves-effect waves-light">MODIFICA</button>
</a>
<!-- Pulsante di eliminazione (cestino) -->
<button type="button" class="btn btn-danger waves-effect waves-light delete-contact" data-id="<?php echo $auditcontactlist->getColumnVal('idcontacts'); ?>">
<i class="fas fa-trash-alt"></i>
</button>
</td>
</tr>
<?php
$auditcontactlist->moveNext();
}
?>
</tbody>
</table> <br>
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&idcontacts=<?php echo ($audticontactdata->getColumnVal("idcontacts")); ?>', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');"><button type="button" class="btn btn-primary waves-effect waves-light">MODIFICA</button></a>
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&idcontacts=<?php echo ($auditcontactlist->getColumnVal("idcontacts")); ?>', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');"><button type="button" class="btn btn-primary waves-effect waves-light">MODIFICA</button></a>
<!-- Pulsante per aggiungere un nuovo contatto -->
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&add_new_contact=1', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');">
<button type="button" class="btn btn-success waves-effect waves-light">AGGIUNGI</button>
</a>
@ -776,7 +796,62 @@ $idprotectioncategoryJson = json_encode($idproteccategorylistRecord);
<!-- end page-wrapper -->
<script>
$(document).ready(function() {
// Quando si clicca sul pulsante di eliminazione
$('.delete-contact').on('click', function() {
var contactId = $(this).data('id');
var row = $(this).closest('tr'); // Memorizza la riga da rimuovere
// Utilizza SweetAlert per conferma
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
// Invia la richiesta AJAX per eliminare il contatto
$.ajax({
url: 'delete_contact.php', // Il file PHP che esegue l'eliminazione
type: 'POST',
data: {
idcontacts: contactId
},
success: function(response) {
if (response === 'success') {
// Rimuovi la riga dalla tabella
row.remove();
// Mostra messaggio di successo con SweetAlert
Swal.fire(
'Deleted!',
'The contact has been deleted.',
'success'
);
} else {
Swal.fire(
'Error!',
'Failed to delete the contact.',
'error'
);
}
},
error: function() {
Swal.fire(
'Error!',
'An error occurred while deleting the contact.',
'error'
);
}
});
}
});
});
});
</script>
<!-- jQuery -->
<!-- <script src="assets/js/jquery.min.js"></script> -->