Ejemplo n.º 1
0
 protected function txtUsername_Create()
 {
     $this->txtUsername = new QTextBox($this);
     $this->txtUsername->Name = QApplication::Translate('Username') . ":";
     $this->txtUsername->Required = true;
     QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->txtUsername->ControlId));
 }
Ejemplo n.º 2
0
 /**
  * Creates the reset button html for use with multiple select boxes.
  * 
  */
 protected function GetResetButtonHtml()
 {
     $strJavaScriptOnClick = sprintf('$j("#%s").val(null);$j("#%s").trigger("change"); return false;', $this->strControlId, $this->strControlId);
     $strToReturn = sprintf(' <a id="reset_ctl_%s" href="#" class="listboxReset">%s</a>', $this->strControlId, QApplication::Translate('Reset'));
     QApplication::ExecuteJavaScript(sprintf('$j("#reset_ctl_%s").on("%s", function(){ %s });', $this->strControlId, "click", $strJavaScriptOnClick));
     return $strToReturn;
 }
Ejemplo n.º 3
0
 protected function SetupPanel()
 {
     if (!$this->objStack) {
         return $this->ReturnTo('#1');
     }
     $this->btnScanCheck = new QButton($this);
     $this->btnScanCheck->Text = 'Scan Check';
     $this->btnScanCheck->CssClass = 'primary';
     $this->btnScanCheck->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnScanCheck_Click'));
     $this->dlgScanCheck = new QDialogBox($this);
     $this->dlgScanCheck->Template = dirname(__FILE__) . '/dlgScanCheck.tpl.php';
     $this->dlgScanCheck->MatteClickable = false;
     $this->dlgScanCheck->HideDialogBox();
     $this->btnScanCheckCancel = new QLinkButton($this->dlgScanCheck);
     $this->btnScanCheckCancel->Text = 'Close';
     $this->btnScanCheckCancel->CssClass = 'cancel';
     $this->btnScanCheckCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnScanCheckCancel_Click'));
     $this->btnScanCheckCancel->AddAction(new QClickEvent(), new QTerminateAction());
     $this->btnScanCheckTest = new QLinkButton($this->dlgScanCheck);
     $this->btnScanCheckTest->Text = 'Test Connection to MICRImage';
     $this->btnScanCheckTest->CssClass = 'cancel';
     $this->btnScanCheckTest->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnScanCheckTest_Click'));
     $this->btnScanCheckTest->AddAction(new QClickEvent(), new QTerminateAction());
     $this->dtgTransactionType = new QDataGrid($this);
     $this->dtgTransactionType->AddColumn(new QDataGridColumn('Transaction Type', '<?= $_CONTROL->ParentControl->RenderTransactionType($_ITEM); ?>', 'Width=280px'));
     $this->dtgTransactionType->AddColumn(new QDataGridColumn('Count', '<?= $_CONTROL->ParentControl->RenderTransactionCount($_ITEM); ?>', 'Width=90px'));
     $this->dtgTransactionType->SetDataBinder('dtgTransactionType_Bind', $this);
     if ($this->strUrlHashArgument == 'scan') {
         QApplication::ExecuteJavaScript('ScrollDivToBottom("dtgContributionsDiv");');
         $this->btnScanCheck_Click();
     }
 }
