Sommario
Nel presente articolo sono descritti i passi da seguire per poter creare un esempio di un'applicazione scritta in linguaggio PHP che consente di effettuare l'autenticazione al prodotto Perfetto4, la ricerca, la modifica e la cancellazione del documento Rapportino per Commessa, utilizzando la tecnologia Magic Link.
Per facilitare la lettura dell'articolo di seguito un indice delle sezioni dell'articolo:
- Creazione del progetto
- Creazione della pagina di Login
- Autenticazione e controllo validità
- Creazione pagina "Lista Rapportini"
- Creazione pagina "Modifica Rapportino"
- Disconnessione
Creazione del progetto
- aprire "Dreamweaver", in questo esempio è stato utilizzato Dreamweaver CC;
- selezionare "Nuovo sito...";
- inserire il nome del sito;
- inserire il path della cartella locale del sito;
- selezionare "Nuovo file";
- inserire il nome del file "index.php".
Creazione della pagina di Login
Nel seguente sezione è mostrato come creare l'interfaccia grafica della pagina di login.
Nel seguente snippet di codice sono presenti le dichiarazioni in HTML dei componenti dell'interfaccia grafica:
<head>
<meta charset="utf-8">
<title>Sito aziendale</title>
<style>
div.login {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div align="center">
<b><font color="#000000" size="100">Connessione al database aziendale</font></b>
</div>
<div class="login" align="center">
<h1><font color="#000000">Login</font></h1>
<form method="post" action="index.php">
<p>
<select name="Protocol" style="padding: 1px;">
<option value="http" <?php echo ($protocol == 'http') ? 'selected' : ''; ?>>http://</option>
<option value="https" <?php echo ($protocol == 'https') ? 'selected' : ''; ?>>https://</option>
</select>
<input type="text" name="Server" id="login" value="<?php echo htmlspecialchars($server); ?>" placeholder="localhost" required>
:
<input type="text" name="Port" id="port" value="<?php echo htmlspecialchars($port); ?>" placeholder="80" style="width: 50px;" required>
/
<input type="text" name="Instance" id="login" value="<?php echo htmlspecialchars($instance); ?>" placeholder="Mago4" required></p>
<br>
<p><input type="text" name="login" id="login" value="" placeholder="Username" required></p>
<p><input type="password" name="password" value="" placeholder="Password" required></p>
<p><input type="text" id="company" name="company" value="" placeholder="Azienda" required></p>
<?php if (!empty($loginResultMsg)) echo $loginResultMsg; ?>
<p class="submit"><input type="submit" name="commit" value="Login"></p>
</form>
</div>
</body>Autenticazione e controllo validità
Per poter accedere ai metodi web che consentono all'utente di registrarsi in Perfetto4, è necessario istanziare un oggetto di tipo SoapClient che faccia riferimento al LoginManager.
In questo esempio per effettuare l'autenticazione al sistema è stato utilizzato il metodo web Login del LoginManager.
Nel seguente codice è mostrato come recuperare i valori dei campi relativi alla login, come passare tali valori al metodo Login per ottenere il codice di autenticazione, come controllare la validità del codice di autenticazione tramite il metodo IsValidToken e come chiamare la pagina che mostra la lista dei Rapportini:
<?php
session_start();
$protocol = isset($_POST['Protocol']) ? $_POST['Protocol'] : 'http';
$server = isset($_POST['Server']) ? $_POST['Server'] : 'localhost';
$port = isset($_POST['Port']) ? $_POST['Port'] : '80';
$instance = isset($_POST['Instance']) ? $_POST['Instance'] : 'Mago4';
$loginResultMsg = "";
$wsdl_url = "{$protocol}://{$server}:{$port}/{$instance}/LoginManager/LoginManager.asmx?wsdl";
try {
$url = new SoapClient($wsdl_url);
if (isset($_SESSION['authenticationToken']) && ($url->IsValidToken(array("authenticationToken" => $_SESSION['authenticationToken']))->IsValidTokenResult == true)) {
header('Location: workingreportslist.php');
exit;
}
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['company'])) {
$loginArgs = array(
"userName" => $_POST['login'],
"companyName" => $_POST['company'],
"password" => $_POST['password'],
"askingProcess" => 'thirdparth',
"overWriteLogin" => false,
"onlycheck" => false
);
$result = $url->Login($loginArgs);
if ($result->LoginResult == 0) {
$_SESSION['authenticationToken'] = $result->authenticationToken;
$_SESSION['base_url'] = "{$protocol}://{$server}:{$port}/{$instance}";
header('Location: workingreportslist.php');
exit;
} else {
$loginResultMsg = "<b><font size=\"5\">Login fallita, errore " . htmlspecialchars($result->LoginResult) . "</font></b>";
}
}
} catch (SoapFault $e) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$loginResultMsg = "<b><font size=\"5\">Errore di connessione al server.</font></b>";
}
}
?>Creazione pagina "Lista Rapportini"
- selezionare "Nuovo file";
- inserire il nome del file "workingreportslist.php";
-
aggiungere il titolo e le impostazioni della pagina;
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Lista Rapportini per Commessa</title> <!-- Stili CSS (vedi sorgente originale) --> </head> -
creare l'intestazione della pagina e il campo di ricerca;
<div class="welcome"> <p style="float: left"><b><font color="#D85E00" size="3">Lista Rapportini per Commessa</font></b></p> <p style="float: right"><b><font size="3"><a style="text-decoration: underline;" href="logout.php">Logout</a></font></b></p> </div> <div align="center"> <form method="post" action="workingreportslist.php"> <input type="search" name="numrap" value="" placeholder="Numero Rapportino"/> <input type="submit" value="Cerca Rapportino" /> </form> </div> - creare una tabella;
-
inserire la riga di intestazione della tabella;
<table> <tr> <th>Numero Rapportino</th> <th>Del</th> <th>Registrato</th> <th>Cliente</th> <th>Divisa</th> <th>Causale</th> <th>Commessa</th> <th>Ns. Riferimento</th> <th>Fattura</th> <th></th> </tr> -
gestione dinamica della tabella;
<?php $filters = "<?xml version=\"1.0\"?>".$path." <maxs:Parameters> <maxs:DefaultDialog title=\"Ricerca campi\"> <maxs:DefaultGroup title=\"Gruppo di ricerca\">"; if((isset($_POST['numrap']))&&(!empty($_POST['numrap']))){ $filters.="<maxs:WorkingReportNo type=\"String\">".$_POST['numrap']."</maxs:WorkingReportNo>"; } $filters.="</maxs:DefaultGroup> </maxs:DefaultDialog> </maxs:Parameters> </maxs:JobWorkingReports>"; $params= array( "authenticationToken" => $_SESSION['authenticationToken'], "parameters" => $filters, "applicationDate" => Date("Y-m-d"), "loadAction" => 0, "resultType" => 0, "formatType" => 0, "useApproximation" => false); $res=$tb_url->GetData($params); $ris=$res->GetDataResult->string; $ris = str_replace("maxs:","",$ris); // ... logica foreach per mostrare i dati con simplexml_load_string() ... ?>
Creazione pagina "Modifica Rapportino"
- selezionare "Nuovo file";
- inserire il nome del file "modifyworkingreport.php";
- aggiungere il titolo e le impostazioni della pagina;
<head> <meta charset="utf-8"> <title>Modifica Rapportino</title> <style> body, html { width: 100%; height: 100%; margin: 0; } .head { width: 100%; height: 50%; } label { display: block; color: #331600; } textarea { height: 54px; width: 166px; } input { outline: 0; border-width: 0 0 2px 0; border-color: grey; } input:focus { border-color: #D85E00; } .but { border-color: transparent; } .but:focus { border-color: transparent; } table { font-family: arial; border-collapse: collapse; width: 100%; } td { border: 1px; padding: 6px; } th { border: 1px; padding: 6px; } .welcome { width: 100%; height: 60px; } .left { float: left; text-align: right; margin: 2px 10px; display: inline; margin-left: 26%; } .right { float: left; text-align: left; margin: 2px 10px; display: inline; margin-left: 21%; } </style> </head>-
creare l'intestazione della pagina;
<body> <div class="welcome" style="width: 95%;padding-left: 2%;"> <p style="float: left"><b><font color="#D85E00" size="3">Anagrafica Rapportino</font></b> <p style="float: right"><b><font size="3"><a style="text-decoration: underline;" href="logout.php">Logout</a></font></b></p> </div> -
leggere i dati del Rapportino;
<?php if(isset($_GET['workingreportid']) && !empty($_GET['workingreportid'])) { $filters = "<?xml version=\"1.0\"?>".$path." <maxs:Parameters> <maxs:DefaultDialog title=\"Ricerca campi\"> <maxs:DefaultGroup title=\"Gruppo di ricerca\"> <maxs:WorkingReportId>".$_GET['workingreportid']."</maxs:WorkingReportId> </maxs:DefaultGroup> </maxs:DefaultDialog> </maxs:Parameters> </maxs:JobWorkingReports>"; $params= array( "authenticationToken" => $_SESSION['authenticationToken'], "parameters" => $filters, "applicationDate" => Date("Y-m-d"), "loadAction" => 0, "resultType" => 0, "formatType" => 0, "useApproximation" => false); $res=$tb_url->GetData($params); $ris=$res->GetDataResult->string; $ris = str_replace("maxs:","",$ris); $xml_res = simplexml_load_string($ris); if(isset($xml_res->Diagnostic->Errors->Error->Message) || isset($xml_res->Diagnostic->Warnings->Warning->Message)){ $error_msg = isset($xml_res->Diagnostic->Errors->Error->Message) ? $xml_res->Diagnostic->Errors->Error->Message : $xml_res->Diagnostic->Warnings->Warning->Message; echo "<div align=\"center\"><b><font color=\"#D85E00\" size=\"6\">".$error_msg."</font></b></div>"; echo "<div style=\"width: 100%; height: 100%; float: left; border-collapse: collapse\" align=\"center\"> <p class=\"submit\"> <form action=\"workingreportslist.php\" method=\"post\"> <input class=\"but\" type=\"submit\" name=\"cancel\" value=\"Torna alla lista\" style=\"height:50px; width:200px\"> </form> </p> </div>"; } else { ?> -
visualizzare i dati di testa del Rapportino;
<form action="modifyworkingreport.php" method="post"> <?php echo "<input type=\"hidden\" name=\"workingreportid\" value=\"".$xml_res->Data->WorkingReport->WorkingReportId."\"/>"; ?> <div class="head"> <div class="left"> <table> <tr><th align="left">Numero Rapportino</th></tr> <tr> <td align="left"><input name="workingreportno" type="text" maxlength="10" readonly <?php if(!empty($xml_res->Data->WorkingReport->WorkingReportNo)) echo "value='".$xml_res->Data->WorkingReport->WorkingReportNo."'"; ?> /></td> </tr> <tr><th align="left">Cliente</th></tr> <tr> <td align="left"><input name="customer" type="text" maxlength="12" <?php if(!empty($xml_res->Data->WorkingReport->Customer)) echo "value=\"".$xml_res->Data->WorkingReport->Customer."\"" ?> /></td> </tr> <tr><th align="left">Commessa</th></tr> <tr> <td align="left"><input id="headjob" name="job" type="text" maxlength="10" <?php if(!empty($xml_res->Data->WorkingReport->Job)) echo "value='".$xml_res->Data->WorkingReport->Job."'"; ?> /></td> </tr> <tr><th align="left">Ns. riferimento</th></tr> <tr> <td align="left"><input name="externalreference" type="text" maxlength="21" <?php if(!empty($xml_res->Data->WorkingReport->ExternalReference)) echo "value=\"".$xml_res->Data->WorkingReport->ExternalReference."\"" ?> /></td> </tr> </table> </div> <div class="right" style="margin-right: -10%; margin-top: -0.15%;"> <table> <tr> <table> <tr><th align="left">Del</th><th align="left"><font style="margin-left: 6%">Registrato</font></th></tr> </table> </tr> <tr> <table> <tr> <td width="33%" align="left"><input size="7" name="workingreportdate" type="date" readonly <?php if(!empty($xml_res->Data->WorkingReport->WorkingReportDate)) echo "value=\"".$xml_res->Data->WorkingReport->WorkingReportDate."\"" ?> /></td> <td align="left"><input size="7" name="postingdate" type="date" readonly <?php if(!empty($xml_res->Data->WorkingReport->PostingDate)) echo "value=\"".$xml_res->Data->WorkingReport->PostingDate."\"" ?> /></td> </tr> </table> </tr> <tr> <table> <tr><th align="left">Causale</th></tr> </tr> <tr> <td align="left"><input size="16" name="wrreason" type="text" maxlength="8" <?php if(!empty($xml_res->Data->WorkingReport->WRReason)) echo "value=\"".$xml_res->Data->WorkingReport->WRReason."\"" ?> required/></td> <td align="left"><input style="margin-left: -97%;" type="checkbox" id="invoicefollows" name="invoicefollows" value="true" <?php if ($xml_res->Data->WorkingReport->InvoiceFollows == 'true') echo "checked='checked'"; ?> ><b>Fattura</b></input></td> </tr> </table> <tr> <table> <th align="left" width="37%">Divisa</th><th align="left"><font style="margin-left: -6%;">Data fixing</font></th> </tr> <tr> <td align="left"><input name="currency" size="16" type="text" maxlength="8" <?php if(!empty($xml_res->Data->WorkingReport->Currency)) echo "value=\"".$xml_res->Data->WorkingReport->Currency."\""; ?> /></td> <td align="left"><input style="margin-left: -6%;" size="5" name="fixingdate" type="date" <?php if(!empty($xml_res->Data->WorkingReport->FixingDate)) echo "value=\"".$xml_res->Data->WorkingReport->FixingDate."\"" ?> readonly/></td> </tr> <tr> <table> <tr><th align="left">Valore fixing</th></tr> </table> </tr> <tr> <table> <tr> <td align="left"><input style="width: 140px;" name="fixing" type="number" <?php if(!empty($xml_res->Data->WorkingReport->Fixing)) echo "value=\"".$xml_res->Data->WorkingReport->Fixing."\"" ?> readonly/></td> </tr> </table> </tr> </table> </table> </div> </div> -
creare script per la gestione dell'aggiunta e della cancellazione delle righe;
<script> function addRow() { var table = document.getElementById("wrrows"); var rowCount = table.rows.length; var row = table.insertRow(rowCount); row.insertCell(0).innerHTML= '<input class="but" type="button" value = "Cancella riga" onClick="Javacsript:deleteRow(this)">'; row.insertCell(1).innerHTML= '<input size="8" name="rowjob[]" type="text" maxlength="10" value="'+document.getElementById("headjob").value+'"/>'; var cell = row.insertCell(2); cell.align='center'; cell.innerHTML= '<input type="hidden" name="rowisonjobeconomicanalysis[]" value="1"><input type="checkbox" checked onclick="this.previousSibling.value=1-this.previousSibling.value">'; row.insertCell(3).innerHTML= '<input size="8" name="rowemployee[]" type="text" maxlength="10" required/>'; row.insertCell(4).innerHTML= '<input name="rowname[]" type="text" maxlength="64" value=" "/>'; row.insertCell(5).innerHTML= '<input size="8" name="rowqualification[]" type="text" maxlength="10" value=" "/>'; row.insertCell(6).innerHTML= '<input name="rowordinaryhours[]" type="number" value="0"/>'; row.insertCell(7).innerHTML= '<input name="rowovertimehours[]" type="number" value="0"/>'; row.insertCell(8).innerHTML= '<input name="rowtravelhours[]" type="number" value="0"/>'; row.insertCell(9).innerHTML= '<input name="rowvacationleavehours[]" type="number" value="0"/>'; row.insertCell(10).innerHTML= '<input name="rowsickleavehours[]" type="number" value="0"/>'; row.insertCell(11).innerHTML= '<input name="rowcustomhours1[]" type="number" value="0"/>'; row.insertCell(12).innerHTML= '<input name="rowcustomhours2[]" type="number" value="0"/>'; row.insertCell(13).innerHTML= '<input name="rowcustomhours3[]" type="number" value="0"/>'; row.insertCell(14).innerHTML= '<input name="rowcustomhours4[]" type="number" value="0"/>'; } function deleteRow(obj) { var index = obj.parentNode.parentNode.rowIndex; var table = document.getElementById("wrrows"); table.deleteRow(index); } </script> -
aggiungere la gestione delle righe del Rapportino;
<div style="clear: both;width: inherit;height: auto;position: static;padding: 0px 10px 5px 10px;white-space: nowrap;"> <table> <tr style="height: 28px"> <th align="center"><input class="but" type="button" id="addrow" value="Aggiungi riga" onclick="addRow()" /></th> </tr> </table> </div> <div style="clear: both;width: inherit;height: 300px;position: static;padding: 0px 10px 5px 10px;overflow-x: auto;white-space: nowrap;overflow-y: scroll;"> <table id="wrrows"> <tr> <th></th> <th align="left">Commessa</th> <th align="left">In Cons.</th> <th align="left">Dipendente</th> <th align="left">Nome</th> <th align="left">Qualifica</th> <th align="left">Ordinario</th> <th align="left">Straordinario</th> <th align="left">Trasferta</th> <th align="left">Ferie</th> <th align="left">Malattia</th> <th align="left">Orario 1</th> <th align="left">Orario 2</th> <th align="left">Orario 3</th> <th align="left">Orario 4</th> </tr> <?php if(isset($xml_res->Data->Details->DetailsRow)) { foreach ($xml_res->Data->Details->DetailsRow as $riga){ ?><tr> <td> <input class="but" type="button" value = "Cancella riga" onClick="Javacsript:deleteRow(this)" /> </td> <td align="left"> <input size="8" name="rowjob[]" type="text" maxlength="10" <?php if(!empty($riga->Job)) echo "value=\"".$riga->Job."\"" ?> /> </td> <td align="center"> <input type="hidden" name="rowisonjobeconomicanalysis[]" <?php if($riga->IsOnJobEconomicAnalysis == 'true') echo "value=\"1\""; else echo "value=\"0\""; ?>/><input type="checkbox" <?php if($riga->IsOnJobEconomicAnalysis == 'true') echo "checked"; ?> onclick="this.previousSibling.value=1-this.previousSibling.value"/> </td> <td align="left"> <input size="8" name="rowemployee[]" type="text" maxlength="10" <?php if(!empty($riga->Employee->Employees->Employee)) echo "value=\"".$riga->Employee->Employees->Employee."\"" ?> required/> </td> <td align="left"> <input name="rowname[]" type="text" maxlength="64" <?php if(!empty($riga->Name)) echo "value=\"".$riga->Name."\"" ?> /> </td> <td align="left"> <input size="8" name="rowqualification[]" type="text" maxlength="10" <?php if(!empty($riga->Qualification)) echo "value=\"".$riga->Qualification."\"" ?> /> </td> <td align="left"> <input name="rowordinaryhours[]" type="number" <?php if(!empty($riga->OrdinaryHours)) echo "value=\"".$riga->OrdinaryHours."\"" ?> /> </td> <td align="left"> <input name="rowovertimehours[]" type="number" <?php if(!empty($riga->OvertimeHours)) echo "value=\"".$riga->OvertimeHours."\"" ?> /></td> <td align="left"> <input name="rowtravelhours[]" type="number" <?php if(!empty($riga->TravelHours)) echo "value=\"".$riga->TravelHours."\"" ?> /> </td> <td align="left"> <input name="rowvacationleavehours[]" type="number" <?php if(!empty($riga->VacationLeaveHours)) echo "value=\"".$riga->VacationLeaveHours."\"" ?> /> </td> <td align="left"> <input name="rowsickleavehours[]" type="number" <?php if(!empty($riga->SickLeaveHours)) echo "value=\"".$riga->SickLeaveHours."\"" ?> /> </td> <td align="left"> <input name="rowcustomhours1[]" type="number" <?php if(!empty($riga->CustomHours1)) echo "value=\"".$riga->CustomHours1."\"" ?> /> </td> <td align="left"> <input name="rowcustomhours2[]" type="number" <?php if(!empty($riga->CustomHours2)) echo "value=\"".$riga->CustomHours2."\"" ?> /> </td> <td align="left"> <input name="rowcustomhours3[]" type="number" <?php if(!empty($riga->CustomHours3)) echo "value=\"".$riga->CustomHours3."\"" ?> /> </td> <td align="left"> <input name="rowcustomhours4[]" type="number" <?php if(!empty($riga->CustomHours4)) echo "value=\"".$riga->CustomHours4."\"" ?> /> </td> </tr> <?php } } ?> </table> </div> <div style="width: 100%; height: 100%; float: left; border-collapse: collapse" align="center"> <p class="submit"> <input class="but" type="submit" name="save" value="Salva" style="height:50px; width:200px"> <input class="but" type="submit" name="cancel" value="Torna alla lista" style="height:50px; width:200px" formnovalidate> </p> </div> </form> -
inviare i dati del Rapportino modificato;
<?php session_start(); if(isset($_POST['cancel'])){ header('Location: workingreportslist.php'); exit; } if (!isset($_SESSION['base_url']) || !isset($_SESSION['authenticationToken'])) { header('Location: logout.php'); exit; } $base_url = $_SESSION['base_url']; try { $url = new SoapClient($base_url . '/LoginManager/LoginManager.asmx?wsdl'); if($url->IsValidToken(array("authenticationToken"=>$_SESSION['authenticationToken']))->IsValidTokenResult == false){ header('Location: logout.php'); exit; } } catch (SoapFault $e) { header('Location: logout.php'); exit; } $mod = 0; $tb_url = new SoapClient($base_url . '/TbServices/TbServices.asmx?WSDL'); $path="<maxs:JobWorkingReports tbNamespace=\"Document.Perfetto.WorkingReports.Documents.JobWorkingReports\" xTechProfile=\"Default\" xmlns:maxs=\"http://www.microarea.it/Schema/2004/Smart/Perfetto/WorkingReports/JobWorkingReports/Standard/Default.xsd\">"; if(isset($_POST['save'])){ if(!empty($_POST['invoicefollows'])){ $invfol="true"; }else{ $invfol="false"; } $filters = "<?xml version=\"1.0\"?>".$path." <maxs:Data> <maxs:WorkingReport master=\"true\"> <maxs:WorkingReportId>".$_POST['workingreportid']."</maxs:WorkingReportId> <maxs:WorkingReportNo>".$_POST['workingreportno']."</maxs:WorkingReportNo> <maxs:WorkingReportDate>".$_POST['workingreportdate']."</maxs:WorkingReportDate> <maxs:PostingDate>".$_POST['postingdate']."</maxs:PostingDate> <maxs:Customer>".$_POST['customer']."</maxs:Customer> <maxs:InvoiceFollows>".$invfol."</maxs:InvoiceFollows> <maxs:WRReason>".$_POST['wrreason']."</maxs:WRReason> <maxs:Job>".$_POST['job']."</maxs:Job> <maxs:Currency>".$_POST['currency']."</maxs:Currency> <maxs:ExternalReference>".$_POST['externalreference']."</maxs:ExternalReference> </maxs:WorkingReport> <maxs:Details>"; if (isset($_POST['rowemployee']) && is_array($_POST['rowemployee'])) { for ($i=0; $i<count($_POST['rowemployee']); $i++){ $filters.="<maxs:DetailsRow> <maxs:WorkingReportId>".$_POST['workingreportid']."</maxs:WorkingReportId> <maxs:Line>".intval($i+1)."</maxs:Line> <maxs:Employee>".$_POST['rowemployee'][$i]."</maxs:Employee>"; if(($_POST['rowname'][$i]==" ")||(empty($_POST['rowname'][$i]))){} else { $filters.="<maxs:Name>".$_POST['rowname'][$i]."</maxs:Name> <maxs:Qualification>".$_POST['rowqualification'][$i]."</maxs:Qualification>"; } $filters.="<maxs:OrdinaryHours>".$_POST['rowordinaryhours'][$i]."</maxs:OrdinaryHours> <maxs:OvertimeHours>".$_POST['rowovertimehours'][$i]."</maxs:OvertimeHours> <maxs:TravelHours>".$_POST['rowtravelhours'][$i]."</maxs:TravelHours> <maxs:VacationLeaveHours>".$_POST['rowvacationleavehours'][$i]."</maxs:VacationLeaveHours> <maxs:SickLeaveHours>".$_POST['rowsickleavehours'][$i]."</maxs:SickLeaveHours> <maxs:Job>".$_POST['rowjob'][$i]."</maxs:Job> <maxs:CustomHours1>".$_POST['rowcustomhours1'][$i]."</maxs:CustomHours1> <maxs:CustomHours2>".$_POST['rowcustomhours2'][$i]."</maxs:CustomHours2> <maxs:CustomHours3>".$_POST['rowcustomhours3'][$i]."</maxs:CustomHours3> <maxs:CustomHours4>".$_POST['rowcustomhours4'][$i]."</maxs:CustomHours4> <maxs:IsOnJobEconomicAnalysis>".$_POST['rowisonjobeconomicanalysis'][$i]."</maxs:IsOnJobEconomicAnalysis> </maxs:DetailsRow>"; } } $filters.="</maxs:Details> </maxs:Data> </maxs:JobWorkingReports>"; $params= array( "authenticationToken" => $_SESSION['authenticationToken'], "data" => $filters, "applicationDate" => Date("Y-m-d"), "postingAction" => 2, "useApproximation" => false); $res=$tb_url->SetData($params); $mod=$res->SetDataResult; if($mod==1){ header('Location: workingreportslist.php'); exit; } else { $_GET['workingreportid'] = $_POST['workingreportid']; } } ?>
Disconnessione
Per disconnettere l'utente dal sistema è necessario cliccare sul link "Logout" in alto a destra che invoca il metodo LogOff del LoginManager.
Di seguito il codice per eseguire la disconnessione:
<?php
session_start();
if (isset($_SESSION['base_url']) && isset($_SESSION['authenticationToken'])) {
try {
$wsdl_url = $_SESSION['base_url'] . "/LoginManager/LoginManager.asmx?wsdl";
$url = new SoapClient($wsdl_url);
$logoutArgs = array("authenticationToken" => $_SESSION['authenticationToken']);
$url->LogOff($logoutArgs);
} catch (Exception $e) {
}
}
$_SESSION = array();
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();
header('Location: index.php');
exit;
?>
Commenti