function execute($param, $post) { try { if (count($param) > 0) { if ($param[0] == "act") { $obj = json_decode($post["json"]); if ($obj->Action == "delete") { $guids = array(); foreach ($obj->Notes as $note) { $guids[] = $note->Guid; } return ReturnBoolean($this->deleteNotes($obj->NoteTakerGuid, $obj->NoteCollectionGuid, $guids)); } else { if ($obj->Action == "addorupdate") { $newNotes = array(); $updateNotes = array(); $listId = $this->getNoteCollectionId($obj->NoteTakerGuid, $obj->NoteCollectionGuid); if ($listId !== false) { foreach ($obj->Notes as $note) { $existingNote = GetSingleByCondition("Notes", array("Guid" => $note->Guid, "NoteCollectionId" => $listId)); if ($existingNote == null) { $newnote = new Note(); $newnote->NoteCollectionId = $listId; $newnote->Guid = $note->Guid; $newnote->Content = $note->Content; $newnote->Description = $note->Description; $newnote->CreateTime = ConvertToDatabaseDateTime($note->CreateTime); $newnote->IsCompleted = $note->IsCompleted; $newNotes[] = $newnote; } else { $existingNote->Content = $note->Content; $existingNote->Description = $note->Description; $existingNote->CreateTime = ConvertToDatabaseDateTime($note->CreateTime); $existingNote->IsCompleted = $note->IsCompleted; $updateNotes[] = $existingNote; } } $res = InsertAll($newNotes); $res &= UpdateAll($updateNotes); return ReturnBoolean($res == 1); } return ReturnBoolean(false); } else { if ($obj->Action == "get") { $listId = $this->getNoteCollectionId($obj->NoteTakerGuid, $obj->NoteCollectionGuid); if ($listId !== false) { $notes = GetAllByCondition("Notes", array("NoteCollectionId" => $listId)); $resp = new NoteResponse(); foreach ($notes as $note) { $resp->Notes[] = new NoteEntity($note); } return ReturnJson($resp); } return ReturnBoolean(false); } else { return ReturnError(LINK_INVALID); } } } } } return ReturnError(LINK_INVALID); } catch (\Exception $ex) { return ReturnError("Exception occured: " . $ex->getMessage()); } }
$sql_timesheet_update = "UPDATE intranet_timesheet SET ts_project = {$ts_fee_proj_change} WHERE ts_project = {$ts_fee_project} AND ts_stage_fee = {$ts_fee_id}"; $result_timesheet_update = mysql_query($sql_timesheet_update, $conn) or die(mysql_error()); $updated_rows = mysql_affected_rows(); //echo "<p>$sql_timesheet_update<br />$updated_rows affected rows</p>"; } // Check that the required values have been entered, and alter the page to show if these values are invalid // elseif ($ts_fee_text == "" ) { $alertmessage = "The description was left empty."; $page_redirect = "timesheet_fees_edit"; } // elseif ($ts_fee_value < 1 AND $ts_fee_percentage < 1) { $alertmessage = "The fee amount was left empty."; $page_redirect = "timesheet_fees_edit";} if ($ts_fee_percentage > 100) { $alertmessage = "The fee percentage is greater than 100."; $page_redirect = "timesheet_fees_edit"; } if ($alertmessage == NULL) { // Construct the MySQL instruction to add these entries to the database if ($ts_fee_id > 0) { $sql_edit = "UPDATE intranet_timesheet_fees SET\n\t\tts_fee_stage = '{$ts_fee_stage}',\n\t\tts_fee_time_begin = '',\n\t\tts_fee_time_end = '{$ts_fee_duration}',\n\t\tts_fee_text = '{$ts_fee_text}',\n\t\tts_fee_value = '{$ts_fee_value}',\n\t\tts_fee_project = '{$ts_fee_project}',\n\t\tts_fee_percentage = '{$ts_fee_percentage}',\n\t\tts_fee_pre = '{$ts_fee_pre}',\n\t\tts_fee_pre_lag = '{$ts_fee_pre_lag}',\n\t\tts_fee_commence = '{$ts_fee_commence}',\n\t\tts_fee_prospect = '{$ts_fee_prospect}',\n\t\tts_fee_target = '{$ts_fee_target}',\n\t\tts_fee_comment = '{$ts_fee_comment}'\n\t\tWHERE ts_fee_id = '{$ts_fee_id}' LIMIT 1"; $result = mysql_query($sql_edit, $conn) or die(mysql_error()); $actionmessage = "Fee stage updated successfully."; $techmessage = $sql_edit; if ($_POST[datum] == 1) { $sql_datum = "UPDATE intranet_timesheet_fees SET ts_datum_commence = '{$ts_fee_commence}', ts_datum_length = '{$ts_fee_duration}' WHERE ts_fee_id = '{$ts_fee_id}' LIMIT 1"; $result = mysql_query($sql_datum, $conn) or die(mysql_error()); } UpdateAll($ts_fee_id); } else { $sql_add = "INSERT INTO intranet_timesheet_fees (\n\t\tts_fee_id,\n\t\tts_fee_stage,\n\t\tts_fee_time_begin,\n\t\tts_fee_time_end,\n\t\tts_fee_text,\n\t\tts_fee_value,\n\t\tts_fee_project,\n\t\tts_fee_percentage,\n\t\tts_fee_pre,\n\t\tts_fee_pre_lag,\n\t\tts_fee_commence,\n\t\tts_fee_prospect,\n\t\tts_fee_target,\n\t\tts_fee_comment,\n\t\tts_datum_commence,\n\t\tts_datum_length\n\t\t) values (\n\t\tNULL,\n\t\t'{$ts_fee_stage}',\n\t\t'',\n\t\t'{$ts_fee_duration}',\n\t\t'{$ts_fee_text}',\n\t\t'{$ts_fee_value}',\n\t\t'{$ts_fee_project}',\n\t\t'{$ts_fee_percentage}',\n\t\t'{$ts_fee_pre}',\n\t\t'{$ts_fee_pre_lag}',\n\t\t'{$ts_fee_commence}',\n\t\t'{$ts_fee_prospect}',\n\t\t'{$ts_fee_target}',\n\t\t'{$ts_fee_comment}',\n\t\t'{$ts_fee_commence}',\n\t\t'{$ts_fee_duration}'\n\t\t)"; $result = mysql_query($sql_add, $conn) or die(mysql_error()); $actionmessage = "Fee stage added successfully."; $techmessage = $sql_add; } }
function execute($param, $post) { if (count($param) > 0) { if ($param[0] == "act") { $obj = json_decode($post["json"]); if ($obj->Action == "remove") { $existingUserConnections = array(); foreach ($obj->UserConnections as $userConnection) { $existingUserConnection = GetSingleByCondition("UserConnections", array("Guid" => $userConnection->Guid)); if ($existingUserConnection != null) { $existingUserConnections[] = $existingUserConnection; } } return ReturnBoolean(DeleteAll($existingUserConnections)); } else { if ($obj->Action == "add") { $newUserConnections = array(); foreach ($obj->UserConnections as $userConnection) { $existingUserConnection = GetSingleByCondition("UserConnections", array("Guid" => $userConnection->Guid)); if ($existingUserConnection == null) { $newuserconnection = new NoteTaker(); $newuserconnection->Guid = $userConnection->Guid; $newuserconnection->Color = $userConnection->Color; $newuserconnection->Name = $userConnection->Name; $newuserconnection->ConnectedUserGuid = $userConnection->ConnectedUserGuid; $newuserconnection->UserGuid = $obj->Guid; $newUserConnections[] = $newuserconnection; } } return ReturnBoolean(InsertAll($newUserConnections)); } else { if ($obj->Action == "addorupdate") { $newUserConnections = array(); $updateUserConnections = array(); foreach ($obj->UserConnections as $userConnection) { $existingUserConnection = GetSingleByCondition("UserConnections", array("Guid" => $userConnection->Guid)); if ($existingUserConnection == null) { $newuserconnection = new NoteTaker(); $newuserconnection->Guid = $userConnection->Guid; $newuserconnection->Color = $userConnection->Color; $newuserconnection->Name = $userConnection->Name; $newuserconnection->ConnectedUserGuid = $userConnection->ConnectedUserGuid; $newuserconnection->UserGuid = $obj->Guid; $newUserConnections[] = $newuserconnection; } else { $existingUserConnection->Color = $userConnection->Color; $existingUserConnection->Name = $userConnection->Name; $existingUserConnection->ConnectedUserGuid = $userConnection->ConnectedUserGuid; $existingUserConnection->UserGuid = $obj->Guid; $updateUserConnections[] = $existingUserConnection; } } return ReturnBoolean(InsertAll($newUserConnections) && UpdateAll($updateUserConnections)); } else { if ($obj->Action == "sync") { $userConnectioncount = $this->countExistingUserConnections($obj); if ($userConnectioncount !== $obj->ExpectedCount) { return ReturnBoolean(false); } $userConnections = GetAllByCondition("UserConnections", array("UserGuid" => $obj->Guid), "Name DESC", " LIMIT " . count($obj->UserConnections)); for ($i = 0; $i < count($userConnections); $i++) { if ($userConnections[$i]->Guid != $obj->UserConnections[$i]->Guid) { return ReturnBoolean(false); } } return ReturnBoolean(true); } else { return ReturnError(LINK_INVALID); } } } } } else { if ($param[0] == "checkGUID" && isset($param[1])) { $res = $this->checkForUniqueGuid($param[1]); if ($res == 1) { return ReturnBoolean(true); } return ReturnBoolean(false); } else { if ($param[0] == "completeGUID" && isset($param[1])) { $res = $this->getUniqueGuid($param[1]); if ($res !== false) { return ReturnJson(new GuidResponse($res)); } return ReturnJson(new GuidResponse("00000000-0000-0000-0000-00000000000")); } else { if (ValidateGuid($param[0])) { $userConnections = GetAllByCondition("UserConnections", array("UserGuid" => $param[0]), "Name DESC"); $resp = new UserConnectionResponse(); foreach ($userConnections as $userConnection) { $resp->UserConnections[] = new NoteTakerEntity($userConnection); } return ReturnJson($resp); } } } } } return ReturnError(LINK_INVALID); }
function execute($param, $post) { try { if (count($param) > 0) { if ($param[0] == "act") { $obj = json_decode($post["json"]); if ($obj->Action == "delete") { $guids = array(); foreach ($obj->NoteCollections as $collection) { $guids[] = $collection->Guid; } return ReturnBoolean($this->deleteNoteCollections($obj->NoteTakerGuid, $guids)); } else { if ($obj->Action == "addorupdate") { $newCollections = array(); $updateCollections = array(); $taker = $this->tryAddNoteTaker($obj->NoteTakerGuid); if ($taker !== false) { $existingCollections = $this->getNoteCollections($obj->NoteTakerGuid); foreach ($obj->NoteCollections as $collection) { $found = false; foreach ($existingCollections as $existingCollection) { if ($existingCollection->Guid == $collection->Guid) { $found = $existingCollection; } } if ($found == false) { $newCollection = new NoteCollection(); $newCollection->Guid = $collection->Guid; $newCollection->CreateTime = ConvertToDatabaseDateTime($collection->CreateTime); $newCollection->Name = $collection->Name; $newCollections[] = $newCollection; } else { $found->Name = $collection->Name; $found->CreateTime = ConvertToDatabaseDateTime($collection->CreateTime); $updateCollections[] = $found; } } return ReturnBoolean($this->addNoteCollections($obj->NoteTakerGuid, $newCollections) && UpdateAll($updateCollections)); } return ReturnBoolean(false); } else { if ($obj->Action == "get") { $collections = $this->getNoteCollections($obj->NoteTakerGuid); if ($collections !== false) { $resp = new NoteCollectionResponse(); foreach ($collections as $collection) { $resp->NoteCollections[] = new NoteCollectionEntity($collection); } return ReturnJson($resp); } return ReturnBoolean(false); } else { return ReturnError(LINK_INVALID); } } } } } return ReturnError(LINK_INVALID); } catch (\Exception $ex) { return ReturnError("Exception occured: " . $ex->getMessage()); } }