Ejemplo n.º 4
0
 protected function SetupChildEditControls()
 {
     $this->lstGrowthGroupLocation = $this->mctGrowthGroup->lstGrowthGroupLocation_Create();
     $this->lstGrowthGroupStructure = $this->mctGrowthGroup->lstGrowthGroupStructures_Create();
     $this->lstGrowthGroupStructure->Rows = 10;
     $this->lstGrowthGroupStatus = new QListBox($this);
     foreach (AvailabilityStatus::LoadAll() as $objStatus) {
         $this->lstGrowthGroupStatus->AddItem($objStatus->Name, $objStatus->Id);
     }
     $this->lstGrowthGroupDayType = $this->mctGrowthGroup->lstGrowthGroupDayType_Create();
     $this->txtStartTime = $this->mctGrowthGroup->txtStartTime_Create();
     $this->txtEndTime = $this->mctGrowthGroup->txtEndTime_Create();
     $this->txtAddress1 = $this->mctGrowthGroup->txtAddress1_Create();
     $this->txtAddress2 = $this->mctGrowthGroup->txtAddress2_Create();
     $this->txtCrossStreet1 = $this->mctGrowthGroup->txtCrossStreet1_Create();
     $this->txtCrossStreet2 = $this->mctGrowthGroup->txtCrossStreet2_Create();
     $this->txtZipCode = $this->mctGrowthGroup->txtZipCode_Create();
     $this->txtLongitude = $this->mctGrowthGroup->txtLongitude_Create();
     $this->txtLatitude = $this->mctGrowthGroup->txtLatitude_Create();
     $this->txtAccuracy = $this->mctGrowthGroup->txtAccuracy_Create();
     $this->txtAccuracy->Instructions = 'as reported by Google Maps -- this should ideally be 7';
     $this->txtDescription = $this->mctGrowthGroup->txtDescription_Create();
     $this->btnRefresh = new QButton($this);
     $this->btnRefresh->Text = 'Lookup Using Google Maps';
     $this->btnRefresh->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnRefresh));
     $this->btnRefresh->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnRefresh_Click'));
     $this->cblMeetings = new QCheckBoxList($this, 'days');
     $this->cblMeetings->Name = 'Meetings per Month';
     foreach (array('1st', '2nd', '3rd', '4th', '5th', 'Every Other') as $intKey => $strName) {
         $intValue = pow(2, $intKey);
         $this->cblMeetings->AddItem($strName, $intValue, $this->mctGrowthGroup->GrowthGroup->MeetingBitmap & $intValue);
     }
     QApplication::ExecuteJavaScript('document.getElementById("days[5]").onclick = EveryOtherClicked;');
 }
Ejemplo n.º 5
0
 protected function GetFooterRowHtml()
 {
     QApplication::ExecuteJavaScript(sprintf('highlight_datagrid(\'%s\');', $this->ControlId));
     if ($this->objPaginatorAlternate) {
         return sprintf('<tr><td colspan="%s">%s</td></tr>', count($this->objColumnArray), $this->GetPaginatorRowHtml($this->objPaginatorAlternate));
     }
 }
Ejemplo n.º 6
0
 protected function TextItem_Cancel($strFormId, $strControlId, $strParameter)
 {
     // Hide the Textbox, get the label cleaned up and ready to go
     $this->lblArray[$strParameter]->Display = true;
     $this->txtArray[$strParameter]->Display = false;
     $this->lblArray[$strParameter]->CssClass = 'renamer_item';
     QApplication::ExecuteJavaScript('intSelectedIndex = -1;');
 }
Ejemplo n.º 7
0
 public function HideDialogBox()
 {
     if ($this->blnDisplay) {
         $this->Display = false;
     }
     QApplication::ExecuteJavaScript("qc.getWrapper('" . $this->strControlId . "').hideDialogBox()");
     $this->blnWrapperModified = false;
 }
