Exemplo n.º 1
0
     if ($result) {
         if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql") {
             $cust = $ds->ds->Insert_ID();
         } else {
             // emulate getting the last insert_id
             $result =& $ds->ds->Execute("SELECT customer \n                            FROM customer\n                            WHERE custdescrip=" . $ds->ds->qstr($custdescrip));
             $temprow = $result->FetchRow();
             $cust = $temprow["customer"];
         }
         $ds->AuditLog(array("event" => 180, "action" => "create customer", "user" => getAuthUsername(), "cust" => $cust, "descrip" => $custdescrip));
         $ds->DbfTransactionEnd();
     }
 } else {
     // always need to test - customer could have been deleted
     // result used later
     $result = $ds->GetCustomerInfo($cust);
     // should only be one row here
     if (!($row = $result->FetchRow())) {
         myError($w, $p, my_("Customer cannot be found!"));
     }
     $result =& $ds->ds->Execute("UPDATE customer\n                    SET custdescrip=" . $ds->ds->qstr($custdescrip) . ",\n                    crm=" . $ds->ds->qstr($crm) . ",\n                    admingrp=" . $ds->ds->qstr($grp) . "\n                    WHERE customer={$cust}");
     // did not fail due to key error?
     if ($result) {
         $ds->AuditLog(array("event" => 181, "action" => "modify customer", "user" => getAuthUsername(), "cust" => $cust, "descrip" => $custdescrip));
         $ds->DbfTransactionEnd();
     }
 }
 // test for CRM duplicates - this is not a unique key and cannot be
 if (!empty($crm)) {
     $recs = $ds->ds->GetOne("SELECT count(*) AS cnt FROM customer \n                    WHERE crm=" . $ds->ds->qstr($crm));
     if ($recs > 1) {
Exemplo n.º 2
0
function __FetchCustomerInfo($params)
{
    global $xmlrpcerruser;
    // import user errcode value
    // $params is an Array of xmlrpcval objects
    $errstr = "";
    $err = 0;
    if (IPPLAN_API_VER != DBF_API_VER) {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, "Incorrect API version");
    }
    // get the first param
    $custobj = $params->getParam(0);
    // if it's there and the correct type
    if (isset($custobj) && $custobj->scalartyp() == "int") {
        // extract the value of the state number
        $cust = $custobj->scalarval();
        if (!($ds = new IPplanDbf())) {
            return new xmlrpcresp(0, $xmlrpcerruser + 1, "Could not connect to database");
        }
        $result = $ds->GetCustomerDNSInfo($cust);
        while ($row = $result->FetchRow()) {
            $myDNS[] = new xmlrpcval(array("hname" => new xmlrpcval($row["hname"]), "ipaddr" => new xmlrpcval($row["ipaddr"])), "struct");
        }
        $result = $ds->GetCustomerInfo($cust);
        // only one row here
        $row = $result->FetchRow();
        $myVal = new xmlrpcval(array("org" => new xmlrpcval($row["org"]), "street" => new xmlrpcval($row["street"]), "city" => new xmlrpcval($row["city"]), "state" => new xmlrpcval($row["state"]), "zipcode" => new xmlrpcval($row["zipcode"]), "cntry" => new xmlrpcval($row["cntry"]), "nichandl" => new xmlrpcval($row["nichandl"]), "lname" => new xmlrpcval($row["lname"]), "fname" => new xmlrpcval($row["fname"]), "mname" => new xmlrpcval($row["mname"]), "torg" => new xmlrpcval($row["torg"]), "tstreet" => new xmlrpcval($row["tstreet"]), "tcity" => new xmlrpcval($row["tcity"]), "tstate" => new xmlrpcval($row["tstate"]), "tzipcode" => new xmlrpcval($row["tzipcode"]), "tcntry" => new xmlrpcval($row["tcntry"]), "phne" => new xmlrpcval($row["phne"]), "mbox" => new xmlrpcval($row["mbox"]), "dns" => new xmlrpcval($myDNS, "array")), "struct");
    } else {
        // parameter mismatch, complain
        $err = 2;
        $errstr = "Incorrect parameters";
    }
    if ($err) {
        // this is an error condition
        return new xmlrpcresp(0, $xmlrpcerruser + 1, $errstr);
    } else {
        // this is a successful value being returned
        return new xmlrpcresp($myVal);
    }
}