Made CSV import of dates working

SVN revision: 2166
This commit is contained in:
Stefan Ritt 2009-01-22 08:01:40 +00:00
parent 03763e6627
commit e3ac2bcadc

View File

@ -2274,7 +2274,7 @@ int sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, char *text, c
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (strchr(str, '\r')) if (strchr(str, '\r'))
*strchr(str, '\r') = 0; *strchr(str, '\r') = 0;
if (atoi(str) >= 100) { if (atoi(str) != 334) {
strcat(str, "\n"); strcat(str, "\n");
if (verbose) if (verbose)
efputs(str); efputs(str);
@ -2294,8 +2294,8 @@ int sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, char *text, c
strcat(str, "\r\n"); strcat(str, "\r\n");
send(s, str, strlen(str), 0); send(s, str, strlen(str), 0);
if (verbose) if (verbose)
efputs(str); efputs(decoded);
write_logfile(lbs, str); write_logfile(lbs, decoded);
recv_string(s, str, strsize, 3000); recv_string(s, str, strsize, 3000);
if (strchr(str, '\r')) if (strchr(str, '\r'))
*strchr(str, '\r') = 0; *strchr(str, '\r') = 0;
@ -13908,11 +13908,11 @@ void show_import_page_csv(LOGBOOK * lbs)
rsprintf("<input type=checkbox id=\"head\" name=\"head\" value=\"1\">\n"); rsprintf("<input type=checkbox id=\"head\" name=\"head\" value=\"1\">\n");
rsprintf("<label for=\"head\">%s</label><br>\n", loc("Derive attributes from CSV file")); rsprintf("<label for=\"head\">%s</label><br>\n", loc("Derive attributes from CSV file"));
if (isparam("ignore")) if (isparam("notignore"))
rsprintf("<input type=checkbox checked id=\"ignore\" name=\"ignore\" value=\"1\">\n"); rsprintf("<input type=checkbox checked id=\"notignore\" name=\"notignore\" value=\"1\">\n");
else else
rsprintf("<input type=checkbox id=\"ignore\" name=\"ignore\" value=\"1\">\n"); rsprintf("<input type=checkbox id=\"notignore\" name=\"notignore\" value=\"1\">\n");
rsprintf("<label for=\"ignore\">%s</label><br>\n", loc("Ignore first line")); rsprintf("<label for=\"notignore\">%s</label><br>\n", loc("Do not ignore first line"));
rsprintf("<input type=checkbox id=\"preview\" name=\"preview\" value=\"1\">\n"); rsprintf("<input type=checkbox id=\"preview\" name=\"preview\" value=\"1\">\n");
rsprintf("<label for=\"preview\">%s</label><br>\n", loc("Preview import")); rsprintf("<label for=\"preview\">%s</label><br>\n", loc("Preview import"));
@ -14078,8 +14078,8 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
rsprintf("<input type=hidden name=sep value=\"%s\">\n", sep); rsprintf("<input type=hidden name=sep value=\"%s\">\n", sep);
if (isparam("head")) if (isparam("head"))
rsprintf("<input type=hidden name=head value=\"%s\">\n", getparam("head")); rsprintf("<input type=hidden name=head value=\"%s\">\n", getparam("head"));
if (isparam("ignore")) if (isparam("notignore"))
rsprintf("<input type=hidden name=ignore value=\"%s\">\n", getparam("ignore")); rsprintf("<input type=hidden name=notignore value=\"%s\">\n", getparam("notignore"));
if (isparam("filltext")) if (isparam("filltext"))
rsprintf("<input type=hidden name=filltext value=\"%s\">\n", getparam("filltext")); rsprintf("<input type=hidden name=filltext value=\"%s\">\n", getparam("filltext"));
rsprintf("<input type=hidden name=csvfile value=\"%s\">\n", csvfile); rsprintf("<input type=hidden name=csvfile value=\"%s\">\n", csvfile);
@ -14116,7 +14116,7 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
} }
/* ignore first line */ /* ignore first line */
if (first && isparam("ignore")) { if (first && !isparam("notignore")) {
first = FALSE; first = FALSE;
continue; continue;
} }
@ -14240,9 +14240,17 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
} else { } else {
/* get date if present */ /* get date and check it */
strlcpy(date, list + datecol*NAME_LENGTH, sizeof(date)); strlcpy(date, list + datecol*NAME_LENGTH, sizeof(date));
ltime = date_to_ltime(date);
if (ltime <= 0) {
strcpy(str, loc("Invalid date format"));
strlcat(str, ": \"", sizeof(str));
strlcat(str, date, sizeof(str));
strlcat(str, "\"", sizeof(str));
show_error(str);
return;
} else {
if (!filltext) { if (!filltext) {
/* submit entry */ /* submit entry */
if (el_submit if (el_submit
@ -14266,6 +14274,7 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
} }
} }
} }
}
first = FALSE; first = FALSE;