ex15_SoaGatewayUpdateForm.php
<?php
/*
* This form incorporates ALL Adabas SOA Gateway access methods,
* list, get, add, update, delete
*
* and demonstrates how easily web applications can be implemented
* based on the Adabas SOA Gateway
*/
global $PHP_SELF;
$Persid = "";
$Fname = "";
$Lname = "";
$City = "";
$Addr[0] = "";
$Addr[1] = "";
$Addr[2] = "";
$Addr[3] = "";
$msg = "";
if (isset($_POST['submit'])) {
if ($_POST['submit'] != "Reset") {
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$Persid = $_POST["Persid"];
$City = $_POST["City"];
$Addr = $_POST["Addr"];
try {
$soapclient = new SoapClient(
"http://localhost:8022/adabas_EmployeesMini?WSDL");
} catch (SoapFault $soapfault) {
echo "<pre>";
print_r($soapfault);
echo "</pre>";
return;
}
}
$msg = "";
if ($_POST['submit'] == "Delete") {
try {
$Adabasresponse = $soapclient->delete(array('personnel_id' => $Persid));
} catch (SoapFault $soapfault) {
echo "<pre>";
print_r($soapfault);
echo "</pre>";
return;
}
$msg = $Adabasresponse->results;
}
if ($_POST['submit'] == "Get") {
try {
$Adabasresponse = $soapclient->get(array('personnel_id' => $Persid));
} catch (SoapFault $soapfault) {
echo "<pre>";
print_r($soapfault);
echo "</pre>";
return;
}
if (!isset($Adabasresponse->adabasEmployees->adabasEmployee)) {
$msg = "No Employee with personnel_id=".$Persid;
$Lname = "";
$Fname = "";
$City = "";
$Addr = array("", "", "", "");
} else {
$Employee = $Adabasresponse->adabasEmployees->adabasEmployee;
$Persid = $Employee->personnel_id;
$Lname = $Employee->name;
$Fname = $Employee->first_name;
$City = $Employee->city;
$Addr = $Employee->address_line;
}
}
if (($_POST['submit'] == "Add") || ($_POST['submit'] == "Update")) {
$adabasEmployee = array (
'personnel_id' => $Persid,
'first_name' => $Fname,
'name' => $Lname,
'city' => $City,
'address_line' => $Addr
);
$adabasEmployees = array($adabasEmployee);
if ($_POST['submit'] == "Add") {
try {
$Adabasresponse = $soapclient->add($adabasEmployees);
} catch (SoapFault $soapfault) {
echo "<pre>";
print_r($soapfault);
echo "</pre>";
}
} else {
try {
$Adabasresponse = $soapclient->update($adabasEmployees);
} catch (SoapFault $soapfault) {
echo "<pre>";
print_r($soapfault);
echo "</pre>";
}
}
}
} else {
}
?>
<html>
<head>
<title>Personnel Info</title>
</head>
<body>
<font face="courier">
<form method="post" action="<?php echo $PHP_SELF;?>">
Personnel Id: <input type="text" size="8" maxlength="8" name="Persid" value="<? echo $Persid; ?>"><br />
First Name..: <input type="text" size="20" maxlength="20" name="Fname" value="<? echo $Fname; ?>"><br />
Last Name...: <input type="text" size="20" maxlength="20" name="Lname" value="<? echo $Lname; ?>"><br />
City........: <input type="text" size="20" maxlength="20" name="City" value="<? echo $City; ?>"><br />
Address.....: <input type="text" size="20" maxlength="20" name="Addr[]" value="<? echo $Addr[0]; ?>"><br />
.....: <input type="text" size="20" maxlength="20" name="Addr[]" value="<? echo $Addr[1]; ?>"><br />
.....: <input type="text" size="20" maxlength="20" name="Addr[]" value="<? echo $Addr[2]; ?>"><br />
.....: <input type="text" size="20" maxlength="20" name="Addr[]" value="<? echo $Addr[3]; ?>"><br />
<br/>
<? echo $msg; ?><br><br>
<input type="submit" value="List" name="submit">
<input type="submit" value="Get" name="submit">
<input type="submit" value="Add" name="submit">
<input type="submit" value="Update" name="submit">
<input type="submit" value="Delete" name="submit">
<input type="submit" value="Reset" name="submit">
</form>
<?
if (isset($_POST['submit'])) {
if ($_POST['submit'] == 'List') {
echo "Selected: Personnel Id=''".$Persid."'', first_name=''".$Fname."'',Name=''".$Lname;
echo "'', City=''".$City."''<br/><br/>";
$listkey = array('personnel_id' => $Persid, 'first_name' => $Fname, 'name' => $Lname, 'city' => $City);
try {
$listresponse = $soapclient->list($listkey);
} catch (SoapFault $soapfault) {
echo "<pre>";
print_r($soapfault);
echo "</pre>";
return;
}
echo "<table border=1 cellpadding=5>";
echo "<tr><th>Personnel Id</th><th>Name</th><th>First Name</th><th>City</th><th width=200>Address Line</td>";
if ( isset($listresponse->adabasEmployees->adabasEmployee) )
{
$Employees = $listresponse->adabasEmployees->adabasEmployee;
if (!is_array($Employees))
$Employees = $listresponse->adabasEmployees;
foreach ($Employees as $Employee) {
echo "<tr><td>$Employee->personnel_id</td><td>$Employee->name</td><td>$Employee->first_name</td><td>$Employee->city</td><td>";
echo "<table>";
if (!is_array($Employee->address_line)) {
echo "<tr><td width=200>$Employee->address_line</td></tr>";
} else {
foreach ($Employee->address_line as $addr) {
echo "<tr><td width=200>$addr</td></tr>";
}
}
echo "</table>";
echo "</td></tr>";
}
}
}
}
?>
</body></html>