Segui

Tutorial PHP: come gestire i Rapportini di Lavoro per Commessa

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 Perfetto, 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

  • 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.

  • Inserire il titolo della pagina, il titolo e le impostazioni della form:
    <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">
    ....
    </form>
    </div>
    </body>
  • Aggiungere i campi relativi alla fase di login:
    • input type=”text” per User
    • input type=”password” per Password
    • input type=”text” per Company
    • input type=”submit” per richiedere la login
    ....
    <form method="post" action="index.php">
    <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
    ....
    ?>
    <p class="submit">
    <input type="submit" name="commit" value="Login">
    </p>
    </form>
    ....

 perfettows-test---Connessione-Desktop-remoto-5.png

Autenticazione e controllo validità
Per poter accedere ai metodi web che consentono all'utente di registrarsi in Perfetto, è 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:

<form method="post" action="index.php">
....
<?php
session_start();
$url = new SoapClient(
'http://localhost/Magonet/LoginManager/LoginManager.asmx?wsdl'
);
if(isset($_SESSION['authenticationToken'])
&&($url->IsValidToken(
array("authenticationToken"=>$_SESSION['authenticationToken'])
)->IsValidTokenResult== true))
{
header('Location: workingreportslist.php');
}
if((isset($_POST['login']))&&(isset($_POST['password']))
&&(isset($_POST['company'])))
{
$login=array("userName"=>$_POST['login'],"companyName"=>$_POST['company'],
"password"=>$_POST['password'],"askingProcess" =>'your code',
"overWriteLogin"=>false);
$result=$url->Login($login);
if($result->LoginResult==0)
{
$_SESSION['authenticationToken']=$result->authenticationToken;
header('Location: workingreportslist.php');
}
else
{
echo "<b><font size=\"5\">Login fallita, errore "
.$result-->LoginResult."</font></b>";
}
}
?>
....
</form>

