CMS  Version 3.9
data_import_field_mapping.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("data_sync");
3 Fakoli::usingFeature("spreadsheet_form");
4 
5 $class = $_SESSION["data_import_class"];
6 $format = $_SESSION["data_file_format"];
7 $file = $_SESSION["data_import_file"];
8 
9 $menu_item = "Data Import";
10 $page_title = "Choose Fields to Import";
11 
12 $profile_id = $_GET["import_profile_id"];
13 
14 $multiProfile = Settings::getValue("data_sync", "multiple_import_profiles");
15 
16 if ($multiProfile)
17 {
18 
19  if (!$profile_id)
20  {
21  $profile_id = $_SESSION["import_profile_id"];
22  if ($profile_id) redirect("data_import_field_mapping?import_profile_id=$profile_id");
23  }
24 
25  if ($profile_id)
26  {
28  if (!$profile->exists())
29  {
30  unset($_SESSION["import_profile_id"]);
31  redirect("data_import_field_mapping");
32  }
33  }
34 
35  $profiles = Query::create(DataImportProfile, "WHERE class=:c ORDER BY profile")
36  ->bind(":c", $class)
37  ->execute();
38 
39  if (count($profiles) && !$profile_id)
40  {
41  $profile_id = $profiles[0]->import_profile_id;
42  }
43 
44  $_SESSION["import_profile_id"] = $profile_id;
45 }
46 else
47 {
48  $profile_id = 0;
49 }
50 
51 
53 var_dump($columns);
55 
56 $options = array_combine($columns, $columns);
57 
59 $form = new AutoForm($mapping);
60 $form->hide("class", "import_profile_id");
61 $columnSelect = new ChecklistFieldRenderer($form, "import_column", "Import Column", $options);
62 $columnSelect->setSize(250, 200);
63 $columnSelect->dropdown = true;
64 $columnSelect->dropdownMessage = "Click to Select Columns";
65 
66 $form->readonly("client_field");
67 $form->getRenderer("client_field")->template = "prettify";
68 
69 $spreadsheet = new SpreadsheetForm($form, $fieldMappings, 0, "POST", "", "", array(FieldMappingHelper, onItemRow));
70 $spreadsheet->formCSS = "list spreadsheet small";
71 
72 $spreadsheet->submitLabel = "Save Field Mapping";
73 $spreadsheet->button("Clear Field Mapping", "/action/data_sync/clear_mapping?import_profile_id={$profile_id}");
74 
76 
77 if ($method == "POST")
78 {
79  if ($spreadsheet->save())
80  {
81  $_SESSION["import_profile_id"] = $profile_id;
82  $tabs->next();
83  }
84 }
85 
86 $script .= $spreadsheet->writeScript();
87 
88 if ($multiProfile)
89 {
90  if (!$profile_id) $profile_id = 0;
91 
92  $script .= <<<ENDSCRIPT
93  <script type="text/javascript" src="/components/data_sync/js/data_sync_profile_manager.js"></script>
94  <script type="text/javascript">
95 
96  var importProfileManager;
97 
98 
99  window.addEvent('load', function()
100  {
101  importProfileManager = new DataImportProfileManager("{$class}", {$profile_id});
102  });
103  </script>
104 ENDSCRIPT;
105 }
106 
107 $tabs->writeHTML();
108 ?>
109 <div class="tab_border">
110 <?
112 {
113 ?>
114 <p class='warning'><i class='fa-fw fas fa-exclamation-triangle'></i> You need to set the <b>Matching</b> flag for at least one field.</p>
115 <?
116 }
117 
118 if ($multiProfile)
119 {
120 ?>
121 <label for="import_profile_id">Select Import Profile: </label><select name="import_profile_id" onchange='go("?import_profile_id=" + this.value);'>
122 <?
123 foreach($profiles as $profile)
124 {
125  option($profile->import_profile_id, $profile->profile, $profile_id);
126 }
127 ?>
128 </select>&nbsp;<a href='#' class='button' onclick='importProfileManager.createProfileDialog(); return false;'>Create New Profile</a>
129 <br/>
130 <br/>
131 <?
132 }
133 $spreadsheet->drawForm();
134 ?>
135 </div>
& nbsp
Definition: index.inc:49
if($method=="POST") $script
static fieldMappingHasMatchField($fieldMappings)
static getImportColumns($class, $file="", $format=null)
static getFieldMappings($class, $profile_id=0)
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$forumRequest to
$openData field
$_SESSION["useMobile"]
Definition: override.inc:7