diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 23159a259..af1564bd8 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -553,6 +553,7 @@ class BulkChange $aResult[$iRow]["finalclass"] = get_class($oTargetObj); $aResult[$iRow]["id"] = new CellStatus_Void(0); } + return $oTargetObj; } protected function UpdateObject(&$aResult, $iRow, $oTargetObj, $aRowData, CMDBChange $oChange = null) @@ -724,8 +725,9 @@ class BulkChange switch($oReconciliationSet->Count()) { case 0: - $this->CreateObject($aResult, $iRow, $aRowData, $oChange); + $oTargetObj = $this->CreateObject($aResult, $iRow, $aRowData, $oChange); // $aResult[$iRow]["__STATUS__"]=> set in CreateObject + $aVisited[] = $oTargetObj->GetKey(); break; case 1: $oTargetObj = $oReconciliationSet->Fetch(); diff --git a/css/light-grey.css b/css/light-grey.css index 7dde5723d..df86f5135 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -899,4 +899,13 @@ a.truncated { span.form_validation { width:24px; text-align:center; -} \ No newline at end of file +} +.notification { + border: 1px solid #c33; + background-color: #fee; + padding: 0.5em; + margin: 0.5em; + text-align:center; + width: 95%; + -moz-border-radius: 0.5em; +} \ No newline at end of file diff --git a/pages/csvimport.php b/pages/csvimport.php index 404088b80..92a7409fd 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -213,6 +213,18 @@ try return array('separator' => $sSeparator, 'qualifier' => $sQualifier); } + /** + * Display a banner for the special "synchro" mode + * @param WebPage $oP The Page for the output + * @param string $sClass The class of objects to synchronize + * @param integer $iCount The number of objects to synchronize + * @return none + */ + function DisplaySynchroBanner(WebPage $oP, $sClass, $iCount) + { + $oP->add("

".MetaModel::GetClassIcon($sClass)." ".Dict::Format('UI:Title:BulkSynchro_nbItem_ofClass_class', $iCount, MetaModel::GetName($sClass))."

\n"); + } + /** * Process the CSV data, for real or as a simulation * @param WebPage $oPage The page used to display the wizard @@ -234,7 +246,24 @@ try $iCurrentStep = $bSimulate ? 4 : 5; $bAdvanced = utils::ReadParam('advanced', 0); $sEncoding = utils::ReadParam('encoding', 'UTF-8'); - + $sSynchroScope = utils::ReadParam('synchro_scope', ''); + if (!empty($sSynchroScope)) + { + $oSearch = DBObjectSearch::FromOQL($sSynchroScope); + $sClassName = $oSearch->GetClass(); // If a synchronization scope is set, then the class is fixed ! + $oSet = new DBObjectSet($oSearch); + $iCount = $oSet->Count(); + $sSynchroClass = 'Server'; + DisplaySynchroBanner($oPage, $sSynchroClass, $iCount); + $sClassesSelect = "'); $oPage->add(''); $oPage->add(''); + $oPage->add(''); + if (!empty($sSynchroScope)) + { + foreach($aSynchroUpdate as $sKey => $value) + { + $oPage->add(''); + } + } foreach($aFieldsMapping as $iNumber => $sAttCode) { $oPage->add(''); @@ -641,10 +675,27 @@ EOF $bAdvanced = utils::ReadParam('advanced', 0); $sEncoding = utils::ReadParam('encoding', 'UTF-8'); + $sSynchroScope = utils::ReadParam('synchro_scope', ''); + if (!empty($sSynchroScope)) + { + $oSearch = DBObjectSearch::FromOQL($sSynchroScope); + $sClassName = $oSearch->GetClass(); // If a synchronization scope is set, then the class is fixed ! + $oSet = new DBObjectSet($oSearch); + $iCount = $oSet->Count(); + $sSynchroClass = 'Server'; + DisplaySynchroBanner($oPage, $sSynchroClass, $iCount); + $sClassesSelect = " '.Dict::S('UI:CSVImport:AdvancedMode').''); $oPage->add(''); $oPage->add('

'.Dict::S('UI:CSVImport:SelectAClassFirst').'

'); @@ -657,6 +708,14 @@ EOF $oPage->add(''); $oPage->add(''); $oPage->add(''); + $oPage->add(''); + if (!empty($sSynchroScope)) + { + foreach($aSynchroUpdate as $sKey => $value) + { + $oPage->add(''); + } + } $oPage->add('

  '); $oPage->add('

'); $oPage->add(''); @@ -915,6 +974,18 @@ EOF $iMaxLines--; } $sCSVDataTruncated = substr($sUTF8Data, 0, $iCurPos); + + $sSynchroScope = utils::ReadParam('synchro_scope', ''); + if (!empty($sSynchroScope)) + { + $oSearch = DBObjectSearch::FromOQL($sSynchroScope); + $sSynchroClass = $oSearch->GetClass(); + $oSet = new DBObjectSet($oSearch); + $iCount = $oSet->Count(); + $sSynchroClass = 'Server'; + DisplaySynchroBanner($oPage, $sSynchroClass, $iCount); + $aSynchroUpdate = utils::ReadParam('synchro_update', array()); + } $oPage->add('

'.Dict::S('UI:Title:CSVImportStep2').'

'); $oPage->add('
'); @@ -941,7 +1012,15 @@ EOF $oPage->add(''); $oPage->add(''); $oPage->add(''); + $oPage->add(''); $oPage->add(''); + if (!empty($sSynchroScope)) + { + foreach($aSynchroUpdate as $sKey => $value) + { + $oPage->add(''); + } + } $oPage->add('
'); $oPage->add('

'.Dict::S('UI:CSVImport:CSVDataPreview').'

'); $oPage->add('
'); @@ -1033,6 +1112,22 @@ EOF $aPossibleEncodings = array_merge($aPossibleEncodings, $aExtraCharsets); asort($aPossibleEncodings); + $sSynchroScope = utils::ReadParam('synchro_scope', ''); + if (!empty($sSynchroScope)) + { + $oSearch = DBObjectSearch::FromOQL($sSynchroScope); + $sSynchroClass = $oSearch->GetClass(); + $oSet = new DBObjectSet($oSearch); + $iCount = $oSet->Count(); + $sSynchroClass = 'Server'; + DisplaySynchroBanner($oPage, $sSynchroClass, $iCount); + $aSynchroUpdate = utils::ReadParam('synchro_update', array()); + } + else + { + $aSynchroUpdate = null; + } + $oPage->add("

".Dict::S('UI:Title:BulkImport+')."

\n"); $oPage->AddTabContainer('tabs1'); @@ -1066,7 +1161,15 @@ EOF ''. ''. ''. - '
'; + ''; + if (!empty($sSynchroScope)) + { + foreach($aSynchroUpdate as $sKey => $value) + { + $sFileLoadHtml .= ''; + } + } + $sFileLoadHtml .= ''; $oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:LoadFromFile'), $sFileLoadHtml); $sCSVData = utils::ReadParam('csvdata', ''); @@ -1093,7 +1196,15 @@ EOF ''. ''. ''. - ''; + ''; + if (!empty($sSynchroScope)) + { + foreach($aSynchroUpdate as $sKey => $value) + { + $sPasteDataHtml .= ''; + } + } + $sPasteDataHtml .= ''; $oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:CopyPaste'), $sPasteDataHtml); if (!empty($sCSVData))