// do we have a title? // if not, we do need at least some customer data... if (!isset($_POST["customerid"])) { $validated = 0; } else { if (!isset($_POST["customer_type"])) { $validated = 0; } } } if ($validated == 1) { $db = new \creamy\DbHandler(); // check if this is a new customer type of event. if (isset($_POST["customerid"]) && isset($_POST["customer_type"])) { $customerid = $_POST["customerid"]; $customertype = $_POST["customer_type"]; $result = $db->createContactEventForCustomer($user->getUserId(), $customerid, $customertype, true, null, null, null); } else { // normal event $title = $_POST["title"]; $color = isset($_POST["color"]) ? $_POST["color"] : CRM_UI_COLOR_DEFAULT_HEX; error_log("Creando evento con color {$color}"); $result = $db->createEvent($user->getUserId(), $title, $color, true, null, null, null); } // return result ob_clean(); print "{$result}"; } else { ob_clean(); print "0"; }