public function __construct($objParentObject, $strClosePanelMethod, $arrayShipmentId) { try { parent::__construct($objParentObject); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); $this->arrShipmentToEdit = $arrayShipmentId; $this->chkShipDate_Create(); $this->chkCourier_Create(); $this->chkToCompany_Create(); $this->chkFromCompany_Create(); $this->chkNote_Create(); $this->calShipDate_Create(); $this->lstCourier_Create(); $this->lstToCompany_Create(); $this->lstToContact_Create(); $this->lstToAddress_Create(); $this->lstFromCompany_Create(); $this->lstFromContact_Create(); $this->lstFromAddress_Create(); $this->txtNote_Create(); $this->lblWarning_Create(); $this->btnApply_Create(); $this->btnCancel_Create(); // Disable inputs $this->calShipDate->Enabled = false; $this->lstToCompany->Enabled = false; $this->lstToContact->Enabled = false; $this->lstToAddress->Enabled = false; $this->lstFromCompany->Enabled = false; $this->lstFromAddress->Enabled = false; $this->lstFromContact->Enabled = false; $this->lstCourier->Enabled = false; $this->txtNote->Enabled = false; // Load Custom Fields $this->objCustomFieldArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Shipment, false); if ($this->objCustomFieldArray) { $this->arrCustomFields = CustomField::CustomFieldControlsCreate($this->objCustomFieldArray, false, $this, true, true, false); foreach ($this->arrCustomFields as $field) { $field['input']->Enabled = false; $this->arrCheckboxes[$field['input']->strControlId] = new QCheckBox($this, 'chk' . $field['input']->strControlId); $this->arrCheckboxes[$field['input']->strControlId]->Checked = false; $this->arrCheckboxes[$field['input']->strControlId]->AddAction(new QClickEvent(), new QJavaScriptAction("enableInput(this)")); } } }
protected function lstCompany_Create() { $this->lstCompany = new QListBox($this); $this->lstCompany->Name = QApplication::Translate('Company'); $this->lstCompany->Required = true; if (!$this->blnEditMode) { $this->lstCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if ($objCompany->CompanyId == $this->intCompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } }
protected function lstFromCompany_Create() { $this->lstFromCompany = new QListBox($this); $this->lstFromCompany->Name = QApplication::Translate('From Company'); $this->lstFromCompany->Required = true; if (!$this->blnEditMode) { $this->lstFromCompany->AddItem('- Select One -', null); } $objFromCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); if ($objFromCompanyArray) { foreach ($objFromCompanyArray as $objFromCompany) { $objListItem = new QListItem($objFromCompany->__toString(), $objFromCompany->CompanyId); if ($this->objReceipt->FromCompany && $this->objReceipt->FromCompany->CompanyId == $objFromCompany->CompanyId) { $objListItem->Selected = true; } $this->lstFromCompany->AddItem($objListItem); } } $this->lstFromCompany->AddAction(new QChangeEvent(), new QAjaxAction('lstFromCompany_Select')); $this->lstFromCompany->TabIndex = 1; $this->intNextTabIndex++; $this->lstFromCompany->Focus(); }
protected function dtgCompany_Bind() { // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll() // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgCompany->TotalItemCount = Company::CountAll(); // Setup the $objClauses Array $objClauses = array(); // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->dtgCompany->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgCompany->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all Company objects, given the clauses above $this->dtgCompany->DataSource = Company::LoadAll($objClauses); }
protected function lstToCompany_Create() { $this->lstToCompany = new QListBox($this); $this->lstToCompany->Name = QApplication::Translate('To Company'); $this->lstToCompany->Required = true; if (!$this->blnEditMode) { $this->lstToCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objToCompanyArray = Company::LoadAll(); if ($objToCompanyArray) { foreach ($objToCompanyArray as $objToCompany) { $objListItem = new QListItem($objToCompany->__toString(), $objToCompany->CompanyId); if ($this->objShipment->ToCompany && $this->objShipment->ToCompany->CompanyId == $objToCompany->CompanyId) { $objListItem->Selected = true; } $this->lstToCompany->AddItem($objListItem); } } }
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_con_%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; if (true && QApplication::$TracmorSettings->AssetLimit != null && QApplication::$TracmorSettings->AssetLimit < $this->intTotalCount + Asset::CountAll()) { $blnError = true; $this->btnNext->Warning = $i . " " . $j . "Sorry that is too many assets. Your asset limit is = " . QApplication::$TracmorSettings->AssetLimit . ", this import has " . $this->intTotalCount . " assets, and you already have " . Asset::CountAll() . " assets in the database."; } else { $this->arrMapFields = array(); $this->arrTracmorField = array(); // Load first file $this->FileCsvData->load($this->strFilePathArray[0]); $file_skipped = fopen($this->strFilePath = sprintf('%s/%s_contact_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; $blnCompany = false; $blnLastName = false; $blnContactId = false; $this->intCompanyArray = array(); foreach (Company::LoadAll() as $objCompany) { $this->intCompanyArray[strtolower($objCompany->ShortDescription)] = $objCompany->CompanyId; } for ($i = 0; $i < count($this->lstMapHeaderArray) - 1; $i++) { $lstMapHeader = $this->lstMapHeaderArray[$i]; $strSelectedValue = strtolower($lstMapHeader->SelectedValue); if ($strSelectedValue == "company") { $blnCompany = true; } if ($strSelectedValue == "last name") { $blnLastName = true; } elseif ($strSelectedValue == "id") { $blnContactId = 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 && $blnCompany && $blnLastName && ($this->lstImportAction->SelectedValue != 2 || $blnContactId)) { $this->btnNext->Warning = ""; // Setup keys for main required fields foreach ($this->arrTracmorField as $key => $value) { if ($value == 'company') { $this->intCompanyKey = $key; } elseif ($value == 'description') { $this->intDescriptionKey = $key; } elseif ($value == 'last name') { $this->intLastNameKey = $key; } elseif ($value == 'first name') { $this->intFirstNameKey = $key; } elseif ($value == 'title') { $this->intTitleKey = $key; } elseif ($value == 'email') { $this->intEmailKey = $key; } elseif ($value == 'office phone') { $this->intOfficePhoneKey = $key; } elseif ($value == 'home phone') { $this->intHomePhoneKey = $key; } elseif ($value == 'mobile phone') { $this->intMobilePhoneKey = $key; } elseif ($value == 'fax') { $this->intFaxKey = $key; } elseif ($this->lstImportAction->SelectedValue == 2 && $value == 'id') { $this->intItemIdKey = $key; } } $this->objNewContactArray = 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 categories $this->dtgContact = new QDataGrid($this); $this->dtgContact->Name = 'contact_list'; $this->dtgContact->CellPadding = 5; $this->dtgContact->CellSpacing = 0; $this->dtgContact->CssClass = "datagrid"; $this->dtgContact->UseAjax = true; $this->dtgContact->ShowColumnToggle = false; $this->dtgContact->ShowExportCsv = false; $this->dtgContact->ShowHeader = false; $this->dtgContact->AddColumn(new QDataGridColumnExt('Contact', '<?= $_ITEM ?>', 'CssClass="dtg_column"', 'HtmlEntities="false"')); // Updated categories $this->dtgUpdatedItems = new QDataGrid($this); $this->dtgUpdatedItems->Name = 'updated_contact_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('Contact 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 Contacts"; $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_contact_skipped.csv', __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "a"); if (!$this->blnImportEnd) { // Category if ($this->intImportStep == 2) { $strContactArray = array(); $this->objNewContactArray = array(); // Load all categories foreach (Contact::LoadAll() as $objContact) { $strContactArray[] = stripslashes(sprintf("%s %s", $objContact->LastName, $objContact->LastName)); } // Add Default value $txtDefaultValue = trim($this->txtMapDefaultValueArray[$this->intCompanyKey]->Text); /*if ($txtDefaultValue && !$this->in_array_nocase($txtDefaultValue, $strContactArray)) { $strContactArray[] = $txtDefaultValue; $objNewContact = new Contact(); $objNewContact->ShortDescription = addslashes($txtDefaultValue); $objNewContact->Save(); $this->objNewContactArray[$objNewContact->ContactId] = $objNewContact->ShortDescription; }*/ $this->btnNext->Warning = "Contacts 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()); } // Category Import if ($this->intImportStep == 2) { $arrItemCustomField = array(); foreach ($this->arrTracmorField as $key => $value) { if (substr($value, 0, 8) == 'contact_') { $intItemCustomFieldKeyArray[substr($value, 8)] = $key; if (array_key_exists(substr($value, 8), $this->arrItemCustomField)) { $arrItemCustomField[substr($value, 8)] = $this->arrItemCustomField[substr($value, 8)]; } } } $strContactValuesArray = array(); $strUpdatedContactValuesArray = array(); $strItemCFVArray = array(); $strUpdatedItemCFVArray = array(); $strNewContactArray = array(); $this->arrOldItemArray = array(); $this->objUpdatedItemArray = array(); $objContactArray = array(); $objExpansionMap[Contact::ExpandCompany] = true; $objExpansionMap[Contact::ExpandAddress] = true; foreach (Contact::LoadArrayBySearchHelper(null, null, null, null, null, null, null, null, null, null, $objExpansionMap) as $objContact) { $objContactArray[$objContact->ContactId] = $objContact; } for ($i = 0; $i < $this->FileCsvData->countRows(); $i++) { $strRowArray = $this->FileCsvData->getRow($i); $objContact = null; if ($this->lstImportAction->SelectedValue == 2) { $intItemId = intval(trim($strRowArray[$this->intItemIdKey])); foreach ($objContactArray as $objItem) { if ($objItem->ContactId == $intItemId) { $objContact = $objItem; break; } } } else { $intItemId = 0; } $strCompany = strtolower(trim($strRowArray[$this->intCompanyKey])); if ($strCompany && array_key_exists($strCompany, $this->intCompanyArray)) { $intCompanyId = $this->intCompanyArray[substr($strCompany, 0)]; } else { $intCompanyId = null; } // Create action if ($intCompanyId && trim($strRowArray[$this->intLastNameKey]) && (!$intItemId || !$objContact)) { $strContactArray[] = trim($strRowArray[$this->intLastNameKey]); $strDescription = ""; if (isset($this->intDescriptionKey)) { if (trim($strRowArray[$this->intDescriptionKey])) { $strDescription = trim($strRowArray[$this->intDescriptionKey]); } else { $strDescription = isset($this->txtMapDefaultValueArray[$this->intDescriptionKey]) ? trim($this->txtMapDefaultValueArray[$this->intDescriptionKey]->Text) : ''; } } $strLastName = ""; if (isset($this->intLastNameKey)) { if (trim($strRowArray[$this->intLastNameKey])) { $strLastName = trim($strRowArray[$this->intLastNameKey]); } else { $strLastName = isset($this->txtMapDefaultValueArray[$this->intLastNameKey]) ? trim($this->txtMapDefaultValueArray[$this->intLastNameKey]->Text) : ''; } } $strFirstName = ""; if (isset($this->intFirstNameKey)) { if (trim($strRowArray[$this->intFirstNameKey])) { $strFirstName = trim($strRowArray[$this->intFirstNameKey]); } else { $strFirstName = isset($this->txtMapDefaultValueArray[$this->intFirstNameKey]) ? trim($this->txtMapDefaultValueArray[$this->intFirstNameKey]->Text) : ''; } } $strEmail = ""; if (isset($this->intEmailKey)) { if (trim($strRowArray[$this->intEmailKey])) { $strEmail = trim($strRowArray[$this->intEmailKey]); } else { $strEmail = isset($this->txtMapDefaultValueArray[$this->intEmailKey]) ? trim($this->txtMapDefaultValueArray[$this->intEmailKey]->Text) : ''; } } $strOfficePhone = ""; if (isset($this->intOfficePhoneKey)) { if (trim($strRowArray[$this->intOfficePhoneKey])) { $strOfficePhone = trim($strRowArray[$this->intOfficePhoneKey]); } else { $strOfficePhone = isset($this->txtMapDefaultValueArray[$this->intOfficePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intOfficePhoneKey]->Text) : ''; } } $strHomePhone = ""; if (isset($this->intHomePhoneKey)) { if (trim($strRowArray[$this->intHomePhoneKey])) { $strHomePhone = trim($strRowArray[$this->intHomePhoneKey]); } else { $strHomePhone = isset($this->txtMapDefaultValueArray[$this->intHomePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intHomePhoneKey]->Text) : ''; } } $strMobilePhone = ""; if (isset($this->intMobilePhoneKey)) { if (trim($strRowArray[$this->intMobilePhoneKey])) { $strMobilePhone = trim($strRowArray[$this->intMobilePhoneKey]); } else { $strMobilePhone = isset($this->txtMapDefaultValueArray[$this->intMobilePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intMobilePhoneKey]->Text) : ''; } } $strFax = ""; if (isset($this->intFaxKey)) { if (trim($strRowArray[$this->intFaxKey])) { $strFax = trim($strRowArray[$this->intFaxKey]); } else { $strFax = isset($this->txtMapDefaultValueArray[$this->intFaxKey]) ? trim($this->txtMapDefaultValueArray[$this->intFaxKey]->Text) : ''; } } $strTitle = ""; if (isset($this->intTitleKey)) { if (trim($strRowArray[$this->intTitleKey])) { $strTitle = trim($strRowArray[$this->intTitleKey]); } else { $strTitle = isset($this->txtMapDefaultValueArray[$this->intTitleKey]) ? trim($this->txtMapDefaultValueArray[$this->intTitleKey]->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[] = ""; } $strContactValuesArray[] = sprintf("('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', NOW())", $intCompanyId, addslashes($strFirstName), addslashes($strLastName), addslashes($strTitle), addslashes($strEmail), addslashes($strDescription), addslashes($strOfficePhone), addslashes($strHomePhone), addslashes($strMobilePhone), addslashes($strFax), $_SESSION['intUserAccountId']); $strNewContactArray[] = addslashes(sprintf("%s %s", isset($this->intFirstNameKey) ? trim($strRowArray[$this->intFirstNameKey]) : "", trim($strRowArray[$this->intLastNameKey]))); } else { $this->intSkippedRecordCount++; $this->PutSkippedRecordInFile($file_skipped, $strRowArray); } } elseif ($intCompanyId && trim($strRowArray[$this->intLastNameKey]) && $this->lstImportAction->SelectedValue == 2 && $objContact) { if (!$blnError) { $strUpdateFieldArray = array(); //$objContact = $objContactArray[strtolower(trim($strRowArray[$this->intCompanyKey]))]; $strUpdateFieldArray[] = sprintf("`company_id`='%s'", addslashes($intCompanyId)); $strDescription = ""; if (isset($this->intDescriptionKey)) { if (trim($strRowArray[$this->intDescriptionKey])) { $strDescription = trim($strRowArray[$this->intDescriptionKey]); } else { $strDescription = isset($this->txtMapDefaultValueArray[$this->intDescriptionKey]) ? trim($this->txtMapDefaultValueArray[$this->intDescriptionKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`description`='%s'", addslashes($strDescription)); } $strLastName = ""; if (isset($this->intLastNameKey)) { if (trim($strRowArray[$this->intLastNameKey])) { $strLastName = trim($strRowArray[$this->intLastNameKey]); } else { $strLastName = isset($this->txtMapDefaultValueArray[$this->intLastNameKey]) ? trim($this->txtMapDefaultValueArray[$this->intLastNameKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`last_name`='%s'", addslashes($strLastName)); } $strFirstName = ""; if (isset($this->intFirstNameKey)) { if (trim($strRowArray[$this->intFirstNameKey])) { $strFirstName = trim($strRowArray[$this->intFirstNameKey]); } else { $strFirstName = isset($this->txtMapDefaultValueArray[$this->intFirstNameKey]) ? trim($this->txtMapDefaultValueArray[$this->intFirstNameKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`first_name`='%s'", addslashes($strFirstName)); } $strEmail = ""; if (isset($this->intEmailKey)) { if (trim($strRowArray[$this->intEmailKey])) { $strEmail = trim($strRowArray[$this->intEmailKey]); } else { $strEmail = isset($this->txtMapDefaultValueArray[$this->intEmailKey]) ? trim($this->txtMapDefaultValueArray[$this->intEmailKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`email`='%s'", addslashes($strEmail)); } $strOfficePhone = ""; if (isset($this->intOfficePhoneKey)) { if (trim($strRowArray[$this->intOfficePhoneKey])) { $strOfficePhone = trim($strRowArray[$this->intOfficePhoneKey]); } else { $strOfficePhone = isset($this->txtMapDefaultValueArray[$this->intOfficePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intOfficePhoneKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`phone_office`='%s'", addslashes($strOfficePhone)); } $strHomePhone = ""; if (isset($this->intHomePhoneKey)) { if (trim($strRowArray[$this->intHomePhoneKey])) { $strHomePhone = trim($strRowArray[$this->intHomePhoneKey]); } else { $strHomePhone = isset($this->txtMapDefaultValueArray[$this->intHomePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intHomePhoneKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`phone_home`='%s'", addslashes($strHomePhone)); } $strMobilePhone = ""; if (isset($this->intMobilePhoneKey)) { if (trim($strRowArray[$this->intMobilePhoneKey])) { $strMobilePhone = trim($strRowArray[$this->intMobilePhoneKey]); } else { $strMobilePhone = isset($this->txtMapDefaultValueArray[$this->intMobilePhoneKey]) ? trim($this->txtMapDefaultValueArray[$this->intMobilePhoneKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`phone_mobile`='%s'", addslashes($strMobilePhone)); } $strFax = ""; if (isset($this->intFaxKey)) { if (trim($strRowArray[$this->intFaxKey])) { $strFax = trim($strRowArray[$this->intFaxKey]); } else { $strFax = isset($this->txtMapDefaultValueArray[$this->intFaxKey]) ? trim($this->txtMapDefaultValueArray[$this->intFaxKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`fax`='%s'", addslashes($strFax)); } $strTitle = ""; if (isset($this->intTitleKey)) { if (trim($strRowArray[$this->intTitleKey])) { $strTitle = trim($strRowArray[$this->intTitleKey]); } else { $strTitle = isset($this->txtMapDefaultValueArray[$this->intTitleKey]) ? trim($this->txtMapDefaultValueArray[$this->intTitleKey]->Text) : ''; } $strUpdateFieldArray[] = sprintf("`title`='%s'", addslashes($strTitle)); } $strUpdateFieldArray[] = sprintf("modified_by='%s'", $_SESSION['intUserAccountId']); $this->arrOldItemArray[$objContact->ContactId] = $objContact; $blnCheckCFVError = false; foreach ($arrItemCustomField as $objCustomField) { //$objItem = $objContactArray[strtolower($objUpdatedItem)]; 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[$objContact->ContactId] = $strCFVArray; } else { $strUpdatedItemCFVArray[$objContact->ContactId] = ""; } $strUpdatedContactValuesArray[] = sprintf("UPDATE `contact` SET %s WHERE `contact_id`='%s'", implode(", ", $strUpdateFieldArray), $objContact->ContactId); $this->objUpdatedItemArray[$objContact->ContactId] = sprintf("%s %s", $objContact->FirstName, $objContact->LastName); } else { $this->intSkippedRecordCount++; $this->PutSkippedRecordInFile($file_skipped, $strRowArray); } } else { $this->intSkippedRecordCount++; $this->PutSkippedRecordInFile($file_skipped, $strRowArray); } } else { $this->intSkippedRecordCount++; $this->PutSkippedRecordInFile($file_skipped, $strRowArray); } } if (count($strContactValuesArray)) { $objDatabase = Contact::GetDatabase(); $objDatabase->NonQuery(sprintf("INSERT INTO `contact` (`company_id`, `first_name`, `last_name`, `title`, `email`, `description`, `phone_office`, `phone_home`, `phone_mobile`, `fax`, `created_by`, `creation_date`) VALUES %s;", implode(", ", $strContactValuesArray))); $intStartId = $objDatabase->InsertId(); $strItemIdArray = array(); for ($i = 0; $i < count($strNewContactArray); $i++) { $this->objNewContactArray[$intStartId + $i] = $strNewContactArray[$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 `contact_custom_field_helper` (`contact_id`, %s) VALUES %s", implode(", ", $strCFVNameArray), implode(", ", $strItemCFVArray)); } else { $strQuery = sprintf("INSERT INTO `contact_custom_field_helper` (`contact_id`) VALUES %s", implode(", ", $strItemIdArray)); } $objDatabase->NonQuery($strQuery); } if (count($strUpdatedContactValuesArray)) { $objDatabase = Category::GetDatabase(); foreach ($strUpdatedContactValuesArray 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 `contact_custom_field_helper` SET %s WHERE `contact_id`='%s'", implode(", ", $strCFVArray), $intItemKey); $objDatabase->NonQuery($strQuery); } } } } } } if ($this->intImportStep == 3) { $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->objNewContactArray)) { $this->lblImportContacts->Display = true; $this->dtgContact->Paginator = new QPaginator($this->dtgContact); $this->dtgContact->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->objNewContactArray) + count($this->objUpdatedItemArray), $this->intSkippedRecordCount); if ($this->intSkippedRecordCount) { $this->lblImportSuccess->Text .= sprintf("<a href='./contact_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++; } } }
/** * Refresh this MetaControl with Data from the local Shipment object. * @param boolean $blnReload reload Shipment from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objShipment->Reload(); } if ($this->lblShipmentId) { if ($this->blnEditMode) { $this->lblShipmentId->Text = $this->objShipment->ShipmentId; } } if ($this->txtShipmentNumber) { $this->txtShipmentNumber->Text = $this->objShipment->ShipmentNumber; } if ($this->lblShipmentNumber) { $this->lblShipmentNumber->Text = $this->objShipment->ShipmentNumber; } if ($this->lstTransaction) { $this->lstTransaction->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstTransaction->AddItem(QApplication::Translate('- Select One -'), null); } $objTransactionArray = Transaction::LoadAll(); if ($objTransactionArray) { foreach ($objTransactionArray as $objTransaction) { $objListItem = new QListItem($objTransaction->__toString(), $objTransaction->TransactionId); if ($this->objShipment->Transaction && $this->objShipment->Transaction->TransactionId == $objTransaction->TransactionId) { $objListItem->Selected = true; } $this->lstTransaction->AddItem($objListItem); } } } if ($this->lblTransactionId) { $this->lblTransactionId->Text = $this->objShipment->Transaction ? $this->objShipment->Transaction->__toString() : null; } if ($this->lstFromCompany) { $this->lstFromCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objFromCompanyArray = Company::LoadAll(); if ($objFromCompanyArray) { foreach ($objFromCompanyArray as $objFromCompany) { $objListItem = new QListItem($objFromCompany->__toString(), $objFromCompany->CompanyId); if ($this->objShipment->FromCompany && $this->objShipment->FromCompany->CompanyId == $objFromCompany->CompanyId) { $objListItem->Selected = true; } $this->lstFromCompany->AddItem($objListItem); } } } if ($this->lblFromCompanyId) { $this->lblFromCompanyId->Text = $this->objShipment->FromCompany ? $this->objShipment->FromCompany->__toString() : null; } if ($this->lstFromContact) { $this->lstFromContact->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromContact->AddItem(QApplication::Translate('- Select One -'), null); } $objFromContactArray = Contact::LoadAll(); if ($objFromContactArray) { foreach ($objFromContactArray as $objFromContact) { $objListItem = new QListItem($objFromContact->__toString(), $objFromContact->ContactId); if ($this->objShipment->FromContact && $this->objShipment->FromContact->ContactId == $objFromContact->ContactId) { $objListItem->Selected = true; } $this->lstFromContact->AddItem($objListItem); } } } if ($this->lblFromContactId) { $this->lblFromContactId->Text = $this->objShipment->FromContact ? $this->objShipment->FromContact->__toString() : null; } if ($this->lstFromAddress) { $this->lstFromAddress->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstFromAddress->AddItem(QApplication::Translate('- Select One -'), null); } $objFromAddressArray = Address::LoadAll(); if ($objFromAddressArray) { foreach ($objFromAddressArray as $objFromAddress) { $objListItem = new QListItem($objFromAddress->__toString(), $objFromAddress->AddressId); if ($this->objShipment->FromAddress && $this->objShipment->FromAddress->AddressId == $objFromAddress->AddressId) { $objListItem->Selected = true; } $this->lstFromAddress->AddItem($objListItem); } } } if ($this->lblFromAddressId) { $this->lblFromAddressId->Text = $this->objShipment->FromAddress ? $this->objShipment->FromAddress->__toString() : null; } if ($this->lstToCompany) { $this->lstToCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objToCompanyArray = Company::LoadAll(); if ($objToCompanyArray) { foreach ($objToCompanyArray as $objToCompany) { $objListItem = new QListItem($objToCompany->__toString(), $objToCompany->CompanyId); if ($this->objShipment->ToCompany && $this->objShipment->ToCompany->CompanyId == $objToCompany->CompanyId) { $objListItem->Selected = true; } $this->lstToCompany->AddItem($objListItem); } } } if ($this->lblToCompanyId) { $this->lblToCompanyId->Text = $this->objShipment->ToCompany ? $this->objShipment->ToCompany->__toString() : null; } if ($this->lstToContact) { $this->lstToContact->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToContact->AddItem(QApplication::Translate('- Select One -'), null); } $objToContactArray = Contact::LoadAll(); if ($objToContactArray) { foreach ($objToContactArray as $objToContact) { $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId); if ($this->objShipment->ToContact && $this->objShipment->ToContact->ContactId == $objToContact->ContactId) { $objListItem->Selected = true; } $this->lstToContact->AddItem($objListItem); } } } if ($this->lblToContactId) { $this->lblToContactId->Text = $this->objShipment->ToContact ? $this->objShipment->ToContact->__toString() : null; } if ($this->lstToAddress) { $this->lstToAddress->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstToAddress->AddItem(QApplication::Translate('- Select One -'), null); } $objToAddressArray = Address::LoadAll(); if ($objToAddressArray) { foreach ($objToAddressArray as $objToAddress) { $objListItem = new QListItem($objToAddress->__toString(), $objToAddress->AddressId); if ($this->objShipment->ToAddress && $this->objShipment->ToAddress->AddressId == $objToAddress->AddressId) { $objListItem->Selected = true; } $this->lstToAddress->AddItem($objListItem); } } } if ($this->lblToAddressId) { $this->lblToAddressId->Text = $this->objShipment->ToAddress ? $this->objShipment->ToAddress->__toString() : null; } if ($this->lstCourier) { $this->lstCourier->RemoveAllItems(); $this->lstCourier->AddItem(QApplication::Translate('- Select One -'), null); $objCourierArray = Courier::LoadAll(); if ($objCourierArray) { foreach ($objCourierArray as $objCourier) { $objListItem = new QListItem($objCourier->__toString(), $objCourier->CourierId); if ($this->objShipment->Courier && $this->objShipment->Courier->CourierId == $objCourier->CourierId) { $objListItem->Selected = true; } $this->lstCourier->AddItem($objListItem); } } } if ($this->lblCourierId) { $this->lblCourierId->Text = $this->objShipment->Courier ? $this->objShipment->Courier->__toString() : null; } if ($this->txtTrackingNumber) { $this->txtTrackingNumber->Text = $this->objShipment->TrackingNumber; } if ($this->lblTrackingNumber) { $this->lblTrackingNumber->Text = $this->objShipment->TrackingNumber; } if ($this->calShipDate) { $this->calShipDate->DateTime = $this->objShipment->ShipDate; } if ($this->lblShipDate) { $this->lblShipDate->Text = sprintf($this->objShipment->ShipDate) ? $this->objShipment->__toString($this->strShipDateDateTimeFormat) : null; } if ($this->chkShippedFlag) { $this->chkShippedFlag->Checked = $this->objShipment->ShippedFlag; } if ($this->lblShippedFlag) { $this->lblShippedFlag->Text = $this->objShipment->ShippedFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->lstCreatedByObject) { $this->lstCreatedByObject->RemoveAllItems(); $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objCreatedByObjectArray = UserAccount::LoadAll(); if ($objCreatedByObjectArray) { foreach ($objCreatedByObjectArray as $objCreatedByObject) { $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId); if ($this->objShipment->CreatedByObject && $this->objShipment->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objShipment->CreatedByObject ? $this->objShipment->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objShipment->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objShipment->CreationDate) ? $this->objShipment->__toString($this->strCreationDateDateTimeFormat) : null; } if ($this->lstModifiedByObject) { $this->lstModifiedByObject->RemoveAllItems(); $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objModifiedByObjectArray = UserAccount::LoadAll(); if ($objModifiedByObjectArray) { foreach ($objModifiedByObjectArray as $objModifiedByObject) { $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId); if ($this->objShipment->ModifiedByObject && $this->objShipment->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objShipment->ModifiedByObject ? $this->objShipment->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objShipment->ModifiedDate; } } if ($this->lstShipmentCustomFieldHelper) { $this->lstShipmentCustomFieldHelper->RemoveAllItems(); $this->lstShipmentCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objShipmentCustomFieldHelperArray = ShipmentCustomFieldHelper::LoadAll(); if ($objShipmentCustomFieldHelperArray) { foreach ($objShipmentCustomFieldHelperArray as $objShipmentCustomFieldHelper) { $objListItem = new QListItem($objShipmentCustomFieldHelper->__toString(), $objShipmentCustomFieldHelper->ShipmentId); if ($objShipmentCustomFieldHelper->ShipmentId == $this->objShipment->ShipmentId) { $objListItem->Selected = true; } $this->lstShipmentCustomFieldHelper->AddItem($objListItem); } } // Because ShipmentCustomFieldHelper's ShipmentCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstShipmentCustomFieldHelper->SelectedValue) { $this->lstShipmentCustomFieldHelper->Enabled = false; } else { $this->lstShipmentCustomFieldHelper->Enabled = true; } } if ($this->lblShipmentCustomFieldHelper) { $this->lblShipmentCustomFieldHelper->Text = $this->objShipment->ShipmentCustomFieldHelper ? $this->objShipment->ShipmentCustomFieldHelper->__toString() : null; } }
protected function Form_Create() { // check rigths for the Inventory to Ship $this->blnShowInventory = true; $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objUserAccount->RoleId, 3); if ($objRoleModule->AccessFlag) { $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, 2); if ($objRoleModuleAuthorization->AuthorizationLevelId == 3) { $this->blnShowInventory = false; } } else { $this->blnShowInventory = false; } // Call SetupShipment to either Load/Edit Existing or Create New $this->SetupShipment(); $this->objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); // Create the Header Menu $this->ctlHeaderMenu_Create(); // Create the Shortcut Menu $this->ctlShortcutMenu_Create(); // Packing List Link $this->lblPackingListLink_Create(); // Shipping Labels $this->lblShipmentNumber_Create(); $this->lblHeaderShipment_Create(); $this->lblShipDate_Create(); $this->lblFromCompany_Create(); $this->lblFromContact_Create(); $this->lblFromAddress_Create(); $this->lstToCompany_Create(); $this->lblNewToCompany_Create(); $this->lstToContact_Create(); $this->lblNewToContact_Create(); $this->lstToAddress_Create(); $this->lblNewToAddress_Create(); $this->lblFromAddressFull_Create(); $this->lblToCompany_Create(); $this->lblToContact_Create(); $this->lblToAddress_Create(); $this->lblToAddressFull_Create(); $this->lblCourier_Create(); $this->pnlNote_Create(); $this->lblTrackingNumber_Create(); // Shipping Inputs $this->dlgExchange_Create(); $this->dlgDueDate_Create(); $this->calShipDate_Create(); $this->lstFromCompany_Create(); $this->lblNewFromCompany_Create(); $this->lstFromContact_Create(); $this->lblNewFromContact_Create(); $this->lstFromAddress_Create(); $this->lblNewFromAddress_Create(); if (QApplication::$TracmorSettings->CustomShipmentNumbers) { $this->txtShipmentNumber_Create(); } $this->lstCourier_Create(); $this->txtNote_Create(); $this->txtNewAssetCode_Create(); if ($this->blnShowInventory) { $this->txtNewInventoryModelCode_Create(); $this->btnLookup_Create(); $this->ctlInventorySearchTool_Create(); $this->lstSourceLocation_Create(); $this->txtQuantity_Create(); $this->btnAddInventory_Create(); } $this->txtTrackingNumber_Create(); //$this->lblAdvanced_Create(); $this->txtReceiptAssetCode_Create(); $this->chkAutoGenerateAssetCode_Create(); $this->dtpScheduleReceiptDueDate_Create(); $this->rblAssetType_Create(); $this->chkScheduleReceipt_Create(); $this->btnAddAsset_Create(); $this->ctlAssetSearchTool_Create(); $this->btnSaveExchange_Create(); $this->btnCancelExchange_Create(); $this->btnSaveDueDate_Create(); $this->btnCancelDueDate_Create(); $this->pnlAttachments_Create(); // Create all custom asset fields $this->customFields_Create(); //Set display logic of Built-In Fields $this->UpdateBuiltInFields(); $this->UpdateAddressAccess(); $this->UpdateCompanyAccess(); $this->UpdateContactAccess(); // New entities Dialog $this->dlgNew_Create(); if (!$this->objShipment->ShippedFlag) { // Shipping Buttons $this->btnDelete_Create(); } $this->btnSave_Create(); $this->btnCancel_Create(); $this->btnEdit_Create(); $this->atcAttach_Create(); // Complete Shipment Buttons $this->btnCompleteShipment_Create(); $this->btnCancelShipment_Create(); $this->btnCancelCompleteShipment_Create(); // Shipping Datagrids $this->dtgAssetTransact_Create(); $this->dtgInventoryTransact_Create(); // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time if ($this->blnEditMode) { $objClauses = array(); if ($objClause = $this->dtgAssetTransact->OrderByClause) { array_push($objClauses, $objClause); } /*if ($objClause = $this->dtgAssetTransact->LimitClause) array_push($objClauses, $objClause);*/ if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) { } array_push($objClauses, $objClause); $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses); $objClauses = null; $objClauses = array(); if ($objClause = $this->dtgInventoryTransact->OrderByClause) { array_push($objClauses, $objClause); } /*if ($objClause = $this->dtgInventoryTransact->LimitClause) array_push($objClauses, $objClause);*/ if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) { } array_push($objClauses, $objClause); $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses); // If shipped, display labels. Otherwise, we don't need to call DisplayLabels because only labels are on the QPanel. $this->DisplayLabels(); } elseif (!$this->blnEditMode) { $this->DisplayInputs(); } // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit if (!$this->blnEditMode) { $intAssetId = QApplication::QueryString('intAssetId'); // If an Asset was passed in the query string, load the txt in the Asset Tag text box and click the add button if ($intAssetId) { $objAsset = Asset::Load($intAssetId); if ($objAsset) { $this->txtNewAssetCode->Text = $objAsset->AssetCode; $this->btnAddAsset_Click($this, null, null); } } $intInventoryModelId = QApplication::QueryString('intInventoryModelId'); // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box if ($intInventoryModelId) { $objInventoryModel = InventoryModel::Load($intInventoryModelId); if ($objInventoryModel) { $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode; $this->btnLookup_Click($this, null, null); QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->lstSourceLocation->ControlId)); } } } }
protected function lstCompany_Create() { $this->lstCompany = new QListBox($this); $this->lstCompany->Name = QApplication::Translate('Company'); $this->lstCompany->Required = true; if (!$this->blnEditMode) { $this->lstCompany->AddItem('- Select One -', null); //$this->lstCompany->AddItem('New Company', -1, false); } $objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if ($this->objContact->Company && $this->objContact->Company->CompanyId == $objCompany->CompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } $this->lstCompany->AddAction(new QChangeEvent(), new QAjaxAction('lstCompany_Select')); QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->lstCompany->ControlId)); $this->lstCompany->TabIndex = $this->intTabIndex++; }
protected function lstCompany_Create() { $this->lstCompany = new QListBox($this); $this->lstCompany->Name = QApplication::Translate('Default Shipping & Receiving Company:'); $this->lstCompany->Required = false; $this->lstCompany->AddItem('- Select One -', null); $objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if (QApplication::$TracmorSettings->CompanyId && QApplication::$TracmorSettings->CompanyId == $objCompany->CompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } $this->lstCompany->AddAction(new QChangeEvent(), new QAjaxAction('lstCompany_Change')); $this->lstCompany->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnSave_Click')); $this->lstCompany->AddAction(new QEnterKeyEvent(), new QTerminateAction()); }
/** * Refresh this MetaControl with Data from the local Contact object. * @param boolean $blnReload reload Contact from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objContact->Reload(); } if ($this->lblContactId) { if ($this->blnEditMode) { $this->lblContactId->Text = $this->objContact->ContactId; } } if ($this->lstCompany) { $this->lstCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objCompanyArray = Company::LoadAll(); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if ($this->objContact->Company && $this->objContact->Company->CompanyId == $objCompany->CompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } } if ($this->lblCompanyId) { $this->lblCompanyId->Text = $this->objContact->Company ? $this->objContact->Company->__toString() : null; } if ($this->lstAddress) { $this->lstAddress->RemoveAllItems(); $this->lstAddress->AddItem(QApplication::Translate('- Select One -'), null); $objAddressArray = Address::LoadAll(); if ($objAddressArray) { foreach ($objAddressArray as $objAddress) { $objListItem = new QListItem($objAddress->__toString(), $objAddress->AddressId); if ($this->objContact->Address && $this->objContact->Address->AddressId == $objAddress->AddressId) { $objListItem->Selected = true; } $this->lstAddress->AddItem($objListItem); } } } if ($this->lblAddressId) { $this->lblAddressId->Text = $this->objContact->Address ? $this->objContact->Address->__toString() : null; } if ($this->txtFirstName) { $this->txtFirstName->Text = $this->objContact->FirstName; } if ($this->lblFirstName) { $this->lblFirstName->Text = $this->objContact->FirstName; } if ($this->txtLastName) { $this->txtLastName->Text = $this->objContact->LastName; } if ($this->lblLastName) { $this->lblLastName->Text = $this->objContact->LastName; } if ($this->txtTitle) { $this->txtTitle->Text = $this->objContact->Title; } if ($this->lblTitle) { $this->lblTitle->Text = $this->objContact->Title; } if ($this->txtEmail) { $this->txtEmail->Text = $this->objContact->Email; } if ($this->lblEmail) { $this->lblEmail->Text = $this->objContact->Email; } if ($this->txtPhoneOffice) { $this->txtPhoneOffice->Text = $this->objContact->PhoneOffice; } if ($this->lblPhoneOffice) { $this->lblPhoneOffice->Text = $this->objContact->PhoneOffice; } if ($this->txtPhoneHome) { $this->txtPhoneHome->Text = $this->objContact->PhoneHome; } if ($this->lblPhoneHome) { $this->lblPhoneHome->Text = $this->objContact->PhoneHome; } if ($this->txtPhoneMobile) { $this->txtPhoneMobile->Text = $this->objContact->PhoneMobile; } if ($this->lblPhoneMobile) { $this->lblPhoneMobile->Text = $this->objContact->PhoneMobile; } if ($this->txtFax) { $this->txtFax->Text = $this->objContact->Fax; } if ($this->lblFax) { $this->lblFax->Text = $this->objContact->Fax; } if ($this->txtDescription) { $this->txtDescription->Text = $this->objContact->Description; } if ($this->lblDescription) { $this->lblDescription->Text = $this->objContact->Description; } if ($this->lstCreatedByObject) { $this->lstCreatedByObject->RemoveAllItems(); $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objCreatedByObjectArray = UserAccount::LoadAll(); if ($objCreatedByObjectArray) { foreach ($objCreatedByObjectArray as $objCreatedByObject) { $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId); if ($this->objContact->CreatedByObject && $this->objContact->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objContact->CreatedByObject ? $this->objContact->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objContact->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objContact->CreationDate) ? $this->objContact->__toString($this->strCreationDateDateTimeFormat) : null; } if ($this->lstModifiedByObject) { $this->lstModifiedByObject->RemoveAllItems(); $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objModifiedByObjectArray = UserAccount::LoadAll(); if ($objModifiedByObjectArray) { foreach ($objModifiedByObjectArray as $objModifiedByObject) { $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId); if ($this->objContact->ModifiedByObject && $this->objContact->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objContact->ModifiedByObject ? $this->objContact->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objContact->ModifiedDate; } } if ($this->lstContactCustomFieldHelper) { $this->lstContactCustomFieldHelper->RemoveAllItems(); $this->lstContactCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objContactCustomFieldHelperArray = ContactCustomFieldHelper::LoadAll(); if ($objContactCustomFieldHelperArray) { foreach ($objContactCustomFieldHelperArray as $objContactCustomFieldHelper) { $objListItem = new QListItem($objContactCustomFieldHelper->__toString(), $objContactCustomFieldHelper->ContactId); if ($objContactCustomFieldHelper->ContactId == $this->objContact->ContactId) { $objListItem->Selected = true; } $this->lstContactCustomFieldHelper->AddItem($objListItem); } } // Because ContactCustomFieldHelper's ContactCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstContactCustomFieldHelper->SelectedValue) { $this->lstContactCustomFieldHelper->Enabled = false; } else { $this->lstContactCustomFieldHelper->Enabled = true; } } if ($this->lblContactCustomFieldHelper) { $this->lblContactCustomFieldHelper->Text = $this->objContact->ContactCustomFieldHelper ? $this->objContact->ContactCustomFieldHelper->__toString() : null; } }
/** * Refresh this MetaControl with Data from the local Address object. * @param boolean $blnReload reload Address from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objAddress->Reload(); } if ($this->lblAddressId) { if ($this->blnEditMode) { $this->lblAddressId->Text = $this->objAddress->AddressId; } } if ($this->lstCompany) { $this->lstCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objCompanyArray = Company::LoadAll(); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if ($this->objAddress->Company && $this->objAddress->Company->CompanyId == $objCompany->CompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } } if ($this->lblCompanyId) { $this->lblCompanyId->Text = $this->objAddress->Company ? $this->objAddress->Company->__toString() : null; } if ($this->txtShortDescription) { $this->txtShortDescription->Text = $this->objAddress->ShortDescription; } if ($this->lblShortDescription) { $this->lblShortDescription->Text = $this->objAddress->ShortDescription; } if ($this->lstCountry) { $this->lstCountry->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCountry->AddItem(QApplication::Translate('- Select One -'), null); } $objCountryArray = Country::LoadAll(); if ($objCountryArray) { foreach ($objCountryArray as $objCountry) { $objListItem = new QListItem($objCountry->__toString(), $objCountry->CountryId); if ($this->objAddress->Country && $this->objAddress->Country->CountryId == $objCountry->CountryId) { $objListItem->Selected = true; } $this->lstCountry->AddItem($objListItem); } } } if ($this->lblCountryId) { $this->lblCountryId->Text = $this->objAddress->Country ? $this->objAddress->Country->__toString() : null; } if ($this->txtAddress1) { $this->txtAddress1->Text = $this->objAddress->Address1; } if ($this->lblAddress1) { $this->lblAddress1->Text = $this->objAddress->Address1; } if ($this->txtAddress2) { $this->txtAddress2->Text = $this->objAddress->Address2; } if ($this->lblAddress2) { $this->lblAddress2->Text = $this->objAddress->Address2; } if ($this->txtCity) { $this->txtCity->Text = $this->objAddress->City; } if ($this->lblCity) { $this->lblCity->Text = $this->objAddress->City; } if ($this->lstStateProvince) { $this->lstStateProvince->RemoveAllItems(); $this->lstStateProvince->AddItem(QApplication::Translate('- Select One -'), null); $objStateProvinceArray = StateProvince::LoadAll(); if ($objStateProvinceArray) { foreach ($objStateProvinceArray as $objStateProvince) { $objListItem = new QListItem($objStateProvince->__toString(), $objStateProvince->StateProvinceId); if ($this->objAddress->StateProvince && $this->objAddress->StateProvince->StateProvinceId == $objStateProvince->StateProvinceId) { $objListItem->Selected = true; } $this->lstStateProvince->AddItem($objListItem); } } } if ($this->lblStateProvinceId) { $this->lblStateProvinceId->Text = $this->objAddress->StateProvince ? $this->objAddress->StateProvince->__toString() : null; } if ($this->txtPostalCode) { $this->txtPostalCode->Text = $this->objAddress->PostalCode; } if ($this->lblPostalCode) { $this->lblPostalCode->Text = $this->objAddress->PostalCode; } if ($this->lstCreatedByObject) { $this->lstCreatedByObject->RemoveAllItems(); $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objCreatedByObjectArray = UserAccount::LoadAll(); if ($objCreatedByObjectArray) { foreach ($objCreatedByObjectArray as $objCreatedByObject) { $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId); if ($this->objAddress->CreatedByObject && $this->objAddress->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objAddress->CreatedByObject ? $this->objAddress->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objAddress->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objAddress->CreationDate) ? $this->objAddress->__toString($this->strCreationDateDateTimeFormat) : null; } if ($this->lstModifiedByObject) { $this->lstModifiedByObject->RemoveAllItems(); $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objModifiedByObjectArray = UserAccount::LoadAll(); if ($objModifiedByObjectArray) { foreach ($objModifiedByObjectArray as $objModifiedByObject) { $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId); if ($this->objAddress->ModifiedByObject && $this->objAddress->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objAddress->ModifiedByObject ? $this->objAddress->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objAddress->ModifiedDate; } } if ($this->lstAddressCustomFieldHelper) { $this->lstAddressCustomFieldHelper->RemoveAllItems(); $this->lstAddressCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null); $objAddressCustomFieldHelperArray = AddressCustomFieldHelper::LoadAll(); if ($objAddressCustomFieldHelperArray) { foreach ($objAddressCustomFieldHelperArray as $objAddressCustomFieldHelper) { $objListItem = new QListItem($objAddressCustomFieldHelper->__toString(), $objAddressCustomFieldHelper->AddressId); if ($objAddressCustomFieldHelper->AddressId == $this->objAddress->AddressId) { $objListItem->Selected = true; } $this->lstAddressCustomFieldHelper->AddItem($objListItem); } } // Because AddressCustomFieldHelper's AddressCustomFieldHelper is not null, if a value is already selected, it cannot be changed. if ($this->lstAddressCustomFieldHelper->SelectedValue) { $this->lstAddressCustomFieldHelper->Enabled = false; } else { $this->lstAddressCustomFieldHelper->Enabled = true; } } if ($this->lblAddressCustomFieldHelper) { $this->lblAddressCustomFieldHelper->Text = $this->objAddress->AddressCustomFieldHelper ? $this->objAddress->AddressCustomFieldHelper->__toString() : null; } }
/** * Refresh this MetaControl with Data from the local CompanyCustomFieldHelper object. * @param boolean $blnReload reload CompanyCustomFieldHelper from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objCompanyCustomFieldHelper->Reload(); } if ($this->lstCompany) { $this->lstCompany->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstCompany->AddItem(QApplication::Translate('- Select One -'), null); } $objCompanyArray = Company::LoadAll(); if ($objCompanyArray) { foreach ($objCompanyArray as $objCompany) { $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId); if ($this->objCompanyCustomFieldHelper->Company && $this->objCompanyCustomFieldHelper->Company->CompanyId == $objCompany->CompanyId) { $objListItem->Selected = true; } $this->lstCompany->AddItem($objListItem); } } } if ($this->lblCompanyId) { $this->lblCompanyId->Text = $this->objCompanyCustomFieldHelper->Company ? $this->objCompanyCustomFieldHelper->Company->__toString() : null; } }
public function dtgCompany_Bind() { // Get Total Count b/c of Pagination $this->dtgCompany->TotalItemCount = Company::CountAll(); $objClauses = array(); if ($objClause = $this->dtgCompany->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgCompany->LimitClause) { array_push($objClauses, $objClause); } $this->dtgCompany->DataSource = Company::LoadAll($objClauses); }
protected function Form_Create() { // Call SetupShipment to either Load/Edit Existing or Create New $this->SetupShipment(); // If the courier is FedEx, load the FedexShipment object if ($this->blnEditMode) { if ($this->objShipment->CourierId === 1) { $this->objFedexShipment = FedexShipment::LoadByShipmentId($this->objShipment->ShipmentId); } } $this->objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); // Create the Header Menu $this->ctlHeaderMenu_Create(); // Create the Shortcut Menu $this->ctlShortcutMenu_Create(); // FedEx Shipment Panel $this->pnlFedExShipment_Create(); // Packing List Link $this->lblPackingListLink_Create(); $this->lblFedexShippingLabelLink_Create(); // Shipping Labels $this->lblShipmentNumber_Create(); $this->lblHeaderShipment_Create(); // $this->lblHeaderCompleteShipment_Create(); $this->lblShipDate_Create(); $this->lblFromCompany_Create(); $this->lblFromContact_Create(); $this->lblFromAddress_Create(); $this->lblFromAddressFull_Create(); $this->lblToCompany_Create(); $this->lblToContact_Create(); $this->lblToAddress_Create(); $this->lblToAddressFull_Create(); $this->lblCourier_Create(); $this->lblToPhone_Create(); $this->lblBillTransportationTo_Create(); $this->lblReference_Create(); $this->lblFedexNotifySenderEmail_Create(); $this->lblFedexNotifyRecipientEmail_Create(); $this->lblFedexNotifyOtherEmail_Create(); $this->lblHoldAtLocationAddress_Create(); $this->lblHoldAtLocationCity_Create(); $this->lblHoldAtLocationState_Create(); $this->lblHoldAtLocationPostalCode_Create(); $this->pnlNote_Create(); $this->lblTrackingNumber_Create(); $this->lblSenderLabel_Create(); $this->lblPayerAccount_Create(); $this->lblFxServiceType_Create(); $this->lblPackageType_Create(); $this->lblPackageWeight_Create(); $this->lblPackageLength_Create(); $this->lblPackageWidth_Create(); $this->lblPackageHeight_Create(); $this->lblValue_Create(); $this->lblWeightUnit_Create(); $this->lblLengthUnit_Create(); $this->lblCurrencyUnit_Create(); // Shipping Inputs $this->dlgExchange_Create(); $this->dlgDueDate_Create(); $this->calShipDate_Create(); $this->lstFromCompany_Create(); $this->lblNewFromCompany_Create(); $this->lstFromContact_Create(); $this->lblNewFromContact_Create(); $this->lstFromAddress_Create(); $this->lblNewFromAddress_Create(); $this->lstToCompany_Create(); $this->lblNewToCompany_Create(); $this->lstToContact_Create(); $this->lblNewToContact_Create(); $this->txtToPhone_Create(); $this->lstBillTransportationTo_Create(); $this->lstShippingAccount_Create(); $this->txtReference_Create(); $this->txtFedexNotifySenderEmail_Create(); $this->txtFedexNotifyRecipientEmail_Create(); $this->txtFedexNotifyOtherEmail_Create(); $this->chkFedexNotifySenderShipFlag_Create(); $this->chkFedexNotifySenderExceptionFlag_Create(); $this->chkFedexNotifySenderDeliveryFlag_Create(); $this->chkFedexNotifyRecipientShipFlag_Create(); $this->chkFedexNotifyRecipientExceptionFlag_Create(); $this->chkFedexNotifyRecipientDeliveryFlag_Create(); $this->chkFedexNotifyOtherShipFlag_Create(); $this->chkFedexNotifyOtherExceptionFlag_Create(); $this->chkFedexNotifyOtherDeliveryFlag_Create(); $this->lstFxServiceType_Create(); $this->txtRecipientThirdPartyAccount_Create(); $this->lstPackageType_Create(); $this->txtPackageWeight_Create(); $this->lstWeightUnit_Create(); $this->txtPackageLength_Create(); $this->txtPackageWidth_Create(); $this->txtPackageHeight_Create(); $this->lstLengthUnit_Create(); $this->txtValue_Create(); $this->lstCurrencyUnit_Create(); $this->chkSaturdayDeliveryFlag_Create(); $this->chkHoldAtLocationFlag_Create(); $this->txtHoldAtLocationAddress_Create(); $this->txtHoldAtLocationCity_Create(); $this->lstHoldAtLocationState_Create(); $this->txtHoldAtLocationPostalCode_Create(); $this->lstToAddress_Create(); $this->lblNewToAddress_Create(); if (QApplication::$TracmorSettings->CustomShipmentNumbers) { $this->txtShipmentNumber_Create(); } $this->lstCourier_Create(); $this->txtNote_Create(); $this->txtNewAssetCode_Create(); $this->txtNewInventoryModelCode_Create(); $this->lstSourceLocation_Create(); $this->txtQuantity_Create(); $this->txtTrackingNumber_Create(); //$this->lblAdvanced_Create(); $this->txtReceiptAssetCode_Create(); $this->chkAutoGenerateAssetCode_Create(); $this->dtpScheduleReceiptDueDate_Create(); $this->rblAssetType_Create(); $this->chkScheduleReceipt_Create(); $this->btnAddAsset_Create(); $this->btnLookup_Create(); $this->btnAddInventory_Create(); $this->btnSaveExchange_Create(); $this->btnCancelExchange_Create(); $this->btnSaveDueDate_Create(); $this->btnCancelDueDate_Create(); $this->pnlAttachments_Create(); // Create all custom asset fields $this->customFields_Create(); //Set display logic of Built-In Fields $this->UpdateBuiltInFields(); $this->UpdateAddressAccess(); $this->UpdateCompanyAccess(); $this->UpdateContactAccess(); // New entities Dialog $this->dlgNew_Create(); if (!$this->objShipment->ShippedFlag) { // Shipping Buttons $this->btnSave_Create(); $this->btnCancel_Create(); $this->btnEdit_Create(); $this->btnDelete_Create(); } $this->atcAttach_Create(); // Complete Shipment Buttons $this->btnCompleteShipment_Create(); $this->btnCancelShipment_Create(); $this->btnCancelCompleteShipment_Create(); // Shipping Datagrids $this->dtgAssetTransact_Create(); $this->dtgInventoryTransact_Create(); // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time if ($this->blnEditMode) { $objClauses = array(); if ($objClause = $this->dtgAssetTransact->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgAssetTransact->LimitClause) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) { } array_push($objClauses, $objClause); $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses); $objClauses = null; $objClauses = array(); if ($objClause = $this->dtgInventoryTransact->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgInventoryTransact->LimitClause) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) { } array_push($objClauses, $objClause); $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses); // If shipped, display labels. Otherwise, we don't need to call DisplayLabels because only labels are on the QPanel. $this->DisplayLabels(); } elseif (!$this->blnEditMode) { $this->DisplayInputs(); } // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit if (!$this->blnEditMode) { $intAssetId = QApplication::QueryString('intAssetId'); // If an Asset was passed in the query string, load the txt in the Asset Code text box and click the add button if ($intAssetId) { $objAsset = Asset::Load($intAssetId); if ($objAsset) { $this->txtNewAssetCode->Text = $objAsset->AssetCode; $this->btnAddAsset_Click($this, null, null); } } $intInventoryModelId = QApplication::QueryString('intInventoryModelId'); // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box if ($intInventoryModelId) { $objInventoryModel = InventoryModel::Load($intInventoryModelId); if ($objInventoryModel) { $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode; $this->btnLookup_Click($this, null, null); QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->lstSourceLocation->ControlId)); } } } }