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.

380 lines
16 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 ShippingRate 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 ShippingRate 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 ShippingRateMetaControl
  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 ShippingRate $ShippingRate the actual ShippingRate data class being edited
  19. * property QLabel $IdControl
  20. * property-read QLabel $IdLabel
  21. * property QLabel $CreationDateControl
  22. * property-read QLabel $CreationDateLabel
  23. * property QFloatTextBox $RateControl
  24. * property-read QLabel $RateLabel
  25. * property QListBox $ZoneIdControl
  26. * property-read QLabel $ZoneIdLabel
  27. * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
  28. * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
  29. */
  30. class ShippingRateMetaControlGen extends QBaseClass {
  31. // General Variables
  32. protected $objShippingRate;
  33. protected $objParentObject;
  34. protected $strTitleVerb;
  35. protected $blnEditMode;
  36. // Controls that allow the editing of ShippingRate's individual data fields
  37. protected $lblId;
  38. protected $lblCreationDate;
  39. protected $txtRate;
  40. protected $lstZone;
  41. // Controls that allow the viewing of ShippingRate's individual data fields
  42. protected $lblRate;
  43. protected $lblZoneId;
  44. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  45. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  46. /**
  47. * Main constructor. Constructor OR static create methods are designed to be called in either
  48. * a parent QPanel or the main QForm when wanting to create a
  49. * ShippingRateMetaControl to edit a single ShippingRate object within the
  50. * QPanel or QForm.
  51. *
  52. * This constructor takes in a single ShippingRate object, while any of the static
  53. * create methods below can be used to construct based off of individual PK ID(s).
  54. *
  55. * @param mixed $objParentObject QForm or QPanel which will be using this ShippingRateMetaControl
  56. * @param ShippingRate $objShippingRate new or existing ShippingRate object
  57. */
  58. public function __construct($objParentObject, ShippingRate $objShippingRate) {
  59. // Setup Parent Object (e.g. QForm or QPanel which will be using this ShippingRateMetaControl)
  60. $this->objParentObject = $objParentObject;
  61. // Setup linked ShippingRate object
  62. $this->objShippingRate = $objShippingRate;
  63. // Figure out if we're Editing or Creating New
  64. if ($this->objShippingRate->__Restored) {
  65. $this->strTitleVerb = QApplication::Translate('Edit');
  66. $this->blnEditMode = true;
  67. } else {
  68. $this->strTitleVerb = QApplication::Translate('Create');
  69. $this->blnEditMode = false;
  70. }
  71. }
  72. /**
  73. * Static Helper Method to Create using PK arguments
  74. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  75. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  76. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  77. * edit, or if we are also allowed to create a new one, etc.
  78. *
  79. * @param mixed $objParentObject QForm or QPanel which will be using this ShippingRateMetaControl
  80. * @param integer $intId primary key value
  81. * @param QMetaControlCreateType $intCreateType rules governing ShippingRate object creation - defaults to CreateOrEdit
  82. * @return ShippingRateMetaControl
  83. */
  84. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  85. // Attempt to Load from PK Arguments
  86. if (strlen($intId)) {
  87. $objShippingRate = ShippingRate::Load($intId);
  88. // ShippingRate was found -- return it!
  89. if ($objShippingRate)
  90. return new ShippingRateMetaControl($objParentObject, $objShippingRate);
  91. // If CreateOnRecordNotFound not specified, throw an exception
  92. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  93. throw new QCallerException('Could not find a ShippingRate object with PK arguments: ' . $intId);
  94. // If EditOnly is specified, throw an exception
  95. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  96. throw new QCallerException('No PK arguments specified');
  97. // If we are here, then we need to create a new record
  98. return new ShippingRateMetaControl($objParentObject, new ShippingRate());
  99. }
  100. /**
  101. * Static Helper Method to Create using PathInfo arguments
  102. *
  103. * @param mixed $objParentObject QForm or QPanel which will be using this ShippingRateMetaControl
  104. * @param QMetaControlCreateType $intCreateType rules governing ShippingRate object creation - defaults to CreateOrEdit
  105. * @return ShippingRateMetaControl
  106. */
  107. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  108. $intId = QApplication::PathInfo(0);
  109. return ShippingRateMetaControl::Create($objParentObject, $intId, $intCreateType);
  110. }
  111. /**
  112. * Static Helper Method to Create using QueryString arguments
  113. *
  114. * @param mixed $objParentObject QForm or QPanel which will be using this ShippingRateMetaControl
  115. * @param QMetaControlCreateType $intCreateType rules governing ShippingRate object creation - defaults to CreateOrEdit
  116. * @return ShippingRateMetaControl
  117. */
  118. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  119. $intId = QApplication::QueryString('intId');
  120. return ShippingRateMetaControl::Create($objParentObject, $intId, $intCreateType);
  121. }
  122. ///////////////////////////////////////////////
  123. // PUBLIC CREATE and REFRESH METHODS
  124. ///////////////////////////////////////////////
  125. /**
  126. * Create and setup QLabel lblId
  127. * @param string $strControlId optional ControlId to use
  128. * @return QLabel
  129. */
  130. public function lblId_Create($strControlId = null) {
  131. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  132. $this->lblId->Name = QApplication::Translate('Id');
  133. if ($this->blnEditMode)
  134. $this->lblId->Text = $this->objShippingRate->Id;
  135. else
  136. $this->lblId->Text = 'N/A';
  137. return $this->lblId;
  138. }
  139. /**
  140. * Create and setup QLabel lblCreationDate
  141. * @param string $strControlId optional ControlId to use
  142. * @return QLabel
  143. */
  144. public function lblCreationDate_Create($strControlId = null) {
  145. $this->lblCreationDate = new QLabel($this->objParentObject, $strControlId);
  146. $this->lblCreationDate->Name = QApplication::Translate('Creation Date');
  147. if ($this->blnEditMode)
  148. $this->lblCreationDate->Text = $this->objShippingRate->CreationDate;
  149. else
  150. $this->lblCreationDate->Text = 'N/A';
  151. return $this->lblCreationDate;
  152. }
  153. /**
  154. * Create and setup QFloatTextBox txtRate
  155. * @param string $strControlId optional ControlId to use
  156. * @return QFloatTextBox
  157. */
  158. public function txtRate_Create($strControlId = null) {
  159. $this->txtRate = new QFloatTextBox($this->objParentObject, $strControlId);
  160. $this->txtRate->Name = QApplication::Translate('Rate');
  161. $this->txtRate->Text = $this->objShippingRate->Rate;
  162. $this->txtRate->Required = true;
  163. return $this->txtRate;
  164. }
  165. /**
  166. * Create and setup QLabel lblRate
  167. * @param string $strControlId optional ControlId to use
  168. * @param string $strFormat optional sprintf format to use
  169. * @return QLabel
  170. */
  171. public function lblRate_Create($strControlId = null, $strFormat = null) {
  172. $this->lblRate = new QLabel($this->objParentObject, $strControlId);
  173. $this->lblRate->Name = QApplication::Translate('Rate');
  174. $this->lblRate->Text = $this->objShippingRate->Rate;
  175. $this->lblRate->Required = true;
  176. $this->lblRate->Format = $strFormat;
  177. return $this->lblRate;
  178. }
  179. /**
  180. * Create and setup QListBox lstZone
  181. * @param string $strControlId optional ControlId to use
  182. * @return QListBox
  183. */
  184. public function lstZone_Create($strControlId = null) {
  185. $this->lstZone = new QListBox($this->objParentObject, $strControlId);
  186. $this->lstZone->Name = QApplication::Translate('Zone');
  187. $this->lstZone->Required = true;
  188. foreach (ZoneType::$NameArray as $intId => $strValue)
  189. $this->lstZone->AddItem(new QListItem($strValue, $intId, $this->objShippingRate->ZoneId == $intId));
  190. return $this->lstZone;
  191. }
  192. /**
  193. * Create and setup QLabel lblZoneId
  194. * @param string $strControlId optional ControlId to use
  195. * @return QLabel
  196. */
  197. public function lblZoneId_Create($strControlId = null) {
  198. $this->lblZoneId = new QLabel($this->objParentObject, $strControlId);
  199. $this->lblZoneId->Name = QApplication::Translate('Zone');
  200. $this->lblZoneId->Text = ($this->objShippingRate->ZoneId) ? ZoneType::$NameArray[$this->objShippingRate->ZoneId] : null;
  201. $this->lblZoneId->Required = true;
  202. return $this->lblZoneId;
  203. }
  204. /**
  205. * Refresh this MetaControl with Data from the local ShippingRate object.
  206. * @param boolean $blnReload reload ShippingRate from the database
  207. * @return void
  208. */
  209. public function Refresh($blnReload = false) {
  210. if ($blnReload)
  211. $this->objShippingRate->Reload();
  212. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objShippingRate->Id;
  213. if ($this->lblCreationDate) if ($this->blnEditMode) $this->lblCreationDate->Text = $this->objShippingRate->CreationDate;
  214. if ($this->txtRate) $this->txtRate->Text = $this->objShippingRate->Rate;
  215. if ($this->lblRate) $this->lblRate->Text = $this->objShippingRate->Rate;
  216. if ($this->lstZone) $this->lstZone->SelectedValue = $this->objShippingRate->ZoneId;
  217. if ($this->lblZoneId) $this->lblZoneId->Text = ($this->objShippingRate->ZoneId) ? ZoneType::$NameArray[$this->objShippingRate->ZoneId] : null;
  218. }
  219. ///////////////////////////////////////////////
  220. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  221. ///////////////////////////////////////////////
  222. ///////////////////////////////////////////////
  223. // PUBLIC SHIPPINGRATE OBJECT MANIPULATORS
  224. ///////////////////////////////////////////////
  225. /**
  226. * This will save this object's ShippingRate instance,
  227. * updating only the fields which have had a control created for it.
  228. */
  229. public function SaveShippingRate() {
  230. try {
  231. // Update any fields for controls that have been created
  232. if ($this->txtRate) $this->objShippingRate->Rate = $this->txtRate->Text;
  233. if ($this->lstZone) $this->objShippingRate->ZoneId = $this->lstZone->SelectedValue;
  234. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  235. // Save the ShippingRate object
  236. $this->objShippingRate->Save();
  237. // Finally, update any ManyToManyReferences (if any)
  238. } catch (QCallerException $objExc) {
  239. $objExc->IncrementOffset();
  240. throw $objExc;
  241. }
  242. }
  243. /**
  244. * This will DELETE this object's ShippingRate instance from the database.
  245. * It will also unassociate itself from any ManyToManyReferences.
  246. */
  247. public function DeleteShippingRate() {
  248. $this->objShippingRate->Delete();
  249. }
  250. ///////////////////////////////////////////////
  251. // PUBLIC GETTERS and SETTERS
  252. ///////////////////////////////////////////////
  253. /**
  254. * Override method to perform a property "Get"
  255. * This will get the value of $strName
  256. *
  257. * @param string $strName Name of the property to get
  258. * @return mixed
  259. */
  260. public function __get($strName) {
  261. switch ($strName) {
  262. // General MetaControlVariables
  263. case 'ShippingRate': return $this->objShippingRate;
  264. case 'TitleVerb': return $this->strTitleVerb;
  265. case 'EditMode': return $this->blnEditMode;
  266. // Controls that point to ShippingRate fields -- will be created dynamically if not yet created
  267. case 'IdControl':
  268. if (!$this->lblId) return $this->lblId_Create();
  269. return $this->lblId;
  270. case 'IdLabel':
  271. if (!$this->lblId) return $this->lblId_Create();
  272. return $this->lblId;
  273. case 'CreationDateControl':
  274. if (!$this->lblCreationDate) return $this->lblCreationDate_Create();
  275. return $this->lblCreationDate;
  276. case 'CreationDateLabel':
  277. if (!$this->lblCreationDate) return $this->lblCreationDate_Create();
  278. return $this->lblCreationDate;
  279. case 'RateControl':
  280. if (!$this->txtRate) return $this->txtRate_Create();
  281. return $this->txtRate;
  282. case 'RateLabel':
  283. if (!$this->lblRate) return $this->lblRate_Create();
  284. return $this->lblRate;
  285. case 'ZoneIdControl':
  286. if (!$this->lstZone) return $this->lstZone_Create();
  287. return $this->lstZone;
  288. case 'ZoneIdLabel':
  289. if (!$this->lblZoneId) return $this->lblZoneId_Create();
  290. return $this->lblZoneId;
  291. default:
  292. try {
  293. return parent::__get($strName);
  294. } catch (QCallerException $objExc) {
  295. $objExc->IncrementOffset();
  296. throw $objExc;
  297. }
  298. }
  299. }
  300. /**
  301. * Override method to perform a property "Set"
  302. * This will set the property $strName to be $mixValue
  303. *
  304. * @param string $strName Name of the property to set
  305. * @param string $mixValue New value of the property
  306. * @return mixed
  307. */
  308. public function __set($strName, $mixValue) {
  309. try {
  310. switch ($strName) {
  311. // Controls that point to ShippingRate fields
  312. case 'IdControl':
  313. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  314. case 'CreationDateControl':
  315. return ($this->lblCreationDate = QType::Cast($mixValue, 'QControl'));
  316. case 'RateControl':
  317. return ($this->txtRate = QType::Cast($mixValue, 'QControl'));
  318. case 'ZoneIdControl':
  319. return ($this->lstZone = QType::Cast($mixValue, 'QControl'));
  320. default:
  321. return parent::__set($strName, $mixValue);
  322. }
  323. } catch (QCallerException $objExc) {
  324. $objExc->IncrementOffset();
  325. throw $objExc;
  326. }
  327. }
  328. }
  329. ?>