Beispiel #1
0
function genSD($projectID)
{
    $file = genPDF($projectID, true);
    $info = getProjectInfo($projectID);
    $xml = "<Operation>\n    <Details>";
    $xml .= addParam("requesttemplate", "API");
    $xml .= addParam("requester", $info["name"]);
    $xml .= addParam("email", $info["email"]);
    $xml .= addParam("subject", $info["title"]);
    $xml .= addParam("description", $info["notes"]);
    $date = strtotime($info["duedate"]);
    $datestr = date("j F Y", $date) . ", 23:59:59";
    $xml .= addParam("Due Date", $datestr);
    $xml .= "</Details>\n          </Operation>";
    $key = getSDkey();
    $method = "ADD_REQUEST";
    $postvars = array("OPERATION_NAME" => $method, "TECHNICIAN_KEY" => $key, "INPUT_DATA" => $xml);
    $url = getSDBaseURL() . "sdpapi/request/";
    $res = postAPI($url, $postvars, null, false);
    $resp = simplexml_load_string($res);
    if (isset($resp->response->operation->Details[0]->workorderid)) {
        $wo = $resp->response->operation->Details[0]->workorderid;
        $url = getSDBaseURL() . "sdpapi/request/{$wo}/attachment?OPERATION_NAME=ADD_ATTACHMENT&TECHNICIAN_KEY={$key}";
        $fields = array("file" => '@' . $file);
        $headers = array('Content-Type: multipart/form-data');
        $res = postAPI($url, $fields, $headers, false, false);
        $resp = simplexml_load_string($res);
        if (isset($resp->response->operation->result->status)) {
            if ($resp->response->operation->result->status == "Success") {
                //complete
            }
        }
        return array('url' => getSDBaseURL() . "WorkOrder.do?woMode=viewWO&woID={$wo}", 'ID' => $wo);
    } else {
        return null;
    }
}
/**
 * update terms
 *
 * @param $coldNames - array of field names
 * @param $trmID - term id, in case new term this is string
 * @param $values - array of values
 * @param $ext_db - mysqli
 * @return $ret - if success this is ID of term, if failure - error string
 */
