|
<?php
|
|
/**
|
|
* This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
|
|
* of the Order class. It uses the code-generated
|
|
* OrderMetaControl class, which has meta-methods to help with
|
|
* easily creating/defining controls to modify the fields of a Order columns.
|
|
*
|
|
* Any display customizations and presentation-tier logic can be implemented
|
|
* here by overriding existing or implementing new methods, properties and variables.
|
|
*
|
|
* NOTE: This file is overwritten on any code regenerations. If you want to make
|
|
* permanent changes, it is STRONGLY RECOMMENDED to move both order_edit.php AND
|
|
* order_edit.tpl.php out of this Form Drafts directory.
|
|
*
|
|
* @package Quinta
|
|
* @subpackage AdminUI
|
|
*/
|
|
class OrderEditPanel extends QPanel {
|
|
// Local instance of the OrderMetaControl
|
|
protected $mctOrder;
|
|
|
|
protected $pnlListPanel;
|
|
|
|
public $dtgOrderItems;
|
|
public $pxyEditOrderItem;
|
|
public $pxyViewProduct;
|
|
public $objOrderItemsPaginator;
|
|
|
|
public $lblOrderTotal;
|
|
// Controls for Order's Data Fields
|
|
public $lblId;
|
|
public $lblAccount;
|
|
public $lblCreationDate;
|
|
public $lblLastModification;
|
|
public $calCompletionDate;
|
|
public $txtProductTotalCost;
|
|
public $txtShippingCost;
|
|
public $txtShippingCharged;
|
|
public $txtHandlingCost;
|
|
public $txtHandlingCharged;
|
|
public $txtTax;
|
|
public $txtProductTotalCharged;
|
|
public $txtNotes;
|
|
public $lstShippingMethod;
|
|
public $lstPaymentMethod;
|
|
public $lstStatus;
|
|
public $lstType;
|
|
|
|
// Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
|
|
|
|
// Other Controls
|
|
public $btnSave;
|
|
public $btnDelete;
|
|
public $btnCancel;
|
|
|
|
// Callback
|
|
protected $strClosePanelMethod;
|
|
|
|
public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null)
|
|
{
|
|
$this->pnlListPanel =& $objParentObject;
|
|
|
|
try {
|
|
parent::__construct($objParentObject, $strControlId);
|
|
} catch (QCallerException $objExc) {
|
|
$objExc->IncrementOffset();
|
|
throw $objExc;
|
|
}
|
|
|
|
$this->strTemplate = 'OrderEditPanel.tpl.php';
|
|
$this->strClosePanelMethod = $strClosePanelMethod;
|
|
|
|
$this->mctOrder = OrderMetaControl::Create($this, $intId);
|
|
|
|
$this->lblId = $this->mctOrder->lblId_Create();
|
|
$this->lblId->Name = "Order Number:";
|
|
|
|
$this->lblAccount = $this->mctOrder->lblAccountId_Create();
|
|
$this->lblAccount->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'lblAccount_Click'));
|
|
$this->lblAccount->AddCssClass('button');
|
|
$this->lblAccount->Name = 'Account No.: ' . $this->mctOrder->Order->AccountId;
|
|
|
|
$this->lblCreationDate = $this->mctOrder->lblCreationDate_Create();
|
|
$this->lblLastModification = $this->mctOrder->lblLastModification_Create();
|
|
$this->calCompletionDate = $this->mctOrder->calCompletionDate_Create();
|
|
$this->txtProductTotalCost = $this->mctOrder->txtProductTotalCost_Create();
|
|
$this->txtShippingCost = $this->mctOrder->txtShippingCost_Create();
|
|
$this->txtShippingCharged = $this->mctOrder->txtShippingCharged_Create();
|
|
$this->txtHandlingCost = $this->mctOrder->txtHandlingCost_Create();
|
|
$this->txtHandlingCharged = $this->mctOrder->txtHandlingCharged_Create();
|
|
$this->txtTax = $this->mctOrder->txtTax_Create();
|
|
$this->txtProductTotalCharged = $this->mctOrder->txtProductTotalCharged_Create();
|
|
$this->txtNotes = $this->mctOrder->txtNotes_Create();
|
|
$this->lstShippingMethod = $this->mctOrder->lstShippingMethod_Create();
|
|
$this->lstPaymentMethod = $this->mctOrder->lstPaymentMethod_Create();
|
|
$this->lstStatus = $this->mctOrder->lstStatus_Create();
|
|
$this->lstType = $this->mctOrder->lstType_Create();
|
|
|
|
$strOrderTotal = money_format("%n", $this->mctOrder->Order->ProductTotalCharged
|
|
+ $this->mctOrder->Order->ShippingCharged
|
|
+ $this->mctOrder->Order->HandlingCharged
|
|
+ $this->mctOrder->Order->Tax );
|
|
$this->lblOrderTotal = new QLabel($this);
|
|
$this->lblOrderTotal->Name = 'Order Total: ';
|
|
$this->lblOrderTotal->Text = $strOrderTotal;
|
|
|
|
// Create Buttons and Actions on this Form
|
|
$this->btnSave = new QButton($this);
|
|
$this->btnSave->Text = QApplication::Translate('Save');
|
|
$this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
|
|
$this->btnSave->CausesValidation = $this;
|
|
|
|
$this->btnCancel = new QButton($this);
|
|
$this->btnCancel->Text = QApplication::Translate('Cancel');
|
|
$this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
|
|
|
|
$this->btnDelete = new QButton($this);
|
|
$this->btnDelete->Text = QApplication::Translate('Delete');
|
|
$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Order') . '?'));
|
|
$this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
|
|
$this->btnDelete->Visible = $this->mctOrder->EditMode;
|
|
|
|
$this->dtgOrderItems = new OrderItemDataGrid($this);
|
|
|
|
$this->dtgOrderItems->CssClass = 'datagrid';
|
|
$this->dtgOrderItems->SetDataBinder('OrderItemsDataBinder', $this);
|
|
$this->dtgOrderItems->AlternateRowStyle->CssClass = 'alternate';
|
|
$this->objOrderItemsPaginator = new QPaginator($this->dtgOrderItems);
|
|
$this->dtgOrderItems->Paginator = $this->objOrderItemsPaginator;
|
|
$this->dtgOrderItems->ItemsPerPage = 20;
|
|
|
|
$this->pxyEditOrderItem = new QControlProxy($this);
|
|
$this->pxyEditOrderItem->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyEditOrderItem_Click'));
|
|
$this->pxyViewProduct = new QControlProxy($this);
|
|
$this->pxyViewProduct->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyViewProduct_Click'));
|
|
$this->dtgOrderItems->MetaAddEditProxyColumn($this->pxyEditOrderItem, 'Edit', 'Edit');
|
|
$this->dtgOrderItems->MetaAddProxyColumn($this->pxyViewProduct, QQN::OrderItem()->Product);
|
|
$this->dtgOrderItems->MetaAddColumn('Quantity');
|
|
|
|
$strItemPriceParam = '<?= money_format("%n", $_ITEM->Product->RetailPrice ) ?>';
|
|
$objItemPriceColumn = new QDataGridColumn('Item Price', $strItemPriceParam );
|
|
$this->dtgOrderItems->AddColumn($objItemPriceColumn);
|
|
|
|
$strItemTotalParam = '<?= money_format("%n", $_ITEM->Quantity '
|
|
. ' * $_ITEM->Product->RetailPrice ) ?>';
|
|
$objItemTotalColumn = new QDataGridColumn('Item Total', $strItemTotalParam );
|
|
$this->dtgOrderItems->AddColumn($objItemTotalColumn);
|
|
|
|
}
|
|
|
|
public function lblAccount_Click($strFormId, $strControlId, $strParameter)
|
|
{
|
|
$objEditPanel = new AccountEditPanel($this->pnlListPanel, 'CloseEditPane', $this->mctOrder->Order->AccountId);
|
|
$this->objForm->SetEditPane($objEditPanel);
|
|
}
|
|
public function pxyEditOrderItem_Click($strFormId, $strControlId, $strParameter)
|
|
{
|
|
$strParameterArray = explode(',', $strParameter);
|
|
// $objEditPanel = new OrderItemEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0], $strParameterArray[1]);
|
|
$objEditPanel = new OrderItemEditPanel($this->pnlListPanel, 'CloseEditPane', $strParameterArray[0], $strParameterArray[1]);
|
|
$this->objForm->SetEditPane($objEditPanel);
|
|
}
|
|
public function pxyViewProduct_Click($strFormId, $strControlId, $strParameter)
|
|
{
|
|
$strParameterArray = explode(',', $strParameter);
|
|
$objOrderItem = OrderItem::Load($strParameterArray[0], $strParameterArray[1]);
|
|
|
|
// $objEditPanel = new OrderItemEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0], $strParameterArray[1]);
|
|
$objEditPanel = new ProductEditPanel($this->pnlListPanel, 'CloseEditPane', $objOrderItem->ProductId);
|
|
$this->objForm->SetEditPane($objEditPanel);
|
|
}
|
|
|
|
/**
|
|
* This binds the OrderItems Datagrid data retrieval to this Order, the items listed in the Datagrid will be those
|
|
* associated with this user in the database.
|
|
*
|
|
* If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used.
|
|
* It will also perform any sorting requested in by clicking on the column titles in the Datagrid.
|
|
*/
|
|
public function OrderItemsDataBinder()
|
|
{
|
|
if ($this->objOrderItemsPaginator)
|
|
$this->dtgOrderItems->TotalItemCount = OrderItem::CountByOrderId($this->mctOrder->Order->Id) ;
|
|
|
|
$objClauses = array();
|
|
|
|
// If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
|
|
// the OrderByClause to the $objClauses array - this is in the datagrid if the user clicks on column title
|
|
if ($objClause = $this->dtgOrderItems->OrderByClause)
|
|
array_push($objClauses, $objClause);
|
|
|
|
// Add the LimitClause information, as well
|
|
if ($objClause = $this->dtgOrderItems->LimitClause)
|
|
array_push($objClauses, $objClause);
|
|
|
|
// array_push($objClauses, QQ::OrderBy(QQN::OrderItem()->CreationDate, false) );
|
|
|
|
$intOrderId = $this->mctOrder->Order->Id;
|
|
$this->dtgOrderItems->DataSource = OrderItem::LoadArrayByOrderId(
|
|
$intOrderId, $objClauses
|
|
);
|
|
}
|
|
|
|
// Control AjaxAction Event Handlers
|
|
public function btnSave_Click($strFormId, $strControlId, $strParameter) {
|
|
// Delegate "Save" processing to the OrderMetaControl
|
|
$this->mctOrder->SaveOrder();
|
|
$this->CloseSelf(true);
|
|
}
|
|
|
|
public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
|
|
// Delegate "Delete" processing to the OrderMetaControl
|
|
$this->mctOrder->DeleteOrder();
|
|
$this->CloseSelf(true);
|
|
}
|
|
|
|
public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
|
|
$this->CloseSelf(false);
|
|
}
|
|
|
|
// Close Myself and Call ClosePanelMethod Callback
|
|
protected function CloseSelf($blnChangesMade) {
|
|
$strMethod = $this->strClosePanelMethod;
|
|
$this->objForm->$strMethod($blnChangesMade);
|
|
}
|
|
}
|
|
?>
|