Ejemplo n.º 8
0
 public function renderLowPriorityButton_Click($strFormId, $strControlId, $strParameter)
 {
     $this->intHitCnt++;
     $this->dtgButtons->MarkAsModified();
     QApplication::ExecuteJavaScript("alert('alert 3: a low priority script')", QJsPriority::Low);
     QApplication::ExecuteJavaScript("alert('alert 1: a low priority script')", QJsPriority::Low);
     QApplication::ExecuteJavaScript("alert('Just updated the datagrid: --> the javascript for adding the css class to the buttons is executed first!')", QJsPriority::Low);
     QApplication::ExecuteJavaScript('$j(".ui-button").addClass("ui-state-error")');
     //change the button color: this is executed with standard priority
 }
    public function GetEndScript()
    {
        $strJS = parent::GetEndScript();
        $strCtrlJs = <<<FUNC
\t\t\t;\$j('#{$this->ControlId}').on("sortstop", function (event, ui) {
\t\t\t\t\t\tvar ary = jQuery(this).sortable("toArray");
\t\t\t\t\t\tvar str = ary.join(",");
\t\t\t \t\t\tqcubed.recordControlModification("{$this->ControlId}", "_ItemArray", str);
\t\t\t\t\t})\t\t\t\t\t\t
FUNC;
        QApplication::ExecuteJavaScript($strCtrlJs, QJsPriority::High);
        return $strJS;
    }
Ejemplo n.º 10
0
 protected function lblForgotPassword_Click()
 {
     $this->txtUsername->Enabled = false;
     $this->txtPassword->Enabled = false;
     $this->btnLogin->Enabled = false;
     $this->lblForgotPassword->Display = false;
     $this->txtEmail->Visible = true;
     $this->btnRecoverPassword->Display = true;
     QApplication::ExecuteJavaScript(sprintf("if (!('placeholder' in document.createElement('input'))) qc.getC('%s').value = 'E-Mail Address'", $this->txtEmail->ControlId));
     $this->txtEmail->Focus();
     $this->txtEmail->Blink();
     $this->txtEmail->Select();
 }
Ejemplo n.º 11
0
 protected function Form_Create()
 {
     $this->lblLabel = new QLabel($this);
     $this->lblLabel->Text = "Members who left after ";
     $this->dtxBeforeValue = new QDateTimeTextBox($this);
     $this->dtxBeforeValue->Name = "Members who Exited Before:";
     $this->dtxBeforeValue->Required = true;
     $this->beforeCalValue = new QCalendar($this, $this->dtxBeforeValue);
     $this->dtxBeforeValue->RemoveAllActions(QClickEvent::EventName);
     $this->dtxBeforeValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change'));
     $this->dtxBeforeValue->Text = QApplication::PathInfo(1);
     $this->dtxAfterValue = new QDateTimeTextBox($this);
     $this->dtxAfterValue->Name = "Members who exited After:";
     $this->dtxAfterValue->Required = true;
     $this->afterCalValue = new QCalendar($this, $this->dtxAfterValue);
     $this->dtxAfterValue->RemoveAllActions(QClickEvent::EventName);
     $this->dtxAfterValue->AddAction(new QChangeEvent(), new QAjaxAction('dtxDate_Change'));
     $this->dtxAfterValue->Text = QApplication::PathInfo(0);
     $this->dtgExitingMembers = new QDataGrid($this);
     $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Name', '<?= $_ITEM->Person->FullName; ?>', 'Width=270px'));
     $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Membership End Date', '<?= $_ITEM->DateEnd; ?>', 'Width=270px'));
     $this->dtgExitingMembers->AddColumn(new QDataGridColumn('Termination Reason', '<?= $_ITEM->TerminationReason; ?>', 'Width=270px'));
     $dtAfterValue = new QDateTime($this->dtxAfterValue->Text);
     $dtBeforeValue = new QDateTime($this->dtxBeforeValue->Text);
     $objcondition = QQ::Equal(QQN::Membership()->Person->AttributeValue->Attribute->Name, 'Post-2016');
     $objMembershipArray = Membership::LoadArrayByEndDateRange($dtAfterValue, $dtBeforeValue, $objcondition);
     $this->iTotalCount = count($objMembershipArray);
     $this->dtgExitingMembers->DataSource = $objMembershipArray;
     $chartArray = array();
     $terminationReason = array();
     foreach ($objMembershipArray as $member) {
         if (array_key_exists($member->TerminationReason, $terminationReason)) {
             $terminationReason[$member->TerminationReason]++;
         } else {
             $terminationReason[$member->TerminationReason] = 1;
         }
     }
     ksort($terminationReason, SORT_STRING);
     foreach ($terminationReason as $key => $value) {
         $objItem = new memberArray();
         $objItem->reason = $key;
         $objItem->count = $value;
         $chartArray[] = $objItem;
     }
     QApplication::ExecuteJavaScript('initializeChart(' . json_encode($chartArray) . ');');
 }
