S
snuffi01 author
Hi,
Issue: I'm using Click actions on listpage and on click the webpage displays: Server error occurred. See details And where the details is empty (nothing there).
Cant really track down what is causing this. My code for the click action (server tab):
global $conn,$control_registration_id;
$result["static_id"] = $params["static_id"]; // When record with static_id =1 exist we now that we havent pushed the record to web yet, lets add it and create additional records so we can delete and update the info on web when we need//
if($params["static_id"] == 1){
require_once ("resources/api_post.php");
/////////////
$sql = "SELECT
driftinfo_problem.active,
driftinfo_problem.id,
driftinfo_problem.`date`,
driftinfo_problem.omrade,
driftinfo_problem.estimate_finished_date,
driftinfo_problem.`time`,
driftinfo_problem.`switch`,
driftinfo_problem.`operator`,
DATE_FORMAT(`estimate_finished_time`, '%H:%i') AS estimate_finished_time,
driftinfo_problem_manus_per_language.heading,
driftinfo_problem_manus_per_language.ingress,
driftinfo_problem_manus_per_language.text,
driftinfo_problem_manus_per_language.next_info_text,
driftinfo_problem_manus_per_language.next_info_header,
driftinfo_problem_manus_per_language.next_info_button_text,
driftinfo_problem_manus_per_language.`language`
FROM driftinfo_problem
INNER JOIN driftinfo_problem_manus_per_language ON driftinfo_problem.id = driftinfo_problem_manus_per_language.driftinfo_problem_id
WHERE (driftinfo_problem.active = 'Yes') AND driftinfo_problem_manus_per_language.`language` = 'SV'
";
$rs = db_query($sql);
$data = db_fetch_array($rs); $valueOmrade = $data["omrade"];
$valueEstimateDate = $data["estimate_finished_date"];
$valueEstimateTime = $data["estimate_finished_time"];
$valueHeading = $data["heading"];
$valueIngress = $data["ingress"];
$valueText = $data["text"];
$valuenext_info_text = $data["next_info_text"];
$valuenext_info_header = $data["next_info_header"];
$valuenext_info_button_text = $data["next_info_button_text"];
$valueProblemId = $data["id"];
$valueSwitch = $data["switch"];
$valueOperator = $data["operator"];
if ($valueSwitch == 1){
$problemType = 'switch';
}
else {
$problemType = 'operator';
}
//USE api_post.php to send to web
$data[heading] = $valueOmrade;
//$data[body] = join(" ", array($valueIngress, $valueText, 'Vi uppskattar att nuvarande driftstörning är åtgärdad vid:', $valueEstimateDate, $valueEstimateTime));
$data[body] = join(" ", array('<strong>', $valueIngress, '</strong><BR><BR>', $valueText, '<BR><BR>', '<strong>Beräknad åtgärdstid:</strong>', $valueEstimateDate, $valueEstimateTime));
$data[type] = $problemType;
$data[status] = '0';
$data[problemId] = $valueProblemId; $api = new sa_api();
$json = $api->post('', $data, $valueProblemId);
//varken dollarReturn eller dollarJson innehåller ngt//
//$pageObject->setProxyValue("InfoId", $return);
// Create the records for last step in guide//
$data4 = array(); $data4["driftinfo_problem_id"] = $valueProblemId;
$data4["static_id"] = 3;
$data4["text"] = 'UPPDATERA DRIFTINFO PÃ… WEBPAGE'; DB::Insert("driftinfo_problem_last_step_actions", $data4 );
$data4 = array(); $data4["driftinfo_problem_id"] = $valueProblemId;
$data4["static_id"] = 4;
$data4["text"] = 'TA BORT DRIFTINFO PÃ… SOLUNO.SE'; DB::Insert("driftinfo_problem_last_step_actions", $data4 );
exit();
}
//If static_id = 3 then user wants to update the info on web if static_id = 4 then user wants to delete info on web//
//We have saved problem_id in session ($_SESSION["problem_id_working"]=$values["id"]<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=25629&image=1&table=forumtopics' class='bbc_emoticon' alt=';)' /> befor edisplaying this edit page as we need to use that when serching for subcase// if($params["static_id"] == 3){
require_once ("resources/api_update.php");
/////////////
$sql = "SELECT
driftinfo_problem.active,
driftinfo_problem.id,
driftinfo_problem.`date`,
driftinfo_problem.omrade,
driftinfo_problem.estimate_finished_date,
driftinfo_problem.`time`,
driftinfo_problem.`web_id`,
DATE_FORMAT(`estimate_finished_time`, '%H:%i') AS estimate_finished_time,
driftinfo_problem_manus_per_language.heading,
driftinfo_problem_manus_per_language.ingress,
driftinfo_problem_manus_per_language.text,
driftinfo_problem_manus_per_language.next_info_text,
driftinfo_problem_manus_per_language.next_info_header,
driftinfo_problem_manus_per_language.next_info_button_text,
driftinfo_problem_manus_per_language.`language`
FROM driftinfo_problem
INNER JOIN driftinfo_problem_manus_per_language ON driftinfo_problem.id = driftinfo_problem_manus_per_language.driftinfo_problem_id
WHERE (driftinfo_problem.active = 'Yes') AND driftinfo_problem_manus_per_language.`language` = 'SV'
";
$rs = db_query($sql);
$data = db_fetch_array($rs); $valueOmrade = $data["omrade"];
$valueEstimateDate = $data["estimate_finished_date"];
$valueEstimateTime = $data["estimate_finished_time"];
$valueHeading = $data["heading"];
$valueIngress = $data["ingress"];
$valueText = $data["text"];
$valuenext_info_text = $data["next_info_text"];
$valuenext_info_header = $data["next_info_header"];
$valuenext_info_button_text = $data["next_info_button_text"];
$valueProblemId = $data["id"];
$webId = $data["web_id"];
//We need the problem_id of th eproblem we are working with and that i sin the session as we hav especial code in events of edit page//
$problem_id = $_SESSION["problem_id_working"];
//Now get the subcase text and date/time from db// $sql3 = "SELECT DISTINCT(driftinfo_problem_subcase_manus.driftinfo_problem_id),
driftinfo_problem_subcase_manus.`date`,
DATE_FORMAT(driftinfo_problem_subcase_manus.`time`, '%H:%i') AS `time`,
driftinfo_problem_subcase_manus.text
FROM driftinfo_problem_subcase_manus LEFT OUTER JOIN driftinfo_lookup_language ON driftinfo_problem_subcase_manus.`language` = driftinfo_lookup_language.`2_letter_language_code` INNER JOIN driftinfo_problem ON driftinfo_problem_subcase_manus.driftinfo_problem_id = driftinfo_problem.id WHERE driftinfo_problem_subcase_manus.`language` = 'SV' AND driftinfo_problem.id = '$problem_id' AND driftinfo_problem_subcase_manus.dummy_row = 0
";
$rs3 = db_query($sql3);
$rowCount = 0;
while ($data3 = db_fetch_array($rs3))
{
//echo 'Data array: ' . $data3;
//echo '<pre>'; print_r($data3); echo '</pre>';
$subcase = array(); if ($rowCount++ % 2 == 1 ) {
$subcasestring .= '<table style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.','. 'Helvetica'.','. 'Helvetica, Arial, sans-serif; width: 100%;" bgcolor="">'. '<tbody>'. '<tr bgcolor="#f8f8f8">' . '<td align="left" height="">' . '<p class="" style="margin: 0; padding: 0; ' . 'font-family: ' . 'Helvetica Neue' . ',' . 'Helvetica' . ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. '<strong>' .$data3["date"] .' ' . $data3["time"]. '</strong>' . '</p>'.'</td>'. '</tr>'.'<tr bgcolor="#f8f8f8">'. '<td align="left" height=""><p class="" style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.',' . 'Helvetica'. ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. $data3["text"] . '</p>'. '</td>'. '</tr>'. '</table>';
}
else {
$subcasestring .= '<table style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.','. 'Helvetica'.','. 'Helvetica, Arial, sans-serif; width: 100%;" bgcolor="">'. '<tbody>'. '<tr bgcolor="#e5e5e5">' . '<td align="left" height="">' . '<p class="" style="margin: 0; padding: 0; ' . 'font-family: ' . 'Helvetica Neue' . ',' . 'Helvetica' . ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. '<strong>' .$data3["date"] . ' ' . $data3["time"]. '</strong>' . '</p>'.'</td>'. '</tr>'.'<tr bgcolor="#e5e5e5">'. '<td align="left" height=""><p class="" style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.',' . 'Helvetica'. ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. $data3["text"] . '</p>'. '</td>'. '</tr>'. '</table>';
}
//echo $subcasestring;
} /*
foreach ($data3 as $wp) {
// stripping stuff:
// increase $rowCount - if the remainder of a division by 2 is 1, echo extra class info:
if ($rowCount++ % 2 == 1 ) {
$subcasestring .= '<table style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.','. 'Helvetica'.','. 'Helvetica, Arial, sans-serif; width: 100%;" bgcolor="">'. '<tbody>'. '<tr bgcolor="#f8f8f8">' . '<td align="left" height="50">' . '<p class="" style="margin: 0; padding: 0; ' . 'font-family: ' . 'Helvetica Neue' . ',' . 'Helvetica' . ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. '<strong>' .$data3["date"] .' ' . $data3["time"]. '</strong>' . '</p>'.'</td>'. '</tr>'.'<tr bgcolor="#f8f8f8">'. '<td align="left" height="50"><p class="" style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.',' . 'Helvetica'. ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. $data3["text"] . '</p>'. '</td>'. '</tr>';
}
else {
$subcasestring .= '<table style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.','. 'Helvetica'.','. 'Helvetica, Arial, sans-serif; width: 100%;" bgcolor="">'. '<tbody>'. '<tr bgcolor="#e5e5e5">' . '<td align="left" height="50">' . '<p class="" style="margin: 0; padding: 0; ' . 'font-family: ' . 'Helvetica Neue' . ',' . 'Helvetica' . ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. '<strong>' .$data3["date"] . ' ' . $data3["time"]. '</strong>' . '</p>'.'</td>'. '</tr>'.'<tr bgcolor="#e5e5e5">'. '<td align="left" height="50"><p class="" style="margin: 0; padding: 0; font-family: '.'Helvetica Neue'.',' . 'Helvetica'. ',' . 'Helvetica, Arial, sans-serif; margin-bottom: 10px; font-weight: normal; font-size: 14px; line-height: 1.6;">'. $data3["text"] . '</p>'. '</td>'. '</tr>';
}
}
*/
//Next step is to loop through the $data3 and store in new var witch we later want to use in the body// //USE api_update.php to send to web
//We need to make array to string to be able to use it in api// $body = join(" ", array('<strong>', $valueIngress, '</strong><BR><BR>', $valueText, '<BR><BR>', '<strong>Beräknad åtgärdstid:</strong>', $valueEstimateDate, $valueEstimateTime));
$data[heading] = $valueOmrade;
//$data[body] = join(" ", array($valueIngress, $valueText, 'Vi uppskattar att nuvarande driftstörning är åtgärdad vid:', $valueEstimateDate, $valueEstimateTime));
$data[body] = $body . '<BR>'. $subcasestring;
$data[type] = 'operator';
$data[status] = '0'; $api = new sa_api();
$json = $api->post('', $data, $webId); //varken dollarReturn eller dollarJson innehåller ngt//
//$pageObject->setProxyValue("InfoId", $return);
// Create the records for last step in guide//
exit();
}
if($params["static_id"] == 4){
require_once ("resources/api_delete.php");
/////////////
$sql = "SELECT
driftinfo_problem.active,
driftinfo_problem.id,
driftinfo_problem.`date`,
driftinfo_problem.omrade,
driftinfo_problem.estimate_finished_date,
driftinfo_problem.`time`,
driftinfo_problem.`web_id`,
DATE_FORMAT(`estimate_finished_time`, '%H:%i') AS estimate_finished_time,
driftinfo_problem_manus_per_language.heading,
driftinfo_problem_manus_per_language.ingress,
driftinfo_problem_manus_per_language.text,
driftinfo_problem_manus_per_language.next_info_text,
driftinfo_problem_manus_per_language.next_info_header,
driftinfo_problem_manus_per_language.next_info_button_text,
driftinfo_problem_manus_per_language.`language`
FROM driftinfo_problem
INNER JOIN driftinfo_problem_manus_per_language ON driftinfo_problem.id = driftinfo_problem_manus_per_language.driftinfo_problem_id
WHERE (driftinfo_problem.active = 'Yes') AND driftinfo_problem_manus_per_language.`language` = 'SV'
";
$rs = db_query($sql);
$data = db_fetch_array($rs); $valueOmrade = $data["omrade"];
$valueEstimateDate = $data["estimate_finished_date"];
$valueEstimateTime = $data["estimate_finished_time"];
$valueHeading = $data["heading"];
$valueIngress = $data["ingress"];
$valueText = $data["text"];
$valuenext_info_text = $data["next_info_text"];
$valuenext_info_header = $data["next_info_header"];
$valuenext_info_button_text = $data["next_info_button_text"];
$valueProblemId = $data["id"];
$webId = $data["web_id"]; //USE api_post.php to send to web $data[heading] = $valueOmrade;
$data[body] = join(" ", array($valueIngress, $valueText, 'Vi uppskattar att nuvarande driftstörning är åtgärdad vid:', $valueEstimateDate, $valueEstimateTime));
$data[type] = 'operator';
$data[status] = '0'; $api = new sa_api();
$json = $api->post('', '', $webId); //varken dollarReturn eller dollarJson innehåller ngt//
//$pageObject->setProxyValue("InfoId", $return);
// Create the records for last step in guide//
$problem_id = $_SESSION["problem_id_working"];
$data4 = array();
$data4["driftinfo_problem_id"] = $problem_id;
$data4["static_id"] = 3; DB::Delete("driftinfo_problem_last_step_actions", $data4 );
//Delet now the dlete field//
$problem_id = $_SESSION["problem_id_working"];
$data4 = array();
$data4["driftinfo_problem_id"] = $problem_id;
$data4["static_id"] = 4; DB::Delete("driftinfo_problem_last_step_actions", $data4 );
exit();
}
return true;
As you see for the Click action code above i'm using an php file called resources/api_post.php with look like this:
<?php
require_once("/var/www/html/driftinfo/2/include/dbcommon.php");
class sa_api {
var $headers;
var $user_agent;
var $compression = 'gzip';
var $cookie_file;
var $proxy;
var $proto = 'https';
var $server = 'www.webpage.com/api/post/GSjN873oiu189sdlkFoPbWzyj';; function sa_api()
{
$this->headers[] = 'Accept: application/json';
$this->headers[] = 'Connection: Keep-Alive';
$this->headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$this->user_agent = 'SA_WebGUI';
} function post($uri, $data_as_array, $valueProblemId)
{
$data_as_string = json_encode($data_as_array);
$process = curl_init($this->proto . "://" . $this->server. "/" .$uri);
curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($process, CURLOPT_HEADER, false);
curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
curl_setopt($process, CURLOPT_ENCODING, $this->compression);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
if ($this->proxy)
curl_setopt($process, CURLOPT_PROXY, $this->proxy);
curl_setopt($process, CURLOPT_POSTFIELDS, $this->$data_as_string);
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($process, CURLOPT_POST, true);
$return = curl_exec($process);
$err_status = curl_error($curl);
$http_status_code = curl_getinfo($process, CURLINFO_HTTP_CODE);
curl_close($process); $json = json_decode($return); preg_match_all('!\d+!', $return, $matches);
$infoId = implode(' ', $matches[0]); $sql = "update driftinfo_problem set web_id=".$infoId ." where id=". $valueProblemId; CustomQuery($sql); } }
?>
Are really stuck, any hints or troubbleshooting tips would be appreciated <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=25629&image=2&table=forumtopics' class='bbc_emoticon' alt=':)' /> / Kristian
|
|