コード例 #1
0
$user = \creamy\CreamyUser::currentUser();
// check required fields
$validated = 1;
if (!isset($_POST["customerid"])) {
    $validated = 0;
}
if (!isset($_POST["old_customer_type"])) {
    $validated = 0;
}
if (!isset($_POST["new_customer_type"])) {
    $validated = 0;
}
if ($validated == 1) {
    $db = new \creamy\DbHandler();
    // parameters
    $customerid = $_POST["customerid"];
    $oldCustomerType = $_POST["old_customer_type"];
    $newCustomerType = $_POST["new_customer_type"];
    // create customer and return result.
    $result = $db->changeCustomerType($customerid, $oldCustomerType, $newCustomerType);
    if ($result === true) {
        ob_clean();
        print CRM_DEFAULT_SUCCESS_RESPONSE;
    } else {
        ob_clean();
        $lh->translateText("unable_modify_customer");
    }
} else {
    ob_clean();
    $lh->translateText("some_fields_missing");
}