Ejemplo n.º 12
0
 private function dtgNew_Create($latestVersions)
 {
     $this->dtgNew = new QDataGrid($this, 'dtgNew');
     $this->dtgNew->AddColumn(new QDataGridColumn('Name', '<?= $_FORM->RenderName($_ITEM) ?>', 'HtmlEntities=false'));
     $this->dtgNew->AddColumn(new QDataGridColumn('Description', '<?= $_ITEM->description ?>', 'HtmlEntities=false'));
     $arrDataSource = array();
     foreach ($latestVersions as $item) {
         /** @var $item DownloadedItem */
         if ($item->installedVersion == null) {
             $arrDataSource[] = $item;
         }
     }
     $this->dtgNew->DataSource = $arrDataSource;
     if (sizeof($this->dtgNew->DataSource) > 0) {
         QApplication::ExecuteJavaScript('jQuery("#lblNoNew").hide()');
     } else {
         QApplication::ExecuteJavaScript('jQuery("#dtgNew").hide()');
     }
 }
Ejemplo n.º 13
0
Archivo: index.php Proyecto: alcf/chms
 public function dtrGrowthGroups_Bind()
 {
     $objCondition = QQ::Equal(QQN::GrowthGroup()->GrowthGroupLocationId, $this->objLocation->Id);
     if ($this->lstDays->SelectedValue) {
         $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::GrowthGroup()->GrowthGroupDayTypeId, $this->lstDays->SelectedValue));
     }
     if ($this->lstTypes->SelectedValue) {
         $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::GrowthGroup()->GrowthGroupStructure->GrowthGroupStructureId, $this->lstTypes->SelectedValue));
     }
     // Filter Out "inactive" groups
     $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::GrowthGroup()->Group->ActiveFlag, true));
     $this->dtrGrowthGroups->DataSource = GrowthGroup::QueryArray($objCondition, QQ::OrderBy(QQN::GrowthGroup()->Group->Name));
     // Results?
     $this->pnlNone->Visible = !count($this->dtrGrowthGroups->DataSource);
     // Markers
     QApplication::ExecuteJavaScript('hideAllMarkers();');
     foreach ($this->dtrGrowthGroups->DataSource as $objGroup) {
         QApplication::ExecuteJavaScript('showMarker(' . ($this->intMarkerArray[$objGroup->GroupId] - 1) . ');');
     }
 }
Ejemplo n.º 14
0
 public function RenderAsEvents($strActionParameter = null, $blnDisplayOutput = true, $strTargetControlId = null, $blnRenderControlId = true)
 {
     if ($strTargetControlId) {
         $this->strTargetControlId = $strTargetControlId;
     } else {
         $this->strTargetControlId = $this->objForm->GenerateControlId();
     }
     $this->strActionParameter = $strActionParameter;
     $strToReturn = $this->GetActionAttributes();
     QApplication::ExecuteJavaScript($strToReturn);
     if ($blnRenderControlId && $blnDisplayOutput) {
         echo sprintf("id='%s'", $this->strTargetControlId);
     } else {
         if ($blnRenderControlId) {
             return sprintf("id='%s'", $this->strTargetControlId);
         } else {
             return "";
         }
     }
 }