Creazione pagina lista Rapportini

  • Selezionare "Nuovo file"
  • Inserire il nome del file "workingreportslist.php"
  • Aggiungere il titolo e le impostazioni della pagina
    <head>
    <meta charset="utf-8">
    <title>Lista Rapportini per Commessa</title>
    <style>
    body, html { width: 100%; height: 100%; margin: 0; }
    .head { width: 100%; height: 50%; }
    table {font-family: arial, sans-serif; border-collapse: collapse; width: 100%;}
    td { border: 1px solid #dddddd; text-align: center; background-color: #E9C89D;
    color: black; padding: 8px; }
    th { border: 1px solid #dddddd; text-align: center; background-color: #D85E00;
    color: white; padding: 8px; }
    .welcome { font-family: marmelad; width: 100%; height: 60px; }
    </style>
    </head>
  • Creare l'intestazione della pagina e il campo di ricerca
    <body>
    <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
      ....
    <div align="center" style="margin-top: 1%;">
    <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>
    <?php
    ....
    ?>
    </table>
    </div>
    </body>
  • Gestione dinamica della tabella
    <?php
    $url=new SoapClient('http://localhost/Magonet/TbServices/TbServices.asmx?WSDL');
    $path="<maxs:Rapportino
    tbNamespace=\"Document.ImpiantiNet.Rapportini.INRapportini.Rapportino\"
    xTechProfile=\"DefaultLight\"
    xmlns:maxs=\"http://www.microarea.it/Schema/2004/Smart/ImpiantiNet/
    Rapportini/Rapportino/Standard/DefaultLight.xsd\">";

    if(isset($_POST['delete']))
    {
    $filters = "<?xml version=\"1.0\"?>".$path."
    <maxs:Data>
    <maxs:RapportinoCommessa master=\"true\">
    <maxs:WorkingReportId >".$_POST['delrap']."</maxs:WorkingReportId>
    </maxs:RapportinoCommessa>
    </maxs:Data>
    </maxs:Rapportino>";
    $params= array(
    "authenticationToken" => $_SESSION['authenticationToken'],
    "data" => $filters,
    "applicationDate" => Date("Y-m-d"),
    "postingAction" => 3,
    "useApproximation" => false);

    $res=$url->SetData($params);

    $mod=$res->SetDataResult;

    if($mod==1)
    {
    echo "<div align=\"center\">
    <b>
    <font color=\"red\" size=\"6\">Rapportino cancellato!</font>
    </b>
    </div>";
    }else
    {
    echo "<div align=\"center\">
    <b>
    <font color=\"red\" size=\"6\">Rapportino non cancellato!
    </font>
    </b>
    </div>";
    }
    }
    ?>
    <div align="center" style="margin-top: 1%;">
    <table>
    ....
    <?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:Rapportino>";

    $params= array(
    "authenticationToken" => $_SESSION['authenticationToken'],
    "parameters" => $filters,
    "applicationDate" => Date("Y-m-d"),
    "loadAction" => 0,
    "resultType" => 0,
    "formatType" => 0,
    "useApproximation" => false);

    $res=$url->GetData($params);

    $ris=$res->GetDataResult->string;
    $ris = str_replace("maxs:","",$ris);

    if(is_array($ris))
    {
    foreach($ris as $prova)
    {
    $xml_res = simplexml_load_string($prova);
    echo "<tr>";
    echo '<form action="workingreportslist.php" method="post">';
    echo "<td><a href=\"modifyworkingreport.php?workingreportid="
    .$xml_res->Data->RapportinoCommessa->WorkingReportId.
    "\">"
    .$xml_res->Data->RapportinoCommessa->WorkingReportNo.
    "</a></td>";
    echo "<td>".date("d-m-Y",
    strtotime(
    $xml_res->Data->RapportinoCommessa->WorkingReportDate
    )).
    "</td>";
    echo "<td>".date("d-m-Y", strtotime(
    $xml_res->Data->RapportinoCommessa->PostingDate
    )).
    "</td>";
    echo "<td>".$xml_res->Data->RapportinoCommessa->Customer."</td>";
    echo "<td>".$xml_res->Data->RapportinoCommessa->Currency."</td>";
    echo "<td>".$xml_res->Data->RapportinoCommessa->WRReason."</td>";
    echo "<td>".$xml_res->Data->RapportinoCommessa->Job."</td>";
    echo "<td>".$xml_res->Data->RapportinoCommessa->ExternalReference."</td>";
    ?>
    <td>
    <input type="checkbox" id="invoicefollows" name="invoicefollows"
    value="true" disabled="disabled"
    <?php if ($xml_res->Data->RapportinoCommessa->InvoiceFollows == 'true')
    echo "checked='checked'"; ?> >
    </input>
    </td>
    <?php
    echo "<td><input type=\"hidden\" name=\"delrap\"
    value=\"".$xml_res->Data->RapportinoCommessa->WorkingReportId.
    "\"/><input type=\"submit\" name=\"delete\" value=\"Elimina\">
    </td>";
    echo "</form>";
    echo "</tr>";
    }
    }
    else
    {
    $xml_res = simplexml_load_string($ris);
    if(!empty($xml_res->Diagnostic))
    {
    echo "<div align=\"center\"><b><font color=\"red\" size=\"6\">"
    .$xml_res->Diagnostic->Warnings->Warning->Message.
    "</font></b>\"</div>";
    }
    else
    {
    echo "<tr>";
    echo '<form action="employeeslist.php" method="post">';
    echo "<td><a href=\"modifyemployee.php?employee="
    .$xml_res->Data->Employee->Employee."\">"
    .$xml_res->Data->Employee->Employee.
    "</a></td>";
    echo "<td>".$xml_res->Data->Employee->Name."</td>";
    echo "<td>".$xml_res->Data->Employee->Address."</td>";
    echo "<td>".$xml_res->Data->Employee->Qualification."</td>";
    echo "<td>".$xml_res->Data->Employee->ZipCode."</td>";
    echo "<td>".$xml_res->Data->Employee->City."</td>";
    echo "<td>".$xml_res->Data->Employee->County."</td>";
    echo "<td>".$xml_res->Data->Employee->Telephone1."</td>";
    echo "<td>".$xml_res->Data->Employee->Telephone2."</td>";
    echo "<td>".$xml_res->Data->Employee->email."</td>";
    echo "<td><input type=\"hidden\" name=\"deldip\" value=\""
    .$xml_res->Data->Employee->Employee.
    "\"/><input type=\"submit\" name=\"delete\" value=\"Elimina\"></td>";
    echo "</form>";
    echo "</tr>";
    }
    }
    ?>
    </table>
    </div>

