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 
7 $menu_item = "Data Import";
8 $page_title = "Choose Fields to Import";
9 
10 $profile_id = $_GET["import_profile_id"];
11 
12 $multiProfile = Settings::getValue("data_sync", "multiple_import_profiles");
13 
14 if ($multiProfile)
15 {
16 
17  if (!$profile_id)
18  {
19  $profile_id = $_SESSION["import_profile_id"];
20  if ($profile_id) redirect("data_import_field_mapping?import_profile_id=$profile_id");
21  }
22 
23  if ($profile_id)
24  {
26  if (!$profile->exists())
27  {
28  unset($_SESSION["import_profile_id"]);
29  redirect("data_import_field_mapping");
30  }
31  }
32 
33  $profiles = Query::create(DataImportProfile, "WHERE class=:c ORDER BY profile")
34  ->bind(":c", $class)
35  ->execute();
36 
37  if (count($profiles) && !$profile_id)
38  {
39  $profile_id = $profiles[0]->import_profile_id;
40  }
41 
42  $_SESSION["import_profile_id"] = $profile_id;
43 }
44 else
45 {
46  $profile_id = 0;
47 }
48 
49 
52 
53 $options = array_combine($columns, $columns);
54 
56 $form = new AutoForm($mapping);
57 $form->hide("class", "import_profile_id");
58 $columnSelect = new ChecklistFieldRenderer($form, "import_column", "Import Column", $options);
59 $columnSelect->setSize(250, 200);
60 $columnSelect->dropdown = true;
61 $columnSelect->dropdownMessage = "Click to Select Columns";
62 
63 $form->readonly("client_field");
64 $form->getRenderer("client_field")->template = "prettify";
65 
66 $spreadsheet = new SpreadsheetForm($form, $fieldMappings, 0, "POST", "", "", array(FieldMappingHelper, onItemRow));
67 $spreadsheet->formCSS = "list spreadsheet small";
68 
69 $spreadsheet->submitLabel = "Save Field Mapping";
70 $spreadsheet->button("Clear Field Mapping", "/action/data_sync/clear_mapping?import_profile_id={$profile_id}");
71 
73 
74 if ($method == "POST")
75 {
76  if ($spreadsheet->save())
77  {
78  $_SESSION["import_profile_id"] = $profile_id;
79  $tabs->next();
80  }
81 }
82 
83 $script .= $spreadsheet->writeScript();
84 
85 if ($multiProfile)
86 {
87  if (!$profile_id) $profile_id = 0;
88 
89  $script .= <<<ENDSCRIPT
90  <script type="text/javascript" src="/components/data_sync/js/data_sync_profile_manager.js"></script>
91  <script type="text/javascript">
92 
93  var importProfileManager;
94 
95 
96  window.addEvent('load', function()
97  {
98  importProfileManager = new DataImportProfileManager("{$class}", {$profile_id});
99  });
100  </script>
101 ENDSCRIPT;
102 }
103 
104 $tabs->writeHTML();
105 ?>
106 <div class="tab_border">
107 <?
108 
109 if ($multiProfile)
110 {
111 ?>
112 <label for="import_profile_id">Select Import Profile: </label><select name="import_profile_id" onchange='go("?import_profile_id=" + this.value);'>
113 <?
114 foreach($profiles as $profile)
115 {
116  option($profile->import_profile_id, $profile->profile, $profile_id);
117 }
118 ?>
119 </select>&nbsp;<a href='#' class='button' onclick='importProfileManager.createProfileDialog(); return false;'>Create New Profile</a>
120 <br/>
121 <br/>
122 <?
123 }
124 $spreadsheet->drawForm();
125 ?>
126 </div>
& nbsp
Definition: index.inc:49
if($method=="POST") $script
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
$_SESSION["useMobile"]
Definition: override.inc:7