Ejemplo n.º 15
0
Archivo: upload.php Proyecto: alcf/chms
 protected function btnSave_Click()
 {
     $strText = file_get_contents($this->flcUpload->FilePath);
     try {
         $intEntriesModified = 0;
         $intEntriesAdded = 0;
         $intRows = PaypalBatch::ProcessReport($strText, $intEntriesModified, $intEntriesAdded);
         if (!$intEntriesAdded && !$intEntriesModified) {
             QApplication::DisplayAlert('No new or modified entries found.  No changes were made.');
         } else {
             if ($intEntriesAdded) {
                 QApplication::DisplayAlert(sprintf('PayPal import successful.  %s payment entries were updated.  WARNING: %s unlinked credit card payment entries had to be created.', $intEntriesModified, $intEntriesAdded));
             } else {
                 QApplication::DisplayAlert(sprintf('PayPal import successful.  %s payment entries were updated.', $intEntriesModified));
             }
         }
         QApplication::ExecuteJavaScript('document.location = "/stewardship/paypal/";');
     } catch (QCallerException $objExc) {
         QApplication::DisplayAlert('There were problems processing the report file: "' . $objExc->getMessage() . '"');
         return;
     }
 }
Ejemplo n.º 16
0
 protected function Form_Create()
 {
     $this->geographyArray = $this->InitializeArray();
     $objgeographyArray = array();
     foreach ($this->geographyArray as $key => $val) {
         $objgeographicalItem = new geographicalItem($key, $val);
         $objgeographyArray[] = $objgeographicalItem;
     }
     $this->dtgGeography = new QDataGrid($this);
     $this->dtgGeography->AddColumn(new QDataGridColumn('City', '<?= $_ITEM->key; ?>', 'Width=270px'));
     $this->dtgGeography->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px'));
     $this->dtgGeography->DataSource = $objgeographyArray;
     $this->dtgPeople = new PersonDataGrid($this);
     $objPaginator = new QPaginator($this->dtgPeople);
     $this->dtgPeople->Paginator = $objPaginator;
     $this->dtgPeople->ItemsPerPage = 20;
     $this->dtgPeople->AddColumn(new QDataGridColumn('Member Name', '<?= $_ITEM->FullName; ?>', 'Width=270px', array('OrderByClause' => QQ::OrderBy(QQN::Person()->LastName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Person()->LastName, false))));
     $this->dtgPeople->AddColumn(new QDataGridColumn('City', '<?= $_FORM->RenderCity($_ITEM) ?>', 'Width=270px', array('OrderByClause' => QQ::OrderBy(QQN::Person()->PrimaryCityText), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Person()->PrimaryCityText, false))));
     $this->dtgPeople->SetDataBinder('dtgPeople_Bind');
     // Construct the charts
     QApplication::ExecuteJavaScript('initializeChart(' . json_encode($objgeographyArray) . ');');
 }
 protected function SetupPanel()
 {
     if (!QApplication::IsLoginHasPermission(PermissionType::EditMembershipStatus)) {
         $this->strTemplate = null;
         QApplication::ExecuteJavaScript('document.location = "#general";');
         return;
     }
     $this->dtgMemberships = new QDataGrid($this);
     if (QApplication::IsLoginHasPermission(PermissionType::EditMembershipStatus)) {
         $this->dtgMemberships->AddColumn(new QDataGridColumn('Edit', '<?= $_CONTROL->ParentControl->RenderEdit($_ITEM); ?>', 'HtmlEntities=false'));
     }
     $this->dtgMemberships->AddColumn(new QDataGridColumn('Membership Started', '<?= $_ITEM->DateStart->__toString("MMMM D, YYYY"); ?>'));
     $this->dtgMemberships->AddColumn(new QDataGridColumn('Membership Ended', '<?= $_CONTROL->ParentControl->RenderMembershipEnded($_ITEM); ?>', 'HtmlEntities=false'));
     $this->dtgMemberships->AddColumn(new QDataGridColumn('Reason', '<?= $_ITEM->TerminationReason; ?>'));
     $this->dtgMemberships->SetDataBinder('dtgMemberships_Bind', $this);
     $strdebug = sprintf("MembershipStatusTypeID = %d", $this->objPerson->MembershipStatusTypeId);
     // Add a "Add a New Membership" button if applicable
     if (QApplication::IsLoginHasPermission(PermissionType::EditMembershipStatus) && !$this->objPerson->CurrentMembershipInfo) {
         $this->btnAdd = new QButton($this);
         $this->btnAdd->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnAdd_Click'));
     }
 }