perfettows-test---Connessione-Desktop-remoto-6.png
 

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>
    <?php
    ....
    ?>
    <div class="welcome" style="width: 95%;padding-left: 2%;">
    <p style="float: left"><b>
    <font color="#D85E00" size="3">Anagrafica Rapportino</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>
    <script>
    ....
  • Leggere i dati del Rapportino
      ....
    </script>
    <?php
    $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:Rapportino>";

    $params= array(
    "authenticationToken" => $_SESSION['authenticationToken'],
    "parameters" => $filters,
    "applicationDate" => Date("Y-m-d"),
    "loadAction" => 0,
    "resultType" => 0,
    "formatType" => 0,
    "useApproximation" => false);

    $res=$url->GetData($params);

    $ris=$res->GetDataResult->string;
    $ris = str_replace("maxs:","",$ris);
    $xml_res = simplexml_load_string($ris);

    if(!empty($xml_res->Diagnostic))
    {
    echo "<div align=\"center\"><b><font color=\"#D85E00\" size=\"6\">"
    .$xml_res->Diagnostic->Warnings->Warning->Message.
    "</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
    {
    ?>
    <div align="center">
    ....
    </div>
    <form action="modifyworkingreport.php" method="post">
    ....
  • Visualizzare i dati di testa del Rapportino
      <form action="modifyworkingreport.php" method="post">
    <?php echo "<input type=\"hidden\" name=\"workingreportid\" value=\""
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->WorkingReportNo))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->Customer))
    echo "value=\""
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->Job))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->ExternalReference))
    echo "value=\""
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->WorkingReportDate
    ))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->WorkingReportDate
    ?> />
    </td>
    <td align="left">
    <input size="7" name="postingdate" type="date" readonly
    <?php
    if(!empty($xml_res->Data->RapportinoCommessa->PostingDate))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->WRReason))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->WRReason
    ?> required/>
    </td>
    <td align="left">
    <input style="margin-left: -97%;" type="checkbox"
    id="invoicefollows" name="invoicefollows" value="true"
    <?php
    if($xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->Currency))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->Currency;
    ?> />
    </td>
    <td align="left">
    <input style="margin-left: -6%;" size="5"
    name="fixingdate" type="date"
    <?php
    if(!empty($xml_res->Data->RapportinoCommessa->FixingDate))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->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->RapportinoCommessa->Fixing))
    echo "value="
    .$xml_res->Data->RapportinoCommessa->Fixing
    ?> readonly/>
    </td>
    </tr>
    </table>
    </tr>
    </table>
    </table>
    </div>
    </div>
    ....
    </form>
  • 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
    foreach ($xml_res->Data->Righe->RigheRow 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))
    echo "value=\"".$riga->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>
    <?php
    }
    ?>
    </body>
  • Inviare i dati del Rapportino modificato
    <body>
    <?php
    if(isset($_POST['cancel'])){
    header('Location: workingreportslist.php');
    }
    session_start();
    $url = new SoapClient('http://localhost/Magonet/LoginManager/LoginManager.asmx?wsdl');
    if(isset($_SESSION['authenticationToken'])
    &&($url->IsValidToken(array("authenticationToken"=>
    $_SESSION['authenticationToken']))->IsValidTokenResult== true))
    {}
    else
    {
    header('Location: logout.php');
    }
    $mod=0;
    $url = new SoapClient('http://localhost/Magonet/TbServices/TbServices.asmx?WSDL');
    $path="<maxs:Rapportino
    tbNamespace=\"Document.ImpiantiNet.Rapportini.INRapportini.Rapportino\"
    xTechProfile=\"DefaultLight\"
    xmlns:maxs=\"http://www.microarea.it/Schema/2004/Smart/ImpiantiNet/
    Rapportini/Rapportino/Standard/DefaultLight.xsd\">";
    if(isset($_POST['save']))
    {
    if(!empty($_POST['invoicefollows']))
    {
    $invfol="true";
    }
    else
    {
    $invfol="false";
    }
    $filters = "<?xml version=\"1.0\"?>".$path."
    <maxs:Data>
    <maxs:RapportinoCommessa 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:RapportinoCommessa>
    <maxs:Righe>";

    for ($i=0; $i<count($_POST['rowemployee']); $i++)
    {
    $filters.="<maxs:RigheRow>
    <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:RigheRow>";
    }
    $filters.="</maxs:Righe></maxs:Data></maxs:Rapportino>";
    $params= array(
    "authenticationToken" => $_SESSION['authenticationToken'],
    "data" => $filters,
    "applicationDate" => Date("Y-m-d"),
    "postingAction" => 2,
    "useApproximation" => false);

    $res=$url->SetData($params);

    $mod=$res->SetDataResult;

    if($mod==1)
    {
    header('Location: workingreportslist.php');
    }
    else
    {
    $_GET['workingreportid']=$_POST['workingreportid'];
    }
    }
    ?>
    ....
    <div align="center">
    <?php
    if($mod!=1){
    if(isset($_POST['save'])){
    echo "<b><font color=\"#D85E00\" size=\"6\">Modifiche non salvate!</font></b>";
    }
    }
    ?>
    </div>

 perfettows-test---Connessione-Desktop-remoto-12.png

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();
$url = new SoapClient('http://localhost/Magonet/LoginManager/LoginManager.asmx?wsdl');
$logout=array("authenticationToken"=>$_SESSION['authenticationToken']);
$url->LogOff($logout);
$_SESSION = array();
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000, $params["path"],
$params["domain"], $params["secure"], $params["httponly"]);
session_destroy();
header('Location: index.php');
?>

 

Altre domande? Invia una richiesta

Commenti

Powered by Zendesk