A QCodo powered CMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
8.7 KiB

  1. <?php
  2. /**
  3. * This is the abstract Panel class for the List All functionality
  4. * of the Order class. This code-generated class
  5. * contains a datagrid to display an HTML page that can
  6. * list a collection of Order objects. It includes
  7. * functionality to perform pagination and sorting on columns.
  8. *
  9. * To take advantage of some (or all) of these control objects, you
  10. * must create a new QPanel which extends this OrderListPanelBase
  11. * class.
  12. *
  13. * Any and all changes to this file will be overwritten with any subsequent re-
  14. * code generation.
  15. *
  16. * @package Quinta
  17. * @subpackage AdminUI
  18. *
  19. */
  20. class OrderListPanel extends QPanel {
  21. // Local instance of the Meta DataGrid to list Orders
  22. public $dtgOrders;
  23. // Other public QControls in this panel
  24. public $btnCreateNew;
  25. public $pxyViewOrder;
  26. public $pxyViewAccount;
  27. public $lblMessage;
  28. public $txtOrderNumberSearch;
  29. public $txtAccountNumberSearch;
  30. public $lstStatus;
  31. protected $intOrderStatusId = null;
  32. protected $intAccountId = null;
  33. // Callback Method Names
  34. protected $strSetEditPanelMethod;
  35. protected $strCloseEditPanelMethod;
  36. public function __construct($objParentObject, $strSetEditPanelMethod, $strCloseEditPanelMethod, $strControlId = null) {
  37. // Call the Parent
  38. try {
  39. parent::__construct($objParentObject, $strControlId);
  40. } catch (QCallerException $objExc) {
  41. $objExc->IncrementOffset();
  42. throw $objExc;
  43. }
  44. // Record Method Callbacks
  45. $this->strSetEditPanelMethod = $strSetEditPanelMethod;
  46. $this->strCloseEditPanelMethod = $strCloseEditPanelMethod;
  47. // Setup the Template
  48. $this->Template = 'OrderListPanel.tpl.php';
  49. //messages (eg. Name not found ..)
  50. $this->lblMessage = new QLabel($this);
  51. $this->txtOrderNumberSearch = new QIntegerTextBox($this);
  52. $this->txtOrderNumberSearch->AddAction(new QEnterKeyEvent(), new QServerControlAction($this, 'txtViewOrder_Click'));
  53. $this->txtOrderNumberSearch->Name = 'Order No.:';
  54. $this->txtOrderNumberSearch->Width = '5em';
  55. $this->txtOrderNumberSearch->CausesValidation = $this->txtOrderNumberSearch;
  56. $this->txtAccountNumberSearch = new QIntegerTextBox($this);
  57. $this->txtAccountNumberSearch->AddAction(new QEnterKeyEvent(), new QServerControlAction($this, 'txtViewByAccount_Click'));
  58. $this->txtAccountNumberSearch->Name = 'Account No.:';
  59. $this->txtAccountNumberSearch->Width = '5em';
  60. $this->txtAccountNumberSearch->CausesValidation = $this->txtAccountNumberSearch;
  61. $this->lstStatus = new QListBox($this, $strControlId);
  62. $this->lstStatus->Name = 'Select Status:';
  63. $this->lstStatus->AddItem(new QListItem('Any', 0));
  64. foreach (OrderStatusType::$NameArray as $intId => $strValue)
  65. $this->lstStatus->AddItem(new QListItem($strValue, $intId+1));
  66. $this->lstStatus->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstStatus_Selected') );
  67. // Instantiate the Meta DataGrid
  68. $this->dtgOrders = new OrderDataGrid($this);
  69. $this->dtgOrders->SetDataBinder('OrderDataBinder', $this);
  70. $this->dtgOrders->CssClass = 'datagrid';
  71. $this->dtgOrders->AlternateRowStyle->CssClass = 'alternate';
  72. $this->dtgOrders->Paginator = new QPaginator($this->dtgOrders);
  73. $this->dtgOrders->ItemsPerPage = 25;
  74. $this->pxyViewOrder = new QControlProxy($this);
  75. $this->pxyViewOrder->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyViewOrder_Click'));
  76. $this->pxyViewAccount = new QControlProxy($this);
  77. $this->pxyViewAccount->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'pxyViewAccount_Click'));
  78. $this->dtgOrders->MetaAddProxyColumn($this->pxyViewOrder, 'Id');
  79. $this->dtgOrders->MetaAddProxyColumn($this->pxyViewAccount, QQN::Order()->Account);
  80. $this->dtgOrders->GetColumn(0)->Name = "Order Number";
  81. $this->dtgOrders->MetaAddColumn('CreationDate');
  82. $this->dtgOrders->MetaAddColumn('LastModification');
  83. $this->dtgOrders->MetaAddColumn('CompletionDate');
  84. $this->dtgOrders->MetaAddColumn(QQN::Order()->ShippingMethod);
  85. $this->dtgOrders->MetaAddColumn(QQN::Order()->PaymentMethod);
  86. $this->dtgOrders->MetaAddTypeColumn('StatusId', 'OrderStatusType');
  87. $strOrderTotalParam = '<?= money_format("%n", $_ITEM->ProductTotalCharged '
  88. . ' + $_ITEM->ShippingCharged '
  89. . ' + $_ITEM->HandlingCharged '
  90. . ' + $_ITEM->Tax ) ?>';
  91. $objOrderTotalColumn = new QDataGridColumn('Order Total', $strOrderTotalParam );
  92. $this->dtgOrders->AddColumn($objOrderTotalColumn);
  93. $this->dtgOrders->MetaAddColumn('ShippingCost');
  94. $this->dtgOrders->MetaAddColumn('ProductTotalCost');
  95. $this->dtgOrders->MetaAddColumn('ShippingCost');
  96. $this->dtgOrders->MetaAddColumn('ShippingCharged');
  97. $this->dtgOrders->MetaAddColumn('HandlingCost');
  98. $this->dtgOrders->MetaAddColumn('HandlingCharged');
  99. $this->dtgOrders->MetaAddColumn('Tax');
  100. $this->dtgOrders->MetaAddColumn('ProductTotalCharged');
  101. $this->dtgOrders->MetaAddColumn('Notes');
  102. $this->dtgOrders->MetaAddColumn(QQN::Order()->ShippingMethod);
  103. $this->dtgOrders->MetaAddColumn(QQN::Order()->PaymentMethod);
  104. $this->dtgOrders->MetaAddTypeColumn('StatusId', 'OrderStatusType');
  105. $this->dtgOrders->MetaAddTypeColumn('TypeId', 'OrderType');
  106. // Setup the Create New button
  107. $this->btnCreateNew = new QButton($this);
  108. $this->btnCreateNew->Text = QApplication::Translate('Create a New') . ' ' . QApplication::Translate('Order');
  109. $this->btnCreateNew->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCreateNew_Click'));
  110. }
  111. public function pxyViewAccount_Click($strFormId, $strControlId, $intOrderId)
  112. {
  113. $objOrder = Order::Load($intOrderId);
  114. if( $objOrder instanceof Order )
  115. {
  116. $objEditPanel = new AccountEditPanel($this, $this->strCloseEditPanelMethod, $objOrder->AccountId );
  117. $strMethodName = $this->strSetEditPanelMethod;
  118. $this->objForm->$strMethodName($objEditPanel);
  119. }
  120. }
  121. public function pxyViewOrder_Click($strFormId, $strControlId, $strParameter)
  122. {
  123. $strParameterArray = explode(',', $strParameter);
  124. $objEditPanel = new OrderEditPanel($this, $this->strCloseEditPanelMethod, $strParameterArray[0]);
  125. $strMethodName = $this->strSetEditPanelMethod;
  126. $this->objForm->$strMethodName($objEditPanel);
  127. }
  128. public function txtViewOrder_Click($strFormId, $strControlId, $strParameter)
  129. {
  130. $intOrderId = $this->txtOrderNumberSearch->Text;
  131. if(Order::Load($intOrderId))
  132. {
  133. $this->lblMessage->Text = '';
  134. $objEditPanel = new OrderEditPanel($this, $this->strCloseEditPanelMethod, $intOrderId );
  135. $strMethodName = $this->strSetEditPanelMethod;
  136. $this->objForm->$strMethodName($objEditPanel);
  137. }
  138. else
  139. $this->lblMessage->Text = 'Order ' . $intOrderId . ' not found.';
  140. }
  141. public function txtViewByAccount_Click($strFormId, $strControlId, $strParameter)
  142. {
  143. $this->intAccountId = $this->txtAccountNumberSearch->Text;
  144. $this->dtgOrders->Refresh();
  145. }
  146. public function lstStatus_Selected($strFormId, $strControlId, $strParameter)
  147. {
  148. $this->intOrderStatusId = $this->lstStatus->SelectedIndex;
  149. $this->dtgOrders->Refresh();
  150. }
  151. public function OrderDataBinder()
  152. {
  153. $objClauses = array();
  154. if ($objClause = $this->dtgOrders->OrderByClause)
  155. array_push($objClauses, $objClause);
  156. if ($objClause = $this->dtgOrders->LimitClause)
  157. array_push($objClauses, $objClause);
  158. if($this->intOrderStatusId && $this->intAccountId)
  159. {
  160. $this->dtgOrders->TotalItemCount = Order::QueryCount(QQ::AndCondition(
  161. QQ::Equal( QQN::Order()->AccountId, $this->intAccountId),
  162. QQ::Equal( QQN::Order()->StatusId, $this->intOrderStatusId)));
  163. $aryOrders = Order::QueryArray( QQ::AndCondition(
  164. QQ::Equal( QQN::Order()->AccountId, $this->intAccountId),
  165. QQ::Equal( QQN::Order()->StatusId, $this->intOrderStatusId)),
  166. $objClauses );
  167. }
  168. elseif($this->intOrderStatusId )
  169. {
  170. $this->dtgOrders->TotalItemCount = Order::QueryCount(QQ::Equal(QQN::Order()->StatusId, $this->intOrderStatusId));
  171. $aryOrders = Order::QueryArray(QQ::Equal( QQN::Order()->StatusId, $this->intOrderStatusId), $objClauses );
  172. }
  173. elseif($this->intAccountId )
  174. {
  175. $this->dtgOrders->TotalItemCount = Order::QueryCount(QQ::Equal(QQN::Order()->AccountId, $this->intAccountId));
  176. $aryOrders = Order::QueryArray(QQ::Equal( QQN::Order()->AccountId, $this->intAccountId), $objClauses );
  177. }
  178. else
  179. {
  180. $this->dtgOrders->TotalItemCount = Order::CountAll();
  181. $aryOrders = Order::LoadAll( $objClauses );
  182. }
  183. $this->dtgOrders->DataSource = $aryOrders;
  184. }
  185. public function btnCreateNew_Click($strFormId, $strControlId, $strParameter)
  186. {
  187. $objEditPanel = new OrderEditPanel($this, $this->strCloseEditPanelMethod, null);
  188. $strMethodName = $this->strSetEditPanelMethod;
  189. $this->objForm->$strMethodName($objEditPanel);
  190. }
  191. }
  192. ?>