Ejemplo n.º 18
0
 protected function lblArray_Click($strFormId, $strControlId, $strParameter)
 {
     // Is the Label being clicked already selected?
     if ($this->lblArray[$strParameter]->Selected) {
         // It's already selected -- go ahead and replace it with the textbox
         $this->lblArray[$strParameter]->Visible = false;
         $this->txtArray[$strParameter]->Visible = true;
         $this->txtArray[$strParameter]->Text = html_entity_decode($this->lblArray[$strParameter]->Text, ENT_COMPAT, QApplication::$EncodingType);
         QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').select(); document.getElementById('%s').focus();", $this->txtArray[$strParameter]->ControlId, $this->txtArray[$strParameter]->ControlId));
     } else {
         // Nope -- not yet selected
         // First, unselect everything else
         for ($intIndex = 0; $intIndex < 10; $intIndex++) {
             if ($this->lblArray[$intIndex]->Selected) {
                 $this->lblArray[$intIndex]->Selected = false;
                 $this->lblArray[$intIndex]->CssClass = 'renamer_item';
             }
         }
         // Now, make this item selected
         $this->lblArray[$strParameter]->Selected = true;
         $this->lblArray[$strParameter]->CssClass = 'renamer_item renamer_item_selected';
     }
 }
 protected function prepareAjaxList($dataSource)
 {
     $list = $dataSource ? JavaScriptHelper::toJsObject($dataSource) : "[]";
     $strJS = sprintf('$j("#%s").data("autocomplete").response(%s);', $this->ControlId, $list);
     QApplication::ExecuteJavaScript($strJS, true);
 }
