protected function Form_Create() { // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_FORM->dtgShipment_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colShipmentId = new QDataGridColumn(QApplication::Translate('Shipment Id'), '<?= $_ITEM->ShipmentId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentId, false))); $this->colShipmentNumber = new QDataGridColumn(QApplication::Translate('Shipment Number'), '<?= QString::Truncate($_ITEM->ShipmentNumber, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentNumber), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentNumber, false))); $this->colTransactionId = new QDataGridColumn(QApplication::Translate('Transaction Id'), '<?= $_FORM->dtgShipment_Transaction_Render($_ITEM); ?>'); $this->colFromCompanyId = new QDataGridColumn(QApplication::Translate('From Company Id'), '<?= $_FORM->dtgShipment_FromCompany_Render($_ITEM); ?>'); $this->colFromContactId = new QDataGridColumn(QApplication::Translate('From Contact Id'), '<?= $_FORM->dtgShipment_FromContact_Render($_ITEM); ?>'); $this->colFromAddressId = new QDataGridColumn(QApplication::Translate('From Address Id'), '<?= $_FORM->dtgShipment_FromAddress_Render($_ITEM); ?>'); $this->colToCompanyId = new QDataGridColumn(QApplication::Translate('To Company Id'), '<?= $_FORM->dtgShipment_ToCompany_Render($_ITEM); ?>'); $this->colToContactId = new QDataGridColumn(QApplication::Translate('To Contact Id'), '<?= $_FORM->dtgShipment_ToContact_Render($_ITEM); ?>'); $this->colToAddressId = new QDataGridColumn(QApplication::Translate('To Address Id'), '<?= $_FORM->dtgShipment_ToAddress_Render($_ITEM); ?>'); $this->colCourierId = new QDataGridColumn(QApplication::Translate('Courier Id'), '<?= $_FORM->dtgShipment_Courier_Render($_ITEM); ?>'); $this->colTrackingNumber = new QDataGridColumn(QApplication::Translate('Tracking Number'), '<?= QString::Truncate($_ITEM->TrackingNumber, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->TrackingNumber), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->TrackingNumber, false))); $this->colShipDate = new QDataGridColumn(QApplication::Translate('Ship Date'), '<?= $_FORM->dtgShipment_ShipDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipDate, false))); $this->colShippedFlag = new QDataGridColumn(QApplication::Translate('Shipped Flag'), '<?= ($_ITEM->ShippedFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShippedFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShippedFlag, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_FORM->dtgShipment_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_FORM->dtgShipment_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_FORM->dtgShipment_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ModifiedDate, false))); $this->colShipmentCustomFieldHelper = new QDataGridColumn(QApplication::Translate('Shipment Custom Field Helper'), '<?= $_FORM->dtgShipment_ShipmentCustomFieldHelper_Render($_ITEM); ?>'); // Setup DataGrid $this->dtgShipment = new QDataGrid($this); $this->dtgShipment->CellSpacing = 0; $this->dtgShipment->CellPadding = 4; $this->dtgShipment->BorderStyle = QBorderStyle::Solid; $this->dtgShipment->BorderWidth = 1; $this->dtgShipment->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgShipment->Paginator = new QPaginator($this->dtgShipment); $this->dtgShipment->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgShipment->UseAjax = false; // Specify the local databind method this datagrid will use $this->dtgShipment->SetDataBinder('dtgShipment_Bind'); $this->dtgShipment->AddColumn($this->colEditLinkColumn); $this->dtgShipment->AddColumn($this->colShipmentId); $this->dtgShipment->AddColumn($this->colShipmentNumber); $this->dtgShipment->AddColumn($this->colTransactionId); $this->dtgShipment->AddColumn($this->colFromCompanyId); $this->dtgShipment->AddColumn($this->colFromContactId); $this->dtgShipment->AddColumn($this->colFromAddressId); $this->dtgShipment->AddColumn($this->colToCompanyId); $this->dtgShipment->AddColumn($this->colToContactId); $this->dtgShipment->AddColumn($this->colToAddressId); $this->dtgShipment->AddColumn($this->colCourierId); $this->dtgShipment->AddColumn($this->colTrackingNumber); $this->dtgShipment->AddColumn($this->colShipDate); $this->dtgShipment->AddColumn($this->colShippedFlag); $this->dtgShipment->AddColumn($this->colCreatedBy); $this->dtgShipment->AddColumn($this->colCreationDate); $this->dtgShipment->AddColumn($this->colModifiedBy); $this->dtgShipment->AddColumn($this->colModifiedDate); $this->dtgShipment->AddColumn($this->colShipmentCustomFieldHelper); }
/** * Count Shipments * by FromCompanyId Index(es) * @param integer $intFromCompanyId * @return int */ public static function CountByFromCompanyId($intFromCompanyId) { // Call Shipment::QueryCount to perform the CountByFromCompanyId query return Shipment::QueryCount(QQ::Equal(QQN::Shipment()->FromCompanyId, $intFromCompanyId)); }
public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } // Record Method Callbacks $this->strSetEditPanelMethod = $strSetEditPanelMethod; $this->strCloseEditPanelMethod = $strCloseEditPanelMethod; // Setup DataGrid Columns $this->colEditLinkColumn = new QDataGridColumn(QApplication::Translate('Edit'), '<?= $_CONTROL->ParentControl->dtgShipment_EditLinkColumn_Render($_ITEM) ?>'); $this->colEditLinkColumn->HtmlEntities = false; $this->colShipmentId = new QDataGridColumn(QApplication::Translate('Shipment Id'), '<?= $_ITEM->ShipmentId; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentId), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentId, false))); $this->colShipmentNumber = new QDataGridColumn(QApplication::Translate('Shipment Number'), '<?= QString::Truncate($_ITEM->ShipmentNumber, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentNumber), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipmentNumber, false))); $this->colTransactionId = new QDataGridColumn(QApplication::Translate('Transaction Id'), '<?= $_CONTROL->ParentControl->dtgShipment_Transaction_Render($_ITEM); ?>'); $this->colFromCompanyId = new QDataGridColumn(QApplication::Translate('From Company Id'), '<?= $_CONTROL->ParentControl->dtgShipment_FromCompany_Render($_ITEM); ?>'); $this->colFromContactId = new QDataGridColumn(QApplication::Translate('From Contact Id'), '<?= $_CONTROL->ParentControl->dtgShipment_FromContact_Render($_ITEM); ?>'); $this->colFromAddressId = new QDataGridColumn(QApplication::Translate('From Address Id'), '<?= $_CONTROL->ParentControl->dtgShipment_FromAddress_Render($_ITEM); ?>'); $this->colToCompanyId = new QDataGridColumn(QApplication::Translate('To Company Id'), '<?= $_CONTROL->ParentControl->dtgShipment_ToCompany_Render($_ITEM); ?>'); $this->colToContactId = new QDataGridColumn(QApplication::Translate('To Contact Id'), '<?= $_CONTROL->ParentControl->dtgShipment_ToContact_Render($_ITEM); ?>'); $this->colToAddressId = new QDataGridColumn(QApplication::Translate('To Address Id'), '<?= $_CONTROL->ParentControl->dtgShipment_ToAddress_Render($_ITEM); ?>'); $this->colCourierId = new QDataGridColumn(QApplication::Translate('Courier Id'), '<?= $_CONTROL->ParentControl->dtgShipment_Courier_Render($_ITEM); ?>'); $this->colTrackingNumber = new QDataGridColumn(QApplication::Translate('Tracking Number'), '<?= QString::Truncate($_ITEM->TrackingNumber, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->TrackingNumber), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->TrackingNumber, false))); $this->colShipDate = new QDataGridColumn(QApplication::Translate('Ship Date'), '<?= $_CONTROL->ParentControl->dtgShipment_ShipDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShipDate, false))); $this->colShippedFlag = new QDataGridColumn(QApplication::Translate('Shipped Flag'), '<?= ($_ITEM->ShippedFlag) ? "true" : "false" ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ShippedFlag), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ShippedFlag, false))); $this->colCreatedBy = new QDataGridColumn(QApplication::Translate('Created By'), '<?= $_CONTROL->ParentControl->dtgShipment_CreatedByObject_Render($_ITEM); ?>'); $this->colCreationDate = new QDataGridColumn(QApplication::Translate('Creation Date'), '<?= $_CONTROL->ParentControl->dtgShipment_CreationDate_Render($_ITEM); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->CreationDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->CreationDate, false))); $this->colModifiedBy = new QDataGridColumn(QApplication::Translate('Modified By'), '<?= $_CONTROL->ParentControl->dtgShipment_ModifiedByObject_Render($_ITEM); ?>'); $this->colModifiedDate = new QDataGridColumn(QApplication::Translate('Modified Date'), '<?= QString::Truncate($_ITEM->ModifiedDate, 200); ?>', array('OrderByClause' => QQ::OrderBy(QQN::Shipment()->ModifiedDate), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Shipment()->ModifiedDate, false))); // Setup DataGrid $this->dtgShipment = new QDataGrid($this); $this->dtgShipment->CellSpacing = 0; $this->dtgShipment->CellPadding = 4; $this->dtgShipment->BorderStyle = QBorderStyle::Solid; $this->dtgShipment->BorderWidth = 1; $this->dtgShipment->GridLines = QGridLines::Both; // Datagrid Paginator $this->dtgShipment->Paginator = new QPaginator($this->dtgShipment); $this->dtgShipment->ItemsPerPage = 10; // Specify Whether or Not to Refresh using Ajax $this->dtgShipment->UseAjax = true; // Specify the local databind method this datagrid will use $this->dtgShipment->SetDataBinder('dtgShipment_Bind', $this); $this->dtgShipment->AddColumn($this->colEditLinkColumn); $this->dtgShipment->AddColumn($this->colShipmentId); $this->dtgShipment->AddColumn($this->colShipmentNumber); $this->dtgShipment->AddColumn($this->colTransactionId); $this->dtgShipment->AddColumn($this->colFromCompanyId); $this->dtgShipment->AddColumn($this->colFromContactId); $this->dtgShipment->AddColumn($this->colFromAddressId); $this->dtgShipment->AddColumn($this->colToCompanyId); $this->dtgShipment->AddColumn($this->colToContactId); $this->dtgShipment->AddColumn($this->colToAddressId); $this->dtgShipment->AddColumn($this->colCourierId); $this->dtgShipment->AddColumn($this->colTrackingNumber); $this->dtgShipment->AddColumn($this->colShipDate); $this->dtgShipment->AddColumn($this->colShippedFlag); $this->dtgShipment->AddColumn($this->colCreatedBy); $this->dtgShipment->AddColumn($this->colCreationDate); $this->dtgShipment->AddColumn($this->colModifiedBy); $this->dtgShipment->AddColumn($this->colModifiedDate); // Setup the Create New button $this->btnCreateNew = new QButton($this); $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Shipment'); $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click')); }
/** * Used internally by the Meta-based Add Column tools. * * Given a QQNode or a Text String, this will return a Shipment-based QQNode. * It will also verify that it is a proper Shipment-based QQNode, and will throw an exception otherwise. * * @param mixed $mixContent * @return QQNode */ protected function ResolveContentItem($mixContent) { if ($mixContent instanceof QQNode) { if (!$mixContent->_ParentNode) { throw new QCallerException('Content QQNode cannot be a Top Level Node'); } if ($mixContent->_RootTableName == 'shipment') { if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } $objCurrentNode = $mixContent; while ($objCurrentNode = $objCurrentNode->_ParentNode) { if (!$objCurrentNode instanceof QQNode) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } } return $mixContent; } else { throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "shipment".'); } } else { if (is_string($mixContent)) { switch ($mixContent) { case 'ShipmentId': return QQN::Shipment()->ShipmentId; case 'ShipmentNumber': return QQN::Shipment()->ShipmentNumber; case 'TransactionId': return QQN::Shipment()->TransactionId; case 'Transaction': return QQN::Shipment()->Transaction; case 'FromCompanyId': return QQN::Shipment()->FromCompanyId; case 'FromCompany': return QQN::Shipment()->FromCompany; case 'FromContactId': return QQN::Shipment()->FromContactId; case 'FromContact': return QQN::Shipment()->FromContact; case 'FromAddressId': return QQN::Shipment()->FromAddressId; case 'FromAddress': return QQN::Shipment()->FromAddress; case 'ToCompanyId': return QQN::Shipment()->ToCompanyId; case 'ToCompany': return QQN::Shipment()->ToCompany; case 'ToContactId': return QQN::Shipment()->ToContactId; case 'ToContact': return QQN::Shipment()->ToContact; case 'ToAddressId': return QQN::Shipment()->ToAddressId; case 'ToAddress': return QQN::Shipment()->ToAddress; case 'CourierId': return QQN::Shipment()->CourierId; case 'Courier': return QQN::Shipment()->Courier; case 'TrackingNumber': return QQN::Shipment()->TrackingNumber; case 'ShipDate': return QQN::Shipment()->ShipDate; case 'ShippedFlag': return QQN::Shipment()->ShippedFlag; case 'CreatedBy': return QQN::Shipment()->CreatedBy; case 'CreatedByObject': return QQN::Shipment()->CreatedByObject; case 'CreationDate': return QQN::Shipment()->CreationDate; case 'ModifiedBy': return QQN::Shipment()->ModifiedBy; case 'ModifiedByObject': return QQN::Shipment()->ModifiedByObject; case 'ModifiedDate': return QQN::Shipment()->ModifiedDate; case 'ShipmentCustomFieldHelper': return QQN::Shipment()->ShipmentCustomFieldHelper; default: throw new QCallerException('Simple Property not found in ShipmentDataGrid content: ' . $mixContent); } } else { if ($mixContent instanceof QQAssociationNode) { throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.'); } else { throw new QCallerException('Invalid Content type'); } } } }
public function btnApply_Click($strFormId, $strControlId, $strParameter) { $this->clearWarnings(); $blnError = false; $objDatabase = QApplication::$Database[1]; // Begin a MySQL Transaction to be either committed or rolled back $objDatabase->TransactionBegin(); // Check "Contact To", "Contact From", "Coutrier" wasn't changed for shipped items if (Shipment::QueryCount(QQ::AndCondition(QQ::Equal(QQN::Shipment()->ShippedFlag, 1), QQ::In(QQN::Shipment()->ShipmentId, $this->arrShipmentToEdit))) > 0 && ($this->chkToCompany->Checked || $this->chkFromCompany->Checked || $this->chkCourier->Checked)) { $this->lblWarning->Text = '"To Company", "From Company", "Courier" shouldn\'t be changed for already Shipped items'; $blnError = true; } if (!$blnError) { // Apply checked main_table fields $set = array(sprintf('`modified_by`= %s', QApplication::$objUserAccount->UserAccountId)); if ($this->chkToCompany->Checked) { if ($this->lstToCompany->SelectedValue) { $set[] = sprintf('`to_company_id`="%s"', $this->lstToCompany->SelectedValue); } else { $this->lstToCompany->Warning = 'Company name must be chosen'; $blnError = true; } if ($this->lstToContact->SelectedValue) { $set[] = sprintf('`to_contact_id`="%s"', $this->lstToContact->SelectedValue); } else { $this->lstToContact->Warning = 'Contact name must be chosen'; $blnError = true; } if ($this->lstToAddress->SelectedValue) { $set[] = sprintf('`to_address_id`="%s"', $this->lstToAddress->SelectedValue); } else { $this->lstToContact->Warning = 'Address name must be chosen'; $blnError = true; } } if ($this->chkFromCompany->Checked) { if ($this->lstFromCompany->SelectedValue) { $set[] = sprintf('`from_company_id`="%s"', $this->lstFromCompany->SelectedValue); } else { $this->lstFromCompany->Warning = 'Company name must be chosen'; $blnError = true; } if ($this->lstFromContact->SelectedValue) { $set[] = sprintf('`from_contact_id`="%s"', $this->lstFromContact->SelectedValue); } else { $this->lstFromContact->Warning = 'Contact name must be chosen'; $blnError = true; } if ($this->lstFromAddress->SelectedValue) { $set[] = sprintf('`from_address_id`="%s"', $this->lstFromAddress->SelectedValue); } else { $this->lstFromAddress->Warning = 'Address name must be chosen'; $blnError = true; } } if ($this->chkCourier->Checked) { $set[] = sprintf('`courier_id`="%s"', $this->lstCourier->SelectedValue); } if ($this->chkShipDate->Checked && $this->calShipDate->DateTime) { $set[] = sprintf('`ship_date`="%s"', $this->calShipDate->DateTime->__toString('YYYY-MM-DD')); } } if (count($this->arrCustomFields) > 0) { $customFieldIdArray = array(); foreach ($this->arrCustomFields as $field) { if ($this->arrCheckboxes[$field['input']->strControlId]->Checked) { if ($field['input'] instanceof QTextBox && $field['input']->Required && $field['input']->Text == null || $field['input'] instanceof QListBox && $field['input']->Required && $field['input']->SelectedValue == null) { $blnError = true; $field['input']->Warning = "Required."; } else { $this->arrCustomFieldsToEdit[] = $field; $customFieldIdArray[] = (int) str_replace('cf', '', $field['input']->strControlId); } } } } // Apdate main table if (!$blnError) { try { // Edit Transactions foreach ($this->arrShipmentToEdit as $intShipmetId) { $objTransaction = Transaction::Load(Shipment::Load($intShipmetId)->Transaction->TransactionId); $objTransaction->ModifiedBy = QApplication::$objUserAccount->UserAccountId; if ($this->chkNote->Checked) { $objTransaction->Note = $this->txtNote->Text; } $objTransaction->Save(); } if (count($this->arrCustomFieldsToEdit) > 0) { // preparing data to edit // Save the values from all of the custom field controls to save the asset foreach ($this->arrShipmentToEdit as $intShipmentId) { $objCustomFieldsArray = CustomField::LoadObjCustomFieldArray(EntityQtype::Shipment, false); $selectedCustomFieldsArray = array(); foreach ($objCustomFieldsArray as $objCustomField) { if (in_array($objCustomField->CustomFieldId, $customFieldIdArray)) { $selectedCustomFieldsArray[] = $objCustomField; } } CustomField::SaveControls($selectedCustomFieldsArray, true, $this->arrCustomFieldsToEdit, $intShipmentId, EntityQtype::Shipment); } } $strQuery = sprintf("UPDATE `shipment`\n SET " . implode(",", $set) . "\n WHERE `shipment_id` IN (%s)", implode(",", $this->arrShipmentToEdit)); $objDatabase->NonQuery($strQuery); $objDatabase->TransactionCommit(); $this->ParentControl->HideDialogBox(); QApplication::Redirect(''); } catch (QMySqliDatabaseException $objExc) { $objDatabase->TransactionRollback(); throw new QDatabaseException(); } } else { $objDatabase->TransactionRollback(); $this->arrCustomFieldsToEdit = array(); $this->uncheck(); } }
/** * Check if Shipment contains company * by CompanyId Index(es) * @param integer $intCompanyId * @return bool */ public static function hasCompany($intCompanyId) { try { $intShipments = Shipment::QueryCount(QQ::OrCondition(QQ::Equal(QQN::Shipment()->FromCompanyId, $intCompanyId), QQ::Equal(QQN::Shipment()->ToCompanyId, $intCompanyId))); return $intShipments > 0 ? true : false; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }