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.

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