function updateTerms($colNames, $trmID, $values, $ext_db)
{
    global $mysqli, $trmColumnNames;
    if ($ext_db == null) {
        $ext_db = $mysqli;
    }
    $ret = null;
    if (count($colNames) && count($values)) {
        $isInsert = $trmID == null || !is_numeric($trmID) && strrpos($trmID, "-") > 0;
        $inverse_termid_old = null;
        if (!$isInsert) {
            //find inverse term id
            $res = $ext_db->query("select trm_InverseTermId from defTerms where trmID=" . $trmID);
            if ($res) {
                if ($row = $res->fetch_row()) {
                    $inverse_termid_old = $row[0];
                }
            }
        }
        $query = "";
        $querycols = "";
        $parameters = array("");
        $ch_parent_id = null;
        $ch_code = null;
        $ch_label = null;
        $inverse_termid = null;
        foreach ($colNames as $colName) {
            $val = array_shift($values);
            if (array_key_exists($colName, $trmColumnNames)) {
                //array_push($ret['error'], "$colName is not a valid column name for defDetailTypes val= $val was not used");
                if ($query != "") {
                    $query = $query . ",";
                    $querycols = $querycols . ",";
                }
                if ($isInsert) {
                    $query = $query . "?";
                    $querycols = $querycols . $colName;
                } else {
                    $query = $query . "{$colName} = ?";
                }
                if ($colName == "trm_ParentTermID") {
                    $ch_parent_id = $val;
                } else {
                    if ($colName == "trm_Code") {
                        $ch_code = $val;
                    } else {
                        if ($colName == "trm_Label") {
                            $ch_label = $val;
                        } else {
                            if ($colName == "trm_InverseTermId") {
                                if ($val == "") {
                                    $val = null;
                                }
                                $inverse_termid = $val;
                                //new value
                            } else {
                                if ($colName == "trm_Status") {
                                    if ($val == "") {
                                        $val = "open";
                                    }
                                }
                            }
                        }
                    }
                }
                $parameters = addParam($parameters, $trmColumnNames[$colName], $val);
            }
        }
        //for columns
        //check label and code duplication for the same level
        if ($ch_code || $ch_label) {
            if ($ch_parent_id) {
                $ch_parent_id = "trm_ParentTermID=" . $ch_parent_id;
            } else {
                $ch_parent_id = "(trm_ParentTermID is null or trm_ParentTermID=0)";
            }
            $dupquery = "select trm_ID from defTerms where " . $ch_parent_id;
            if (!$isInsert) {
                $dupquery .= " and (trm_ID <>" . $trmID . ")";
            }
            $dupquery .= " and (";
            if ($ch_code) {
                $dupquery .= "(trm_Code = '" . mysql_real_escape_string($ch_code) . "')";
            }
            if ($ch_label) {
                if ($ch_code) {
                    $dupquery .= " or ";
                }
                $dupquery .= "(trm_Label = '" . mysql_real_escape_string($ch_label) . "')";
            }
            $dupquery .= ")";
            $res = $ext_db->query($dupquery);
            if ($ext_db->error) {
                $ret = "SQL error checking duplication values in terms: " . $ext_db->error . "  Query:" . $dupquery;
            } else {
                $recCount = $res->num_rows;
                if ($recCount > 0) {
                    $ret = "Duplicate label ('{$ch_label}') or code ('{$ch_code}') not allowed for terms at the same branch/level in the tree";
                }
            }
        }
        //insert, update
        if (!$ret && $query != "") {
            if ($isInsert) {
                $query = "insert into defTerms (" . $querycols . ") values (" . $query . ")";
            } else {
                $query = $query . ", trm_LocallyModified=IF(trm_OriginatingDBID>0,1,0)";
                $query = "update defTerms set " . $query . " where trm_ID = {$trmID}";
            }
            $rows = execSQL($ext_db, $query, $parameters, true);
            if ($rows == 0 || is_string($rows)) {
                //ERROR
                $oper = $isInsert ? "inserting" : "updating term " . $trmID;
                $ret = "SQL error {$oper} in updateTerms: " . $rows;
                //."  ".htmlspecialchars($query);
            } else {
                if ($isInsert) {
                    $trmID = $ext_db->insert_id;
                    // new id
                }
                if ($inverse_termid != null) {
                    $query = "update defTerms set trm_InverseTermId={$trmID} where trm_ID={$inverse_termid}";
                    execSQL($ext_db, $query, null, true);
                } else {
                    if ($inverse_termid_old != null) {
                        $query = "update defTerms set trm_InverseTermId=null where trm_ID={$inverse_termid_old}";
                        execSQL($ext_db, $query, null, true);
                    }
                }
                $ret = $trmID;
            }
        }
    }
    //if column names
    if ($ret == null) {
        $ret = "no data supplied for updating record structure - {$trmID}";
    }
    return $ret;
}
Beispiel #3
0
        }
        $paypalUriOk = $value;
        continue;
    } elseif ($name == 'notify_url') {
        if (!FWValidator::isUri($value)) {
            continue;
        }
        $paypalUriIpn = $value;
        continue;
    } elseif ($name == 'cmd') {
        if ($value == '_notify-validate') {
            die("VERIFIED");
        }
        continue;
    }
    addParam($name, $value);
}
function addParam($name, $value)
{
    global $strForm;
    $strForm .= "        <tr><td>" . contrexx_input2xhtml($name) . "</td><td><input type=\"text\" name=\"" . contrexx_input2xhtml($name) . "\" value=\"" . urlencode($value) . "\" /></td></tr>\n";
}
die('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>PayPal Dummy</title>
    <script type="text/javascript">
    // <![CDATA[
    function submitResult(result) {
      targetUri = "";
      if (result == -1) {