Ejemplo n.º 20
0
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         case "ItemCssStyle":
             try {
                 $this->strItemCssStyle = QType::Cast($mixValue, QType::String);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ItemSelectedCssStyle":
             try {
                 $this->strItemSelectedCssStyle = QType::Cast($mixValue, QType::String);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ItemHoverCssStyle":
             try {
                 $this->strItemHoverCssStyle = QType::Cast($mixValue, QType::String);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "IndentWidth":
             try {
                 $this->intIndentWidth = QType::Cast($mixValue, QType::Integer);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ItemHeight":
             try {
                 $this->intItemHeight = QType::Cast($mixValue, QType::Integer);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ItemWidth":
             try {
                 $this->intItemWidth = QType::Cast($mixValue, QType::Integer);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "ExpandOnSelect":
             try {
                 $this->blnExpandOnSelect = QType::Cast($mixValue, QType::Boolean);
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case "SelectedItem":
             try {
                 $objItem = QType::Cast($mixValue, "QTreeNavItem");
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             // If the currently selected item is $objItem, then do nothing
             if ($objItem && $this->objSelectedTreeNavItem && (string) $this->objSelectedTreeNavItem->ItemId == (string) $objItem->ItemId) {
                 return $objItem;
             }
             // Deselect the Old (if applicable)
             if ($this->objSelectedTreeNavItem) {
                 // if we are in an AJAX response scenario, we MUST remember to use a javascript update call
                 // to "deselect" the old selected item
                 QApplication::ExecuteJavaScript(sprintf("treenavItemUnselect('%s_%s_label', '%s')", $this->strControlId, $this->objSelectedTreeNavItem->ItemId, $this->strItemCssStyle));
                 // Update deselection in the form state, too
                 $this->objSelectedTreeNavItem->Selected = false;
             }
             if ($this->objSelectedTreeNavItem = $objItem) {
                 $objItem->Selected = true;
                 if ($this->blnExpandOnSelect) {
                     $objItem->Expanded = true;
                 }
                 // Ensure that all parents and ancestors are expanded
                 $objParent = $this->GetItem($objItem->ParentItemId);
                 while ($objParent) {
                     $objParent->Expanded = true;
                     $objParent = $this->GetItem($objParent->ParentItemId);
                 }
             }
             return $objItem;
         case "ItemExpanded":
             $strTokenArray = explode(' ', $mixValue);
             $objItem = $this->GetItem($strTokenArray[0]);
             $objItem->Expanded = $strTokenArray[1];
             return $strTokenArray[1];
         default:
             try {
                 parent::__set($strName, $mixValue);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             break;
     }
 }
Ejemplo n.º 21
0
 protected function btnNew_Click($strFormId, $strControlId, $strParameter)
 {
     $this->intEditPersonId = -1;
     $this->txtFirstName->Text = '';
     $this->txtLastName->Text = '';
     // Let's put the focus on the FirstName Textbox
     QApplication::ExecuteJavaScript(sprintf('qcodo.getControl("%s").focus()', $this->txtFirstName->ControlId));
 }
Ejemplo n.º 22
0
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     if ($this->txtAccessKey && $this->txtAccessKey->Text != $this->objContextInfo->SuggestionAccessKey) {
         $this->objContextInfo->SuggestionAccessKey = $this->txtAccessKey->Text;
         $this->objContextInfo->Save();
     }
     if ($this->txtCommandKey && $this->txtCommandKey->Text != $this->objContextInfo->SuggestionCommandKey) {
         $this->objContextInfo->SuggestionCommandKey = $this->txtCommandKey->Text;
         $this->objContextInfo->Save();
     }
     if ($this->txtTranslation->Text != '' && ($this->chkChanged->Checked || $this->btnSaveIgnore && $this->btnSaveIgnore->ControlId == $strControlId)) {
         if (!$this->btnSaveIgnore && !$this->Validate()) {
             $this->btnSaveIgnore_Create();
             $this->btnSaveIgnore->RemoveAllActions('click');
             $this->btnSaveIgnore->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
             $this->btnSaveIgnore->Text = t('Ignore and save');
             $this->lblMessage->Text .= sprintf(t('Clear the textbox to skip this translation, click Ignore and save or click the save button to try again'));
             $this->btnSaveIgnore->Display = true;
             $this->chkChanged->Checked = false;
             return false;
         }
         if ($this->btnSaveIgnore) {
             $this->btnSaveIgnore->Display = false;
             $this->btnSave->Display = true;
         }
         if (!($objSuggestion = NarroSuggestion::LoadByTextIdLanguageIdSuggestionValueMd5($this->objContextInfo->Context->TextId, QApplication::GetLanguageId(), md5($this->txtTranslation->Text)))) {
             $objSuggestion = new NarroSuggestion();
             $objSuggestion->IsImported = false;
             $objSuggestion->HasComments = false;
             $objSuggestion->LanguageId = QApplication::GetLanguageId();
             $objSuggestion->TextId = $this->objContextInfo->Context->TextId;
             $objSuggestion->SuggestionValue = $this->txtTranslation->Text;
             $objSuggestion->UserId = QApplication::GetUserId();
             $objSuggestion->Save();
             $this->objContextInfo->HasSuggestions = 1;
             $this->objContextInfo->Modified = QDateTime::Now();
             $this->objContextInfo->Save();
             QApplication::ExecuteJavaScript(sprintf('jQuery(\'#%s\').after(\'&nbsp;<small style="padding: 2px;" class="ui-state-highlight ui-corner-all"><span style="width:16px; height: 16px; display:inline-block" class="ui-icon ui-icon-info"></span>&nbsp;%s.</small>\')', $this->btnHelp->ControlId, t('Translation saved')));
             if ($this->dtgTranslation) {
                 $this->dtgTranslation->MarkAsModified();
             }
         }
         if ($this->ParentControl->ParentControl->chkApprove->Checked == true) {
             $this->btnApprove_Click($strFormId, $strControlId, $objSuggestion->SuggestionId);
         } else {
             if ($this->ParentControl->ParentControl->chkRefresh->Checked && $strControlId != $this->btnKeepUntranslated->ControlId) {
                 $this->ParentControl->ParentControl->btnSearch_Click();
             }
             $this->btnHelp_Update();
             foreach ($this->Form->GetAllControls() as $ctl) {
                 if ($ctl instanceof NarroContextInfoEditor) {
                     if ($ctl->Text->Text == $this->lblText->Text) {
                         $ctl->btnHelp_Click($this->Form->FormId, $ctl->btnHelp->ControlId, '1');
                     }
                 }
             }
         }
         $this->chkChanged->Checked = false;
         $this->lblMessage->Text = '';
     } elseif ($this->txtTranslation->Text == '' && $this->objContextInfo->ValidSuggestionId) {
         $this->objContextInfo->ValidSuggestionId = null;
         $this->objContextInfo->ValidatorUserId = null;
         $this->objContextInfo->Save();
         if ($this->dtgTranslation) {
             $this->dtgTranslation->MarkAsModified();
         }
     }
     if (isset($objSuggestion)) {
         return $objSuggestion;
     } else {
         return true;
     }
 }
Ejemplo n.º 23
0
 public function btnCancel_Click($strFormId, $strControlId, $strParameter)
 {
     QApplication::ExecuteJavaScript('document.location = "#groups";');
 }
Ejemplo n.º 24
0
 /**
  * Call a JQuery UI Method on the object. 
  * 
  * A helper function to call a jQuery UI Method. Takes variable number of arguments.
  * 
  * @param string $strMethodName the method name to call
  * @internal param $mixed [optional] $mixParam1
  * @internal param $mixed [optional] $mixParam2
  */
 protected function CallJqUiMethod($strMethodName)
 {
     $args = func_get_args();
     $strArgs = JavaScriptHelper::toJsObject($args);
     $strJs = sprintf('jQuery("#%s").%s(%s)', $this->getJqControlId(), $this->getJqSetupFunction(), substr($strArgs, 1, strlen($strArgs) - 2));
     // params without brackets
     QApplication::ExecuteJavaScript($strJs);
 }
		/**
		 * This will focus on and do a "select all" on the contents of the textbox
		 */
		public function Select() {
			QApplication::ExecuteJavaScript(sprintf('qc.getW("%s").select();', $this->strControlId));
		}
Ejemplo n.º 26
0
 /**
  * Make sure the caller of this method is also a "return" call to cease processing within that given method.
  * This will safely redirect the user back to whatever URL is being requested, even if it's a HASH.
  * @param string $strUrl
  * @return null
  */
 public function ReturnTo($strUrl)
 {
     $this->strTemplate = null;
     QApplication::ExecuteJavaScript('document.location = "' . $strUrl . '";');
     return null;
 }
Ejemplo n.º 27
0
 public function SetFocus()
 {
     QApplication::ExecuteJavaScript(sprintf('qc.getW("%s").focus()', $this->strControlId));
 }
Ejemplo n.º 28
0
 public static function UpdatePageTitle($strPageTitle)
 {
     $strPageTitle = QApplication::HtmlEntities($strPageTitle);
     $strJavaScript = sprintf('document.title = "%s";', $strPageTitle);
     QApplication::ExecuteJavaScript($strJavaScript);
 }
Ejemplo n.º 29
0
 protected function txtShortDescription_Create()
 {
     parent::txtShortDescription_Create();
     $this->txtShortDescription->CausesValidation = true;
     $this->txtShortDescription->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnSave_Click'));
     $this->txtShortDescription->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->txtShortDescription->TabIndex = $this->intTabIndex++;
     QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->txtShortDescription->ControlId));
 }
Ejemplo n.º 30
0
 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++;
         }
     }
 }