use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class ReceiptsRowBuildder method incrementCount.
@Override
protected int incrementCount(SurveyStock surveyStock, int newValue) {
Survey survey = surveyStock.getSurvey();
Date maxBalanceDate = Survey.getLastDateForSurveyType(Constants.SURVEY_RESET);
if ((maxBalanceDate == null || Utils.dateGreaterOrEqualsThanDate(maxBalanceDate, survey.getEventDate())) && survey.getType().equals(Constants.SURVEY_RECEIPT)) {
return newValue;
}
return 0;
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class StatusRowBuilder method updateColumn.
@Override
protected Object updateColumn(Object oldValue, int surveyValue, SurveyStock surveyStock, int position) {
Survey survey = surveyStock.getSurvey();
Date maxBalanceDate = Survey.getLastDateForSurveyType(Constants.SURVEY_RESET);
if (maxBalanceDate == null || Utils.dateGreaterOrEqualsThanDate(maxBalanceDate, survey.getEventDate())) {
if (survey.getType() == Constants.SURVEY_RESET) {
balanceSurvey[position] = surveyValue;
} else if (survey.getType() == Constants.SURVEY_RECEIPT) {
summationReceiptsUsed[position] += surveyValue;
} else if (survey.getType() == Constants.SURVEY_ISSUE) {
summationReceiptsUsed[position] -= surveyValue;
}
columnClasses.set(position + 1, getCSSForValues(position));
}
return "";
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class DashboardActivityStrategy method sendSurvey.
@Override
public void sendSurvey() {
Session.getMalariaSurvey().updateSurveyStatus();
Survey stockSurvey = Session.getStockSurvey();
if (stockSurvey != null) {
Session.getStockSurvey().complete();
Date eventDate = new Date();
saveEventDate(Session.getMalariaSurvey(), eventDate);
saveEventDate(Session.getStockSurvey(), eventDate);
new CompletionSurveyUseCase().execute(Session.getMalariaSurvey().getId_survey());
}
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class DashboardActivityStrategy method completeSurvey.
@Override
public void completeSurvey() {
Date eventDate = new Date();
//Complete malariaSurvey
Survey survey = Session.getMalariaSurvey();
saveEventDate(survey, eventDate);
survey.updateSurveyStatus();
//Complete stockSurvey
survey = Session.getStockSurvey();
saveEventDate(survey, eventDate);
survey.complete();
}
use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.
the class DashboardActivity method onSurveyBackPressed.
/**
* It is called when the user press back in a surveyFragment
*/
private void onSurveyBackPressed() {
//// FIXME: 09/03/2017 Refactor. If the survey is loading the survey should be closed at the end
if (Session.isIsLoadingSurvey()) {
Session.setShouldPressBackOnLoadSurvey(true);
return;
}
Log.d(TAG, "onBackPressed");
Survey survey = Session.getMalariaSurvey();
if (!survey.isSent()) {
int infoMessage = survey.isInProgress() ? R.string.survey_info_exit_delete : R.string.survey_info_exit;
new AlertDialog.Builder(this).setTitle(R.string.survey_info_exit).setMessage(infoMessage).setNegativeButton(android.R.string.no, null).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
//Reload data using service
isBackPressed = true;
closeSurveyFragment();
}
}).create().show();
} else {
closeSurveyFragment();
}
}
Aggregations