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.

438 lines
20 KiB

  1. <?php
  2. /**
  3. * This is a MetaControl class, providing a QForm or QPanel access to event handlers
  4. * and QControls to perform the Create, Edit, and Delete functionality
  5. * of the OrderStatusHistory class. This code-generated class
  6. * contains all the basic elements to help a QPanel or QForm display an HTML form that can
  7. * manipulate a single OrderStatusHistory object.
  8. *
  9. * To take advantage of some (or all) of these control objects, you
  10. * must create a new QForm or QPanel which instantiates a OrderStatusHistoryMetaControl
  11. * class.
  12. *
  13. * Any and all changes to this file will be overwritten with any subsequent
  14. * code re-generation.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage MetaControls
  18. * property-read OrderStatusHistory $OrderStatusHistory the actual OrderStatusHistory data class being edited
  19. * property QLabel $IdControl
  20. * property-read QLabel $IdLabel
  21. * property QListBox $OrderIdControl
  22. * property-read QLabel $OrderIdLabel
  23. * property QLabel $DateControl
  24. * property-read QLabel $DateLabel
  25. * property QTextBox $NotesControl
  26. * property-read QLabel $NotesLabel
  27. * property QListBox $StatusIdControl
  28. * property-read QLabel $StatusIdLabel
  29. * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
  30. * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
  31. */
  32. class OrderStatusHistoryMetaControlGen extends QBaseClass {
  33. // General Variables
  34. protected $objOrderStatusHistory;
  35. protected $objParentObject;
  36. protected $strTitleVerb;
  37. protected $blnEditMode;
  38. // Controls that allow the editing of OrderStatusHistory's individual data fields
  39. protected $lblId;
  40. protected $lstOrder;
  41. protected $lblDate;
  42. protected $txtNotes;
  43. protected $lstStatus;
  44. // Controls that allow the viewing of OrderStatusHistory's individual data fields
  45. protected $lblOrderId;
  46. protected $lblNotes;
  47. protected $lblStatusId;
  48. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  49. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  50. /**
  51. * Main constructor. Constructor OR static create methods are designed to be called in either
  52. * a parent QPanel or the main QForm when wanting to create a
  53. * OrderStatusHistoryMetaControl to edit a single OrderStatusHistory object within the
  54. * QPanel or QForm.
  55. *
  56. * This constructor takes in a single OrderStatusHistory object, while any of the static
  57. * create methods below can be used to construct based off of individual PK ID(s).
  58. *
  59. * @param mixed $objParentObject QForm or QPanel which will be using this OrderStatusHistoryMetaControl
  60. * @param OrderStatusHistory $objOrderStatusHistory new or existing OrderStatusHistory object
  61. */
  62. public function __construct($objParentObject, OrderStatusHistory $objOrderStatusHistory) {
  63. // Setup Parent Object (e.g. QForm or QPanel which will be using this OrderStatusHistoryMetaControl)
  64. $this->objParentObject = $objParentObject;
  65. // Setup linked OrderStatusHistory object
  66. $this->objOrderStatusHistory = $objOrderStatusHistory;
  67. // Figure out if we're Editing or Creating New
  68. if ($this->objOrderStatusHistory->__Restored) {
  69. $this->strTitleVerb = QApplication::Translate('Edit');
  70. $this->blnEditMode = true;
  71. } else {
  72. $this->strTitleVerb = QApplication::Translate('Create');
  73. $this->blnEditMode = false;
  74. }
  75. }
  76. /**
  77. * Static Helper Method to Create using PK arguments
  78. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  79. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  80. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  81. * edit, or if we are also allowed to create a new one, etc.
  82. *
  83. * @param mixed $objParentObject QForm or QPanel which will be using this OrderStatusHistoryMetaControl
  84. * @param integer $intId primary key value
  85. * @param QMetaControlCreateType $intCreateType rules governing OrderStatusHistory object creation - defaults to CreateOrEdit
  86. * @return OrderStatusHistoryMetaControl
  87. */
  88. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  89. // Attempt to Load from PK Arguments
  90. if (strlen($intId)) {
  91. $objOrderStatusHistory = OrderStatusHistory::Load($intId);
  92. // OrderStatusHistory was found -- return it!
  93. if ($objOrderStatusHistory)
  94. return new OrderStatusHistoryMetaControl($objParentObject, $objOrderStatusHistory);
  95. // If CreateOnRecordNotFound not specified, throw an exception
  96. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  97. throw new QCallerException('Could not find a OrderStatusHistory object with PK arguments: ' . $intId);
  98. // If EditOnly is specified, throw an exception
  99. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  100. throw new QCallerException('No PK arguments specified');
  101. // If we are here, then we need to create a new record
  102. return new OrderStatusHistoryMetaControl($objParentObject, new OrderStatusHistory());
  103. }
  104. /**
  105. * Static Helper Method to Create using PathInfo arguments
  106. *
  107. * @param mixed $objParentObject QForm or QPanel which will be using this OrderStatusHistoryMetaControl
  108. * @param QMetaControlCreateType $intCreateType rules governing OrderStatusHistory object creation - defaults to CreateOrEdit
  109. * @return OrderStatusHistoryMetaControl
  110. */
  111. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  112. $intId = QApplication::PathInfo(0);
  113. return OrderStatusHistoryMetaControl::Create($objParentObject, $intId, $intCreateType);
  114. }
  115. /**
  116. * Static Helper Method to Create using QueryString arguments
  117. *
  118. * @param mixed $objParentObject QForm or QPanel which will be using this OrderStatusHistoryMetaControl
  119. * @param QMetaControlCreateType $intCreateType rules governing OrderStatusHistory object creation - defaults to CreateOrEdit
  120. * @return OrderStatusHistoryMetaControl
  121. */
  122. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  123. $intId = QApplication::QueryString('intId');
  124. return OrderStatusHistoryMetaControl::Create($objParentObject, $intId, $intCreateType);
  125. }
  126. ///////////////////////////////////////////////
  127. // PUBLIC CREATE and REFRESH METHODS
  128. ///////////////////////////////////////////////
  129. /**
  130. * Create and setup QLabel lblId
  131. * @param string $strControlId optional ControlId to use
  132. * @return QLabel
  133. */
  134. public function lblId_Create($strControlId = null) {
  135. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  136. $this->lblId->Name = QApplication::Translate('Id');
  137. if ($this->blnEditMode)
  138. $this->lblId->Text = $this->objOrderStatusHistory->Id;
  139. else
  140. $this->lblId->Text = 'N/A';
  141. return $this->lblId;
  142. }
  143. /**
  144. * Create and setup QListBox lstOrder
  145. * @param string $strControlId optional ControlId to use
  146. * @return QListBox
  147. */
  148. public function lstOrder_Create($strControlId = null) {
  149. $this->lstOrder = new QListBox($this->objParentObject, $strControlId);
  150. $this->lstOrder->Name = QApplication::Translate('Order');
  151. $this->lstOrder->Required = true;
  152. if (!$this->blnEditMode)
  153. $this->lstOrder->AddItem(QApplication::Translate('- Select One -'), null);
  154. $objOrderArray = Order::LoadAll();
  155. if ($objOrderArray) foreach ($objOrderArray as $objOrder) {
  156. $objListItem = new QListItem($objOrder->__toString(), $objOrder->Id);
  157. if (($this->objOrderStatusHistory->Order) && ($this->objOrderStatusHistory->Order->Id == $objOrder->Id))
  158. $objListItem->Selected = true;
  159. $this->lstOrder->AddItem($objListItem);
  160. }
  161. return $this->lstOrder;
  162. }
  163. /**
  164. * Create and setup QLabel lblOrderId
  165. * @param string $strControlId optional ControlId to use
  166. * @return QLabel
  167. */
  168. public function lblOrderId_Create($strControlId = null) {
  169. $this->lblOrderId = new QLabel($this->objParentObject, $strControlId);
  170. $this->lblOrderId->Name = QApplication::Translate('Order');
  171. $this->lblOrderId->Text = ($this->objOrderStatusHistory->Order) ? $this->objOrderStatusHistory->Order->__toString() : null;
  172. $this->lblOrderId->Required = true;
  173. return $this->lblOrderId;
  174. }
  175. /**
  176. * Create and setup QLabel lblDate
  177. * @param string $strControlId optional ControlId to use
  178. * @return QLabel
  179. */
  180. public function lblDate_Create($strControlId = null) {
  181. $this->lblDate = new QLabel($this->objParentObject, $strControlId);
  182. $this->lblDate->Name = QApplication::Translate('Date');
  183. if ($this->blnEditMode)
  184. $this->lblDate->Text = $this->objOrderStatusHistory->Date;
  185. else
  186. $this->lblDate->Text = 'N/A';
  187. return $this->lblDate;
  188. }
  189. /**
  190. * Create and setup QTextBox txtNotes
  191. * @param string $strControlId optional ControlId to use
  192. * @return QTextBox
  193. */
  194. public function txtNotes_Create($strControlId = null) {
  195. $this->txtNotes = new QTextBox($this->objParentObject, $strControlId);
  196. $this->txtNotes->Name = QApplication::Translate('Notes');
  197. $this->txtNotes->Text = $this->objOrderStatusHistory->Notes;
  198. $this->txtNotes->TextMode = QTextMode::MultiLine;
  199. return $this->txtNotes;
  200. }
  201. /**
  202. * Create and setup QLabel lblNotes
  203. * @param string $strControlId optional ControlId to use
  204. * @return QLabel
  205. */
  206. public function lblNotes_Create($strControlId = null) {
  207. $this->lblNotes = new QLabel($this->objParentObject, $strControlId);
  208. $this->lblNotes->Name = QApplication::Translate('Notes');
  209. $this->lblNotes->Text = $this->objOrderStatusHistory->Notes;
  210. return $this->lblNotes;
  211. }
  212. /**
  213. * Create and setup QListBox lstStatus
  214. * @param string $strControlId optional ControlId to use
  215. * @return QListBox
  216. */
  217. public function lstStatus_Create($strControlId = null) {
  218. $this->lstStatus = new QListBox($this->objParentObject, $strControlId);
  219. $this->lstStatus->Name = QApplication::Translate('Status');
  220. $this->lstStatus->Required = true;
  221. foreach (OrderStatusType::$NameArray as $intId => $strValue)
  222. $this->lstStatus->AddItem(new QListItem($strValue, $intId, $this->objOrderStatusHistory->StatusId == $intId));
  223. return $this->lstStatus;
  224. }
  225. /**
  226. * Create and setup QLabel lblStatusId
  227. * @param string $strControlId optional ControlId to use
  228. * @return QLabel
  229. */
  230. public function lblStatusId_Create($strControlId = null) {
  231. $this->lblStatusId = new QLabel($this->objParentObject, $strControlId);
  232. $this->lblStatusId->Name = QApplication::Translate('Status');
  233. $this->lblStatusId->Text = ($this->objOrderStatusHistory->StatusId) ? OrderStatusType::$NameArray[$this->objOrderStatusHistory->StatusId] : null;
  234. $this->lblStatusId->Required = true;
  235. return $this->lblStatusId;
  236. }
  237. /**
  238. * Refresh this MetaControl with Data from the local OrderStatusHistory object.
  239. * @param boolean $blnReload reload OrderStatusHistory from the database
  240. * @return void
  241. */
  242. public function Refresh($blnReload = false) {
  243. if ($blnReload)
  244. $this->objOrderStatusHistory->Reload();
  245. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objOrderStatusHistory->Id;
  246. if ($this->lstOrder) {
  247. $this->lstOrder->RemoveAllItems();
  248. if (!$this->blnEditMode)
  249. $this->lstOrder->AddItem(QApplication::Translate('- Select One -'), null);
  250. $objOrderArray = Order::LoadAll();
  251. if ($objOrderArray) foreach ($objOrderArray as $objOrder) {
  252. $objListItem = new QListItem($objOrder->__toString(), $objOrder->Id);
  253. if (($this->objOrderStatusHistory->Order) && ($this->objOrderStatusHistory->Order->Id == $objOrder->Id))
  254. $objListItem->Selected = true;
  255. $this->lstOrder->AddItem($objListItem);
  256. }
  257. }
  258. if ($this->lblOrderId) $this->lblOrderId->Text = ($this->objOrderStatusHistory->Order) ? $this->objOrderStatusHistory->Order->__toString() : null;
  259. if ($this->lblDate) if ($this->blnEditMode) $this->lblDate->Text = $this->objOrderStatusHistory->Date;
  260. if ($this->txtNotes) $this->txtNotes->Text = $this->objOrderStatusHistory->Notes;
  261. if ($this->lblNotes) $this->lblNotes->Text = $this->objOrderStatusHistory->Notes;
  262. if ($this->lstStatus) $this->lstStatus->SelectedValue = $this->objOrderStatusHistory->StatusId;
  263. if ($this->lblStatusId) $this->lblStatusId->Text = ($this->objOrderStatusHistory->StatusId) ? OrderStatusType::$NameArray[$this->objOrderStatusHistory->StatusId] : null;
  264. }
  265. ///////////////////////////////////////////////
  266. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  267. ///////////////////////////////////////////////
  268. ///////////////////////////////////////////////
  269. // PUBLIC ORDERSTATUSHISTORY OBJECT MANIPULATORS
  270. ///////////////////////////////////////////////
  271. /**
  272. * This will save this object's OrderStatusHistory instance,
  273. * updating only the fields which have had a control created for it.
  274. */
  275. public function SaveOrderStatusHistory() {
  276. try {
  277. // Update any fields for controls that have been created
  278. if ($this->lstOrder) $this->objOrderStatusHistory->OrderId = $this->lstOrder->SelectedValue;
  279. if ($this->txtNotes) $this->objOrderStatusHistory->Notes = $this->txtNotes->Text;
  280. if ($this->lstStatus) $this->objOrderStatusHistory->StatusId = $this->lstStatus->SelectedValue;
  281. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  282. // Save the OrderStatusHistory object
  283. $this->objOrderStatusHistory->Save();
  284. // Finally, update any ManyToManyReferences (if any)
  285. } catch (QCallerException $objExc) {
  286. $objExc->IncrementOffset();
  287. throw $objExc;
  288. }
  289. }
  290. /**
  291. * This will DELETE this object's OrderStatusHistory instance from the database.
  292. * It will also unassociate itself from any ManyToManyReferences.
  293. */
  294. public function DeleteOrderStatusHistory() {
  295. $this->objOrderStatusHistory->Delete();
  296. }
  297. ///////////////////////////////////////////////
  298. // PUBLIC GETTERS and SETTERS
  299. ///////////////////////////////////////////////
  300. /**
  301. * Override method to perform a property "Get"
  302. * This will get the value of $strName
  303. *
  304. * @param string $strName Name of the property to get
  305. * @return mixed
  306. */
  307. public function __get($strName) {
  308. switch ($strName) {
  309. // General MetaControlVariables
  310. case 'OrderStatusHistory': return $this->objOrderStatusHistory;
  311. case 'TitleVerb': return $this->strTitleVerb;
  312. case 'EditMode': return $this->blnEditMode;
  313. // Controls that point to OrderStatusHistory fields -- will be created dynamically if not yet created
  314. case 'IdControl':
  315. if (!$this->lblId) return $this->lblId_Create();
  316. return $this->lblId;
  317. case 'IdLabel':
  318. if (!$this->lblId) return $this->lblId_Create();
  319. return $this->lblId;
  320. case 'OrderIdControl':
  321. if (!$this->lstOrder) return $this->lstOrder_Create();
  322. return $this->lstOrder;
  323. case 'OrderIdLabel':
  324. if (!$this->lblOrderId) return $this->lblOrderId_Create();
  325. return $this->lblOrderId;
  326. case 'DateControl':
  327. if (!$this->lblDate) return $this->lblDate_Create();
  328. return $this->lblDate;
  329. case 'DateLabel':
  330. if (!$this->lblDate) return $this->lblDate_Create();
  331. return $this->lblDate;
  332. case 'NotesControl':
  333. if (!$this->txtNotes) return $this->txtNotes_Create();
  334. return $this->txtNotes;
  335. case 'NotesLabel':
  336. if (!$this->lblNotes) return $this->lblNotes_Create();
  337. return $this->lblNotes;
  338. case 'StatusIdControl':
  339. if (!$this->lstStatus) return $this->lstStatus_Create();
  340. return $this->lstStatus;
  341. case 'StatusIdLabel':
  342. if (!$this->lblStatusId) return $this->lblStatusId_Create();
  343. return $this->lblStatusId;
  344. default:
  345. try {
  346. return parent::__get($strName);
  347. } catch (QCallerException $objExc) {
  348. $objExc->IncrementOffset();
  349. throw $objExc;
  350. }
  351. }
  352. }
  353. /**
  354. * Override method to perform a property "Set"
  355. * This will set the property $strName to be $mixValue
  356. *
  357. * @param string $strName Name of the property to set
  358. * @param string $mixValue New value of the property
  359. * @return mixed
  360. */
  361. public function __set($strName, $mixValue) {
  362. try {
  363. switch ($strName) {
  364. // Controls that point to OrderStatusHistory fields
  365. case 'IdControl':
  366. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  367. case 'OrderIdControl':
  368. return ($this->lstOrder = QType::Cast($mixValue, 'QControl'));
  369. case 'DateControl':
  370. return ($this->lblDate = QType::Cast($mixValue, 'QControl'));
  371. case 'NotesControl':
  372. return ($this->txtNotes = QType::Cast($mixValue, 'QControl'));
  373. case 'StatusIdControl':
  374. return ($this->lstStatus = QType::Cast($mixValue, 'QControl'));
  375. default:
  376. return parent::__set($strName, $mixValue);
  377. }
  378. } catch (QCallerException $objExc) {
  379. $objExc->IncrementOffset();
  380. throw $objExc;
  381. }
  382. }
  383. }
  384. ?>