17 include_once (
"FDL/Class.Dir.php");
18 include_once (
"FDL/import_file.php");
19 include_once (
"FDL/modcard.php");
20 include_once (
"GENERIC/generic_util.php");
37 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/subwindow.js");
39 $policy = GetHttpVars(
"policy",
"update");
40 $category = GetHttpVars(
"category");
41 $analyze = (GetHttpVars(
"analyze",
"N") ==
"Y");
42 $key1 = GetHttpVars(
"key1",
"title");
43 $key2 = GetHttpVars(
"key2",
"");
44 $classid = GetHttpVars(
"classid",
getDefFam($action));
45 $comma = GetHttpVars(
"comma",
";");
46 $tcolorder[$classid] = GetHttpVars(
"colorder");
52 if (isset($_FILES[
"vcardfile"])) {
54 $vcardfile = $_FILES[
"vcardfile"][
"tmp_name"];
56 $vcardfile = GetHttpVars(
"file");
61 $fdoc = fopen($cvsfile,
"r");
63 $fdoc = fopen($vcardfile,
"r");
66 if (!$fdoc) $action->
exitError(_(
"no csv import file specified"));
69 if (
$analyze) $action->lay->set(
"importresult", _(
"import analysis result"));
70 else $action->lay->set(
"importresult", _(
"import results"));
76 while (!feof($fdoc)) {
77 $buffer = rtrim(fgets($fdoc, 4096));
78 $data = explode($comma, $buffer);
81 if ($num < 1)
continue;
86 if (isset($tkeys[$fromid])) $tk = $tkeys[$fromid];
93 if (
$cr[$line][
"err"] !=
"") {
96 if (
$cr[$line][
"id"] > 0) {
98 if (is_array($category)) {
100 foreach ($category as $k => $v) {
105 $err = $catg->AddFile(
$cr[$line][
"id"]);
107 if (
$err ==
"")
$cr[$line][
"msg"].= sprintf(_(
"Add it in %s folder") , $catg->title);
124 "values" => array() ,
130 $cr[$line][
"msg"] = sprintf(_(
"new column order %s") , implode(
" - ", $tcolorder[$fromid]));
144 "values" => array() ,
150 if (($tkeys[$fromid][0] ==
"") || (count($tkeys[$fromid]) == 0)) {
151 $cr[$line][
"err"] = sprintf(_(
"error in import keys : %s") , implode(
" - ", $tkeys[$fromid]));
152 unset($tkeys[$fromid]);
153 $cr[$line][
"action"] =
"ignored";
155 $cr[$line][
"msg"] = sprintf(_(
"new import keys : %s") , implode(
" - ", $tkeys[$fromid]));
163 foreach (
$cr as $k => $v) {
164 $cr[$k][
"taction"] = _($v[
"action"]);
165 $cr[$k][
"order"] = $k;
166 $cr[$k][
"svalues"] =
"";
168 foreach ($v[
"values"] as $ka => $va) {
169 $cr[$k][
"svalues"].=
"<LI>[$ka:$va]</LI>";
173 $action->lay->SetBlockData(
"ADDEDDOC",
$cr);
174 $nbdoc = count(array_filter(
$cr,
"isdoc2"));
175 $action->lay->
Set(
"nbdoc",
"$nbdoc");
179 return (($var[
"action"] ==
"added") || ($var[
"action"] ==
"updated"));
getDefFld(Action &$action)
setPostVars(Doc &$doc, &$info=array())
getOrder(array $orderdata)
getDefFam(Action &$action)
exitError($texterr, $exit=true, $code="")
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getFamIdFromName($dbaccess, $name)
generic_importcsv(Action &$action)
new_Doc($dbaccess, $id= '', $latest=false)
setMaxExecutionTimeTo($limit)
csvAddDoc($dbaccess, $data, $dirid=0, $analyze=false, $ldir= '', $policy="add", $tkey=array("title"), $prevalues=array(), $torder=array())
if($file) if($subject==""&&$file) if($subject=="") $err