protected function btnNext_Click() { $blnError = false; if ($this->intStep == 1) { if ($this->chkHeaderRow->Checked) { $this->blnHeaderRow = true; } else { $this->blnHeaderRow = false; } // Check errors if ($this->lstFieldSeparator->SelectedValue == 'other' && !$this->txtFieldSeparator->Text) { $this->flcFileCsv->Warning = "Please enter the field separator."; $blnError = true; } elseif ($this->lstTextDelimiter->SelectedValue == 'other' && !$this->txtTextDelimiter->Text) { $this->flcFileCsv->Warning = "Please enter the text delimiter."; $blnError = true; } else { // Step 1 complete // File Not Uploaded if (!file_exists($this->flcFileCsv->File) || !$this->flcFileCsv->Size) { //throw new QCallerException('FileAssetType must be a valid QFileAssetType constant value'); $this->flcFileCsv->Warning = 'The file could not be uploaded. Please provide a valid file.'; $blnError = true; // File Has Incorrect MIME Type (only if an acceptiblemimearray is setup) } elseif (is_array($this->strAcceptibleMimeArray) && !array_key_exists($this->flcFileCsv->Type, $this->strAcceptibleMimeArray)) { $this->flcFileCsv->Warning = "Extension must be 'csv' or 'txt'"; $blnError = true; // File Successfully Uploaded } else { $this->flcFileCsv->Warning = ""; // Setup Filename, Base Filename and Extension $strFilename = $this->flcFileCsv->FileName; $intPosition = strrpos($strFilename, '.'); } if (!$blnError) { $this->FileCsvData = new File_CSV_DataSource(); // Setup the settings which have got on step 1 $this->FileCsvData->settings($this->GetCsvSettings()); $file = fopen($this->flcFileCsv->File, "r"); // Counter of files $i = 1; // Counter of rows $j = 1; $this->strFilePathArray = array(); // The uploaded file splits up in order to avoid out of memory while ($row = fgets($file, 1000)) { if ($j == 1) { $strFilePath = sprintf('%s/%s_man_%s.csv', __TRACMOR_TMP__, $_SESSION['intUserAccountId'], $i); $this->strFilePathArray[] = $strFilePath; $file_part = fopen($strFilePath, "w+"); if ($i == 1) { if ($this->blnHeaderRow) { $strHeaderRow = $row; } else { // Add empty row which would be as header row $strHeaderRow = "\n"; fwrite($file_part, $strHeaderRow); } } else { fwrite($file_part, $strHeaderRow); } } fwrite($file_part, $row); $j++; if ($j > 200) { $j = 1; $i++; fclose($file_part); } } $this->intTotalCount = ($i - 1) * 200 + $j - 1; $this->arrMapFields = array(); $this->arrTracmorField = array(); // Load first file $this->FileCsvData->load($this->strFilePathArray[0]); $file_skipped = fopen($this->strFilePath = sprintf('%s/%s_manufacturer_skipped.csv', __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "w+"); // Get Headers if ($this->blnHeaderRow) { $this->arrCsvHeader = $this->FileCsvData->getHeaders(); // Create the header row in the skipped error file $this->PutSkippedRecordInFile($file_skipped, $this->arrCsvHeader); } /*else { // If it is not first file $this->FileCsvData->appendRow($this->FileCsvData->getHeaders()); }*/ $strFirstRowArray = $this->FileCsvData->getRow(0); for ($i = 0; $i < count($strFirstRowArray); $i++) { $this->arrMapFields[$i] = array(); if ($this->blnHeaderRow && array_key_exists($i, $this->arrCsvHeader)) { if ($this->arrCsvHeader[$i] == '') { $this->arrCsvHeader[$i] = ' '; } $this->lstMapHeader_Create($this, $i, $this->arrCsvHeader[$i]); $this->arrMapFields[$i]['header'] = $this->arrCsvHeader[$i]; } else { $this->lstMapHeader_Create($this, $i); } // Create Default Value TextBox, ListBox and DateTimePicker if ($this->blnHeaderRow && array_key_exists($i, $this->arrCsvHeader) && $this->arrCsvHeader[$i] || !$this->blnHeaderRow) { $txtDefaultValue = new QTextBox($this); $txtDefaultValue->Width = 200; $this->txtMapDefaultValueArray[] = $txtDefaultValue; $lstDefaultValue = new QListBox($this); $lstDefaultValue->Width = 200; $lstDefaultValue->Display = false; $this->lstMapDefaultValueArray[] = $lstDefaultValue; $dtpDate = new QDateTimePicker($this); $dtpDate->DateTimePickerType = QDateTimePickerType::Date; $dtpDate->DateTimePickerFormat = QDateTimePickerFormat::MonthDayYear; $dtpDate->Display = false; $this->dtpDateArray[] = $dtpDate; if (array_key_exists($i, $this->lstMapHeaderArray)) { $this->lstTramorField_Change(null, $this->lstMapHeaderArray[$i]->ControlId, null); } } $this->arrMapFields[$i]['row1'] = $strFirstRowArray[$i]; } $this->btnNext->Text = "Import Now"; fclose($file_skipped); // Create Add Field button $btnAddField = new QButton($this); $btnAddField->Text = "Add Field"; $btnAddField->AddAction(new QClickEvent(), new QServerAction('btnAddField_Click')); $btnAddField->AddAction(new QEnterKeyEvent(), new QServerAction('btnAddField_Click')); $btnAddField->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->lstMapHeaderArray[] = $btnAddField; } } } elseif ($this->intStep == 2) { // Step 2 complete $blnError = false; /*$blnLocation = false; */ $blnManufacturer = false; $blnManufacturerId = false; //$blnManufacturer = false; for ($i = 0; $i < count($this->lstMapHeaderArray) - 1; $i++) { $lstMapHeader = $this->lstMapHeaderArray[$i]; $strSelectedValue = strtolower($lstMapHeader->SelectedValue); /*if ($strSelectedValue == "location") { $blnLocation = true; } elseif ($strSelectedValue == "asset code") { $blnAssetCode = true; } elseif ($strSelectedValue == "asset model short description") { $blnAssetModelShortDescription = true; } elseif ($strSelectedValue == "asset model code") { $blnAssetModelCode = true; } else*/ if ($strSelectedValue == "manufacturer name") { $blnManufacturer = true; } elseif ($strSelectedValue == "id") { $blnManufacturerId = true; } /*elseif ($strSelectedValue == "manufacturer") { $blnManufacturer = true; }*/ } if ($this->lstMapDefaultValueArray) { // Checking errors for required Default Value text fields foreach ($this->lstMapDefaultValueArray as $lstDefault) { if ($lstDefault->Display && $lstDefault->Required && !$lstDefault->SelectedValue) { $lstDefault->Warning = "You must select one default value."; $blnError = true; break; } else { $blnError = false; $lstDefault->Warning = ""; } } } if ($this->txtMapDefaultValueArray) { // Checking errors for required Default Value lst fields foreach ($this->txtMapDefaultValueArray as $txtDefault) { if ($txtDefault->Display && $txtDefault->Required && !$txtDefault->Text) { $txtDefault->Warning = "You must enter default value."; break; } else { $blnError = false; $txtDefault->Warning = ""; } } } // If all required fields have no errors if (!$blnError && $blnManufacturer && ($this->lstImportAction->SelectedValue != 2 || $blnManufacturerId)) { $this->btnNext->Warning = ""; // Setup keys for main required fields foreach ($this->arrTracmorField as $key => $value) { if ($value == 'manufacturer name') { $this->intManufacturerKey = $key; } elseif ($value == 'manufacturer description') { $this->intManufacturerDescriptionKey = $key; } elseif ($this->lstImportAction->SelectedValue == 2 && $value == 'id') { $this->intItemIdKey = $key; } } $this->objNewManufacturerArray = array(); $this->blnImportEnd = false; $j = 1; $this->btnNext->RemoveAllActions('onclick'); // Add new ajax actions for button $this->btnNext->AddAction(new QClickEvent(), new QAjaxAction('btnNext_Click')); $this->btnNext->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnNext)); $this->btnNext->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnNext_Click')); $this->btnNext->AddAction(new QEnterKeyEvent(), new QToggleEnableAction($this->btnNext)); $this->btnNext->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->btnNext->Warning = "Please wait..."; $this->intImportStep = 2; $this->intCurrentFile = 0; $this->strSelectedValueArray = array(); // New manufacturers $this->dtgManufacturer = new QDataGrid($this); $this->dtgManufacturer->Name = 'manufacturer_list'; $this->dtgManufacturer->CellPadding = 5; $this->dtgManufacturer->CellSpacing = 0; $this->dtgManufacturer->CssClass = "datagrid"; $this->dtgManufacturer->UseAjax = true; $this->dtgManufacturer->ShowColumnToggle = false; $this->dtgManufacturer->ShowExportCsv = false; $this->dtgManufacturer->ShowHeader = false; $this->dtgManufacturer->AddColumn(new QDataGridColumnExt('Manufacturer', '<?= $_ITEM ?>', 'CssClass="dtg_column"', 'HtmlEntities="false"')); // Updated categories $this->dtgUpdatedItems = new QDataGrid($this); $this->dtgUpdatedItems->Name = 'updated_manufacturer_list'; $this->dtgUpdatedItems->CellPadding = 5; $this->dtgUpdatedItems->CellSpacing = 0; $this->dtgUpdatedItems->CssClass = "datagrid"; $this->dtgUpdatedItems->UseAjax = true; $this->dtgUpdatedItems->ShowColumnToggle = false; $this->dtgUpdatedItems->ShowExportCsv = false; $this->dtgUpdatedItems->ShowHeader = false; $this->dtgUpdatedItems->AddColumn(new QDataGridColumnExt('manufacturer name', '<?= $_ITEM ?>', 'CssClass="dtg_column"', 'HtmlEntities="false"')); // Create the label for successful import $this->lblImportSuccess = new QLabel($this); $this->lblImportSuccess->HtmlEntities = false; $this->lblImportSuccess->Display = false; // Undo Last Import button $this->btnUndoLastImport = new QButton($this); $this->btnUndoLastImport->Text = "Undo Last Import"; $this->btnUndoLastImport->Display = false; $this->btnUndoLastImport->AddAction(new QClickEvent(), new QServerAction('btnCancel_Click')); $this->btnUndoLastImport->AddAction(new QEnterKeyEvent(), new QServerAction('btnCancel_Click')); $this->btnUndoLastImport->AddAction(new QEnterKeyEvent(), new QTerminateAction()); // Import More button $this->btnImportMore = new QButton($this); $this->btnImportMore->Text = "Import More"; $this->btnImportMore->Display = false; $this->btnImportMore->AddAction(new QClickEvent(), new QServerAction('btnImportMore_Click')); $this->btnImportMore->AddAction(new QEnterKeyEvent(), new QServerAction('btnImportMore_Click')); $this->btnImportMore->AddAction(new QEnterKeyEvent(), new QTerminateAction()); // Return to Assets button $this->btnReturnTo = new QButton($this); $this->btnReturnTo->Text = "Return to Manufacturers"; $this->btnReturnTo->Display = false; $this->btnReturnTo->AddAction(new QClickEvent(), new QServerAction('btnReturnTo_Click')); $this->btnReturnTo->AddAction(new QEnterKeyEvent(), new QServerAction('btnReturnTo_Click')); $this->btnReturnTo->AddAction(new QEnterKeyEvent(), new QTerminateAction()); } else { $this->btnNext->Warning = "You must select all required fields."; $blnError = true; } } else { // Step 3 complete set_time_limit(0); $file_skipped = fopen($strFilePath = sprintf('%s/%s_manufacturer_skipped.csv', __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "a"); if (!$this->blnImportEnd) { if ($this->intImportStep == 2) { $strManufacturerArray = array(); $this->objNewManufacturerArray = array(); // Load all manufacturers foreach (Manufacturer::LoadAll() as $objManufacturer) { $strManufacturerArray[] = stripslashes($objManufacturer->ShortDescription); } $txtDefaultValue = trim($this->txtMapDefaultValueArray[$this->intManufacturerKey]->Text); // Add Default Value if ($txtDefaultValue && !$this->in_array_nocase($txtDefaultValue, $strManufacturerArray)) { $strManufacturerArray[] = $txtDefaultValue; $objNewManufacturer = new Manufacturer(); $objNewManufacturer->ShortDescription = addslashes($txtDefaultValue); $objNewManufacturer->Save(); $this->objNewManufacturerArray[$objNewManufacturer->ManufacturerId] = $objNewManufacturer->ShortDescription; } $this->btnNext->Warning = "Manufacturers have been imported. Please wait..."; } for ($j = $this->intCurrentFile; $j < count($this->strFilePathArray); $j++) { $this->FileCsvData->load($this->strFilePathArray[$j]); if (!$j) { //$this->FileCsvData->appendRow($this->FileCsvData->getHeaders()); } // Manufacturer Import if ($this->intImportStep == 2) { $arrItemCustomField = array(); foreach ($this->arrTracmorField as $key => $value) { if (substr($value, 0, 13) == 'manufacturer_') { $intItemCustomFieldKeyArray[substr($value, 13)] = $key; if (array_key_exists(substr($value, 13), $this->arrItemCustomField)) { $arrItemCustomField[substr($value, 13)] = $this->arrItemCustomField[substr($value, 13)]; } } } $strManufacturerValuesArray = array(); $strUpdatedManufacturerValuesArray = array(); $strItemCFVArray = array(); $strUpdatedItemCFVArray = array(); $strNewManufacturerArray = array(); $intManufacturerArray = array(); $this->arrOldItemArray = array(); $this->objUpdatedItemArray = array(); $objManufacturerArray = array(); foreach (Manufacturer::LoadAllWithCustomFieldsHelper() as $objManufacturer) { $objManufacturerArray[strtolower($objManufacturer->ShortDescription)] = $objManufacturer; } for ($i = 0; $i < $this->FileCsvData->countRows(); $i++) { $strRowArray = $this->FileCsvData->getRow($i); $objManufacturer = null; if ($this->lstImportAction->SelectedValue == 2) { $intItemId = intval(trim($strRowArray[$this->intItemIdKey])); foreach ($objManufacturerArray as $objItem) { if ($objItem->ManufacturerId == $intItemId) { $objManufacturer = $objItem; break; } } } else { $intItemId = 0; } // Create action if (trim($strRowArray[$this->intManufacturerKey]) && (!$intItemId || !$objManufacturer) && !$this->in_array_nocase(trim($strRowArray[$this->intManufacturerKey]), $strManufacturerArray)) { $strManufacturerArray[] = trim($strRowArray[$this->intManufacturerKey]); $strManufacturerDescription = ""; if (isset($this->intManufacturerDescriptionKey)) { if (trim($strRowArray[$this->intManufacturerDescriptionKey])) { $strManufacturerDescription = trim($strRowArray[$this->intManufacturerDescriptionKey]); } else { $strManufacturerDescription = isset($this->txtMapDefaultValueArray[$this->intManufacturerDescriptionKey]) ? trim($this->txtMapDefaultValueArray[$this->intManufacturerDescriptionKey]->Text) : ''; } } $strCFVArray = array(); $blnCheckCFVError = false; // Custom Field import foreach ($arrItemCustomField as $objCustomField) { if ($objCustomField->CustomFieldQtypeId != 2) { $strShortDescription = trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]) ? addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])) : addslashes($this->txtMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->Text); $strCFVArray[$objCustomField->CustomFieldId] = $strShortDescription ? sprintf("'%s'", $strShortDescription) : "NULL"; } else { $objDatabase = CustomField::GetDatabase(); $strShortDescription = addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])); $blnInList = false; foreach (CustomFieldValue::LoadArrayByCustomFieldId($objCustomField->CustomFieldId) as $objCustomFieldValue) { if (strtolower($objCustomFieldValue->ShortDescription) == strtolower($strShortDescription)) { $blnInList = true; break; } } // Add the CustomFieldValue /*if (!$blnInList && !in_array($strShortDescription, $strAddedCFVArray)) { $strQuery = sprintf("INSERT INTO custom_field_value (custom_field_id, short_description, created_by, creation_date) VALUES (%s, '%s', %s, NOW());", $objCustomField->CustomFieldId, $strShortDescription, $_SESSION['intUserAccountId']); $objDatabase->NonQuery($strQuery); $strAddedCFVArray[] = $strShortDescription; } else*/ if (!$blnInList && $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedValue != null) { $strShortDescription = $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedName; } elseif (!$blnInList) { $blnCheckCFVError = true; break; } if (!$blnCheckCFVError) { if ($strShortDescription) { $strCFVArray[$objCustomField->CustomFieldId] = sprintf("'%s'", $strShortDescription); } else { $strCFVArray[$objCustomField->CustomFieldId] = "NULL"; } } } } if (!$blnCheckCFVError) { if (isset($strCFVArray) && count($strCFVArray)) { $strItemCFVArray[] = implode(', ', $strCFVArray); } else { $strItemCFVArray[] = ""; } $strManufacturerValuesArray[] = sprintf("('%s', '%s', '%s', NOW())", addslashes(trim($strRowArray[$this->intManufacturerKey])), addslashes($strManufacturerDescription), $_SESSION['intUserAccountId']); $strNewManufacturerArray[] = addslashes(trim($strRowArray[$this->intManufacturerKey])); } } elseif (trim($strRowArray[$this->intManufacturerKey]) && $this->lstImportAction->SelectedValue == 2 && !$this->in_array_nocase(trim($strRowArray[$this->intManufacturerKey]), $this->objUpdatedItemArray) && $objManufacturer) { if (!$blnError) { $strManufacturerDescription = ""; if (isset($this->intManufacturerDescriptionKey)) { if (trim($strRowArray[$this->intManufacturerDescriptionKey])) { $strManufacturerDescription = trim($strRowArray[$this->intManufacturerDescriptionKey]); } else { $strManufacturerDescription = isset($this->txtMapDefaultValueArray[$this->intManufacturerDescriptionKey]) ? trim($this->txtMapDefaultValueArray[$this->intManufacturerDescriptionKey]->Text) : ''; } } $this->arrOldItemArray[$objManufacturer->ManufacturerId] = $objManufacturer; $blnCheckCFVError = false; foreach ($arrItemCustomField as $objCustomField) { if ($objCustomField->CustomFieldQtypeId != 2) { $strShortDescription = trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]) ? addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])) : addslashes($this->txtMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->Text); $strCFVArray[$objCustomField->CustomFieldId] = $strShortDescription ? sprintf("'%s'", $strShortDescription) : "NULL"; } else { $objDatabase = CustomField::GetDatabase(); $strShortDescription = addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])); $strCFVArray[$objCustomField->CustomFieldId] = $strShortDescription ? sprintf("'%s'", $strShortDescription) : "NULL"; $blnInList = false; foreach (CustomFieldValue::LoadArrayByCustomFieldId($objCustomField->CustomFieldId) as $objCustomFieldValue) { if (strtolower($objCustomFieldValue->ShortDescription) == strtolower($strShortDescription)) { //$intItemKeyntCustomFieldValueId = $objCustomFieldValue->CustomFieldValueId; $blnInList = true; break; } } // Add the CustomFieldValue /*if (!$blnInList && !in_array($strShortDescription, $strAddedCFVArray)) { $strQuery = sprintf("INSERT INTO custom_field_value (custom_field_id, short_description, created_by, creation_date) VALUES (%s, '%s', %s, NOW());", $objCustomField->CustomFieldId, $strShortDescription, $_SESSION['intUserAccountId']); $objDatabase->NonQuery($strQuery); $strAddedCFVArray[] = $strShortDescription; } else*/ if (!$blnInList && $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedValue != null) { $strShortDescription = $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedName; } elseif (!$blnInList) { $blnCheckCFVError = true; break; } if (!$blnCheckCFVError) { if ($strShortDescription) { $strCFVArray[$objCustomField->CustomFieldId] = sprintf("'%s'", $strShortDescription); } else { $strCFVArray[$objCustomField->CustomFieldId] = "NULL"; } } } } if (!$blnCheckCFVError) { if (isset($strCFVArray) && count($strCFVArray)) { $strUpdatedItemCFVArray[$objManufacturer->ManufacturerId] = $strCFVArray; } else { $strUpdatedItemCFVArray[$intItemId] = ""; } $strUpdatedManufacturerValuesArray[] = sprintf("UPDATE `manufacturer` SET `short_description`='%s', `long_description`='%s' WHERE `manufacturer_id`='%s'", addslashes(trim($strRowArray[$this->intManufacturerKey])), addslashes($strManufacturerDescription), $objManufacturer->ManufacturerId); $this->objUpdatedItemArray[$objManufacturer->ManufacturerId] = $objManufacturer->ShortDescription; } } else { $this->intSkippedRecordCount++; $this->PutSkippedRecordInFile($file_skipped, $strRowArray); } } else { $this->intSkippedRecordCount++; $this->PutSkippedRecordInFile($file_skipped, $strRowArray); } } if (count($strManufacturerValuesArray)) { $objDatabase = Manufacturer::GetDatabase(); $objDatabase->NonQuery(sprintf("INSERT INTO `manufacturer` (`short_description`, `long_description`, `created_by`, `creation_date`) VALUES %s;", implode(", ", $strManufacturerValuesArray))); $intStartId = $objDatabase->InsertId(); $strItemIdArray = array(); for ($i = 0; $i < count($strNewManufacturerArray); $i++) { $this->objNewManufacturerArray[$intStartId + $i] = $strNewManufacturerArray[$i]; $objDatabase = CustomField::GetDatabase(); $strItemCFVArray[$i] = sprintf("('%s', %s)", $intStartId + $i, $strItemCFVArray[$i]); $strItemIdArray[$i] = sprintf("(%s)", $intStartId + $i); } $strCFVNameArray = array(); foreach ($arrItemCustomField as $objCustomField) { $strCFVNameArray[] = sprintf("`cfv_%s`", $objCustomField->CustomFieldId); } if (count($strItemCFVArray) > 0 && count($strCFVNameArray) > 0) { $strQuery = sprintf("INSERT INTO `manufacturer_custom_field_helper` (`manufacturer_id`, %s) VALUES %s", implode(", ", $strCFVNameArray), implode(", ", $strItemCFVArray)); } else { $strQuery = sprintf("INSERT INTO `manufacturer_custom_field_helper` (`manufacturer_id`) VALUES %s", implode(", ", $strItemIdArray)); } $objDatabase->NonQuery($strQuery); } if (count($strUpdatedManufacturerValuesArray)) { $objDatabase = Manufacturer::GetDatabase(); foreach ($strUpdatedManufacturerValuesArray as $query) { $objDatabase->NonQuery($query); } foreach ($this->objUpdatedItemArray as $intItemKey => $objUpdatedItem) { if (isset($strUpdatedItemCFVArray[$intItemKey]) && count($strUpdatedItemCFVArray[$intItemKey])) { $strCFVArray = array(); foreach ($arrItemCustomField as $objCustomField) { $strCFVArray[] = sprintf("`cfv_%s`=%s", $objCustomField->CustomFieldId, $strUpdatedItemCFVArray[$intItemKey][$objCustomField->CustomFieldId]); } if (isset($strCFVArray) && count($strCFVArray)) { $strQuery = sprintf("UPDATE `manufacturer_custom_field_helper` SET %s WHERE `manufacturer_id`='%s'", implode(", ", $strCFVArray), $intItemKey); $objDatabase->NonQuery($strQuery); } } } } } } if ($this->intImportStep == 3) { /*if (count($this->strSelectedValueArray)) { $objDatabase = CustomField::GetDatabase(); $strQuery = sprintf("INSERT INTO `custom_field_selection` " . "(`entity_id`,`entity_qtype_id`, `custom_field_value_id`) " . "VALUES %s;", implode(", ", $this->strSelectedValueArray)); $objDatabase->NonQuery($strQuery); }*/ $this->blnImportEnd = true; $this->btnNext->Warning = ""; $this->lblImportResults->Display = true; if (count($this->objUpdatedItemArray)) { $this->lblImportUpdatedItems->Display = true; $this->dtgUpdatedItems->Paginator = new QPaginator($this->dtgUpdatedItems); $this->dtgUpdatedItems->ItemsPerPage = 20; } if (count($this->objNewManufacturerArray)) { $this->lblImportManufacturers->Display = true; $this->dtgManufacturer->Paginator = new QPaginator($this->dtgManufacturer); $this->dtgManufacturer->ItemsPerPage = 20; } /*if (count($this->objNewLocationArray)) { $this->lblImportLocations->Display = true; $this->dtgLocation->Paginator = new QPaginator($this->dtgLocation); $this->dtgLocation->ItemsPerPage = 20; }*/ $this->btnNext->Display = false; $this->btnCancel->Display = false; $this->btnUndoLastImport->Display = true; $this->btnImportMore->Display = true; $this->btnReturnTo->Display = true; $this->lblImportSuccess->Display = true; $this->lblImportSuccess->Text = sprintf("Success:<br/>" . "<b>%s</b> Records imported successfully<br/>" . "<b>%s</b> Records skipped due to error<br/>", count($this->objNewManufacturerArray) + count($this->objUpdatedItemArray), $this->intSkippedRecordCount); if ($this->intSkippedRecordCount) { $this->lblImportSuccess->Text .= sprintf("<a href='./manufacturer_import.php?intDownloadCsv=1'>Click here to download records that could not be imported</a>"); } $this->lblImportSuccess->Text .= "<br/><br/>"; $this->intImportStep = -1; } // Enable Next button $this->btnNext->Enabled = true; if (!$this->blnImportEnd && !$this->intCurrentFile) { $this->intImportStep++; } } fclose($file_skipped); } if (!$blnError) { if (($this->blnImportEnd || $this->intImportStep == 2) && $this->intImportStep != -1) { $this->intStep++; $this->DisplayStepForm($this->intStep); } if (!$this->blnImportEnd) { QApplication::ExecuteJavaScript("document.getElementById('" . $this->btnNext->ControlId . "').click();"); } if (!($this->intCurrentFile < count($this->strFilePathArray))) { $this->intCurrentFile = 0; $this->intImportStep++; } } }
protected function dtgManufacturer_Bind() { $objExpansionMap[Manufacturer::ExpandCreatedByObject] = true; // Get Total Count b/c of Pagination $this->dtgManufacturer->TotalItemCount = Manufacturer::CountAll(); if ($this->dtgManufacturer->TotalItemCount == 0) { $this->dtgManufacturer->ShowHeader = false; } else { /* $objClauses = array(); if ($objClause = $this->dtgManufacturer->OrderByClause) array_push($objClauses, $objClause); if ($objClause = $this->dtgManufacturer->LimitClause) array_push($objClauses, $objClause); if ($objClause = QQ::Expand(QQN::Manufacturer()->CreatedByObject)) array_push($objClauses, $objClause); $this->dtgManufacturer->DataSource = Manufacturer::LoadAll($objClauses); $this->dtgManufacturer->ShowHeader = true;*/ $this->dtgManufacturer->DataSource = Manufacturer::LoadAllWithCustomFieldsHelper($this->dtgManufacturer->SortInfo, $this->dtgManufacturer->LimitInfo, $objExpansionMap); $this->dtgManufacturer->ShowHeader = true; } }