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 Setup Receipt to either load existing or create new receipt $this->SetupReceipt(); // Create the Header Menu $this->ctlHeaderMenu_Create(); // Create the Shortcut Menu $this->ctlShortcutMenu_Create(); // Create the labels $this->lblHeaderReceipt_Create(); $this->lblFromCompany_Create(); $this->lblFromContact_Create(); $this->lblToContact_Create(); $this->lblToAddress_Create(); $this->lblReceiptNumber_Create(); $this->pnlNote_Create(); $this->lblDueDate_Create(); $this->lblReceiptDate_Create(); // Create the inputs $this->lstFromCompany_Create(); $this->lblNewFromCompany_Create(); $this->lstFromContact_Create(); $this->lblNewFromContact_Create(); $this->lstToContact_Create(); $this->lblNewToContact_Create(); $this->lstToAddress_Create(); $this->lblNewToAddress_Create(); $this->txtNote_Create(); // Create all custom asset fields - this must be here for tab ordering $this->customFields_Create(); if ($this->blnShowInventory) { $this->txtNewInventoryModelCode_Create(); $this->ctlInventorySearchTool_Create(); $this->txtQuantity_Create(); $this->btnAddInventory_Create(); } $this->txtNewAssetCode_Create(); $this->rblAssetType_Create(); $this->lstAssetModel_Create(); $this->chkAutoGenerateAssetCode_Create(); $this->calDueDate_Create(); $this->calDateReceived_Create(); if (QApplication::$TracmorSettings->CustomReceiptNumbers) { $this->txtReceiptNumber_Create(); } // Create the buttons $this->btnSave_Create(); $this->btnEdit_Create(); $this->btnCancel_Create(); $this->btnDelete_Create(); $this->atcAttach_Create(); $this->pnlAttachments_Create(); $this->btnAddAsset_Create(); $this->ctlAssetSearchTool_Create(); //Set display logic of Built-In Fields $this->UpdateBuiltInFields(); // Set display logic of certain Entities $this->UpdateAddressAccess(); $this->UpdateCompanyAccess(); $this->UpdateContactAccess(); // Check prerequisites for scheduling receipts $this->CheckPrerequisites(); // Create the datagrids $this->dtgAssetTransact_Create(); $this->dtgInventoryTransact_Create(); // New entities Dialog $this->dlgNew_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); } $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objReceipt->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->objReceipt->TransactionId, $objClauses); $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->txtQuantity->Focus(); } } } }
protected function btnLogin_Click($strFormId, $strControlId, $strParameter) { if ($_SERVER['REMOTE_ADDR'] != "127.0.0.1" && substr($_SERVER['REMOTE_ADDR'], 0, 8) != "192.168.") { $ip_array = json_decode(file_get_contents("http://192.168.1.168:8888/eBayBO/service.php?action=getClientIp")); //file_put_contents("/tmp/xx.log", print_r($ip_array, true)); if (!in_array($_SERVER['REMOTE_ADDR'], $ip_array)) { $blnError = true; $this->txtUsername->Warning = QApplication::Translate('Invalid username or password.'); return 0; } } $blnError = false; $strUsername = $this->txtUsername->Text; $strPassword = $this->txtPassword->Text; $objUserAccount = UserAccount::LoadByUsername($strUsername); $errorMessage = QApplication::Translate('Invalid username or password.'); // Check if that username exists if (!$objUserAccount) { $blnError = true; $this->txtUsername->Warning = $errorMessage; } elseif (!$objUserAccount->ActiveFlag) { $blnError = true; $this->txtUsername->Warning = $errorMessage; } elseif (sha1($strPassword) != $objUserAccount->PasswordHash) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } else { QApplication::Login($objUserAccount); // If the user has access to the assets module, send them there. Otherwise, send them to the home module. $objRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2); if ($objRoleModule->AccessFlag) { QApplication::Redirect('./inventory/'); } else { Qapplication::Redirect('./home/'); } } }
/** * Authorizes any control to determine if the user has access * If not, it sets the objControl->Visible to false * * @param object $objEntity - any entity with a created_by column (asset, location, etc.) * @param object $objControl - the control which is being evaluated - any QControl where visible is a property * @param integer $intAuthorizationId - the authorization required to see this control (view(1), edit(2), or delete(3)) */ public static function AuthorizeControl($objEntity, $objControl, $intAuthorizationId, $intModuleId = null) { if ($intModuleId == null) { $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId(QApplication::$objRoleModule->RoleModuleId, $intAuthorizationId); } else { $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objRoleModule->RoleId, $intModuleId); $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, $intAuthorizationId); } // Added if $objEntity == null for the ship button shortcut on the asset page. if ($objRoleModuleAuthorization->AuthorizationLevelId == 1 || $objRoleModuleAuthorization->AuthorizationLevelId == 2 && $objEntity == null || $objRoleModuleAuthorization->AuthorizationLevelId == 2 && $objEntity->CreatedBy == QApplication::$objUserAccount->UserAccountId) { $objControl->Visible = true; } else { $objControl->Visible = false; } }
protected function UpdateAuthorizations() { if ($this->objModuleArray) { foreach ($this->objModuleArray as $objModule) { if ($this->blnEditMode) { $objRoleModule = RoleModule::LoadByRoleIdModuleId($this->objRole->RoleId, $objModule->ModuleId); } else { $objRoleModule = new RoleModule(); $objRoleModule->ModuleId = $objModule->ModuleId; $objRoleModule->RoleId = $this->objRole->RoleId; } $objRoleModule->AccessFlag = $this->arrControls[$objModule->ShortDescription]['access']->SelectedValue; $objRoleModule->Save(); if ($this->objAuthorizationArray) { foreach ($this->objAuthorizationArray as $objAuthorization) { if ($this->blnEditMode) { $objRoleModuleAuthorization = $this->objRoleModuleAuthorizationArray[$objRoleModule->RoleModuleId . '-' . $objAuthorization->AuthorizationId]; } else { $objRoleModuleAuthorization = new RoleModuleAuthorization(); $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId; $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId; } $objRoleModuleAuthorization->AuthorizationLevelId = $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription]->SelectedValue; $objRoleModuleAuthorization->Save(); } } } } // Home module not implemented yet. When it is, uncomment the code below //if (!$this->blnEditMode) { // $objRoleModule = new RoleModule(); // $objRoleModule->ModuleId = 1; // $objRoleModule->RoleId = $this->objRole->RoleId; // $objRoleModule->AccessFlag = true; // $objRoleModule->Save(); //} }
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 btnLogin_Click($strFormId, $strControlId, $strParameter) { $blnError = false; $strUsername = $this->txtUsername->Text; $strPassword = $this->txtPassword->Text; $objUserAccount = UserAccount::LoadByUsername($strUsername); $errorMessage = 'Invalid username or password.'; // Check if that username exists if (!$objUserAccount) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!$objUserAccount->ActiveFlag) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!QApplication::CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } else { QApplication::Login($objUserAccount); $objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2); $objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3); $objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4); $objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5); $objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6); $objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7); $strRedirect = ''; $intModule = null; if (array_key_exists('strReferer', $_GET)) { $strRedirect = $_GET['strReferer']; } else { if ($objAssetRoleModule->AccessFlag) { // If the user has access to the assets module, send them there, otherwise... $strRedirect = __SUBDIRECTORY__ . '/assets/'; $intModule = 2; } else { if ($objInventoryRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/inventory/'; $intModule = 3; } else { if ($objContactsRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/contacts/'; $intModule = 4; } else { if ($objShippingRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/shipping/'; $intModule = 5; } else { if ($objReceivingRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/receiving/'; $intModule = 6; } else { if ($objReportsRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/reports/'; $intModule = 7; } } } } } } } QApplication::Redirect($strRedirect); } }
protected function btnLogin_Click($strFormId, $strControlId, $strParameter) { $blnError = false; $strUsername = $this->txtUsername->Text; $strPassword = $this->txtPassword->Text; $objUserAccount = UserAccount::LoadByUsername($strUsername); $errorMessage = 'Invalid username or password.'; $objHasher = new PasswordHash(8, PORTABLE_PASSWORDS); // Check if that username exists if (!$objUserAccount) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!$objUserAccount->ActiveFlag) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!$objHasher->CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } else { QApplication::Login($objUserAccount); $objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2); $objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3); $objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4); $objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5); $objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6); $objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7); if (array_key_exists('strReferer', $_GET)) { QApplication::Redirect($_GET['strReferer']); } else { if ($objAssetRoleModule->AccessFlag) { // If the user has access to the assets module, send them there, otherwise... QApplication::Redirect('./assets/'); } else { if ($objInventoryRoleModule->AccessFlag) { Qapplication::Redirect('./inventory/'); } else { if ($objContactsRoleModule->AccessFlag) { Qapplication::Redirect('./contacts/'); } else { if ($objShippingRoleModule->AccessFlag) { Qapplication::Redirect('./shipping/'); } else { if ($objReceivingRoleModule->AccessFlag) { Qapplication::Redirect('./receiving/'); } else { if ($objReportsRoleModule->AccessFlag) { Qapplication::Redirect('./reports/'); } } } } } } } } }
protected function UpdateAuthorizations() { if ($this->objModuleArray) { foreach ($this->objModuleArray as $objModule) { if ($this->blnEditMode) { $objRoleModule = RoleModule::LoadByRoleIdModuleId($this->objRole->RoleId, $objModule->ModuleId); } else { $objRoleModule = new RoleModule(); $objRoleModule->ModuleId = $objModule->ModuleId; $objRoleModule->RoleId = $this->objRole->RoleId; } $objRoleModule->AccessFlag = $this->arrControls[$objModule->ShortDescription]['access']->SelectedValue; $objRoleModule->Save(); if ($this->objAuthorizationArray) { foreach ($this->objAuthorizationArray as $objAuthorization) { if ($this->blnEditMode) { $objRoleModuleAuthorization = $this->objRoleModuleAuthorizationArray[$objRoleModule->RoleModuleId . '-' . $objAuthorization->AuthorizationId]; } else { $objRoleModuleAuthorization = new RoleModuleAuthorization(); $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId; $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId; } $objRoleModuleAuthorization->AuthorizationLevelId = $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription]->SelectedValue; $objRoleModuleAuthorization->Save(); } } } } // If creating a new Role, manually give access to the Home module //if (!$this->blnEditMode) { // $objRoleModule = new RoleModule(); // $objRoleModule->ModuleId = 1; // $objRoleModule->RoleId = $this->objRole->RoleId; // $objRoleModule->AccessFlag = true; // $objRoleModule->Save(); /* // Give view, edit, and delete access for ALL for the home module if ($this->objAuthorizationArray) { foreach ($this->objAuthorizationArray as $objAuthorization) { $objRoleModuleAuthorization = new RoleModuleAuthorization(); $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId; $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId; $objRoleModuleAuthorization->AuthorizationLevelId = 3; $objRoleModuleAuthorization->Save(); } } */ //} /* // Delete all RoleModules - this will cascade to all RoleModuleAuthorizations also if ($this->blnEditMode) { // Set the Role Module Access $objRoleModuleArray = RoleModule::LoadArrayByRoleId($this->objRole->RoleId); if ($objRoleModuleArray) { foreach ($objRoleModuleArray as $objRoleModule) { $objRoleModule->Delete(); $objRoleModule = null; } } } if ($this->objModuleArray) { foreach ($this->objModuleArray as $objModule) { $objRoleModule = new RoleModule(); $objRoleModule->ModuleId = $objModule->ModuleId; $objRoleModule->RoleId = $this->objRole->RoleId; $objRoleModule->AccessFlag = $this->arrControls[$objModule->ShortDescription]['access']->SelectedValue; $objRoleModule->Save(); if ($this->objAuthorizationArray) { foreach ($this->objAuthorizationArray as $objAuthorization) { $objRoleModuleAuthorization = new RoleModuleAuthorization(); $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId; $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId; $objRoleModuleAuthorization->AuthorizationLevelId = $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription]->SelectedValue; $objRoleModuleAuthorization->Save(); $objRoleModuleAuthorization = null; } } $objRoleModule = null; } }*/ }