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.

1334 lines
65 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 Product 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 Product 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 ProductMetaControl
  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 Product $Product the actual Product data class being edited
  19. * property QLabel $IdControl
  20. * property-read QLabel $IdLabel
  21. * property QListBox $ManufacturerIdControl
  22. * property-read QLabel $ManufacturerIdLabel
  23. * property QListBox $SupplierIdControl
  24. * property-read QLabel $SupplierIdLabel
  25. * property QLabel $CreationDateControl
  26. * property-read QLabel $CreationDateLabel
  27. * property QTextBox $NameControl
  28. * property-read QLabel $NameLabel
  29. * property QTextBox $ModelControl
  30. * property-read QLabel $ModelLabel
  31. * property QTextBox $ShortDescriptionControl
  32. * property-read QLabel $ShortDescriptionLabel
  33. * property QTextBox $LongDescriptionControl
  34. * property-read QLabel $LongDescriptionLabel
  35. * property QFloatTextBox $MsrpControl
  36. * property-read QLabel $MsrpLabel
  37. * property QFloatTextBox $WholesalePriceControl
  38. * property-read QLabel $WholesalePriceLabel
  39. * property QFloatTextBox $RetailPriceControl
  40. * property-read QLabel $RetailPriceLabel
  41. * property QFloatTextBox $CostControl
  42. * property-read QLabel $CostLabel
  43. * property QFloatTextBox $WeightControl
  44. * property-read QLabel $WeightLabel
  45. * property QFloatTextBox $HeightControl
  46. * property-read QLabel $HeightLabel
  47. * property QFloatTextBox $WidthControl
  48. * property-read QLabel $WidthLabel
  49. * property QFloatTextBox $DepthControl
  50. * property-read QLabel $DepthLabel
  51. * property QCheckBox $IsVirtualControl
  52. * property-read QLabel $IsVirtualLabel
  53. * property QListBox $TypeIdControl
  54. * property-read QLabel $TypeIdLabel
  55. * property QListBox $StatusIdControl
  56. * property-read QLabel $StatusIdLabel
  57. * property QIntegerTextBox $ViewCountControl
  58. * property-read QLabel $ViewCountLabel
  59. * property QListBox $ProductCategoryControl
  60. * property-read QLabel $ProductCategoryLabel
  61. * property QListBox $ParentProductAsRelatedControl
  62. * property-read QLabel $ParentProductAsRelatedLabel
  63. * property QListBox $ProductAsRelatedControl
  64. * property-read QLabel $ProductAsRelatedLabel
  65. * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
  66. * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
  67. */
  68. class ProductMetaControlGen extends QBaseClass {
  69. // General Variables
  70. protected $objProduct;
  71. protected $objParentObject;
  72. protected $strTitleVerb;
  73. protected $blnEditMode;
  74. // Controls that allow the editing of Product's individual data fields
  75. protected $lblId;
  76. protected $lstManufacturer;
  77. protected $lstSupplier;
  78. protected $lblCreationDate;
  79. protected $txtName;
  80. protected $txtModel;
  81. protected $txtShortDescription;
  82. protected $txtLongDescription;
  83. protected $txtMsrp;
  84. protected $txtWholesalePrice;
  85. protected $txtRetailPrice;
  86. protected $txtCost;
  87. protected $txtWeight;
  88. protected $txtHeight;
  89. protected $txtWidth;
  90. protected $txtDepth;
  91. protected $chkIsVirtual;
  92. protected $lstType;
  93. protected $lstStatus;
  94. protected $txtViewCount;
  95. // Controls that allow the viewing of Product's individual data fields
  96. protected $lblManufacturerId;
  97. protected $lblSupplierId;
  98. protected $lblName;
  99. protected $lblModel;
  100. protected $lblShortDescription;
  101. protected $lblLongDescription;
  102. protected $lblMsrp;
  103. protected $lblWholesalePrice;
  104. protected $lblRetailPrice;
  105. protected $lblCost;
  106. protected $lblWeight;
  107. protected $lblHeight;
  108. protected $lblWidth;
  109. protected $lblDepth;
  110. protected $lblIsVirtual;
  111. protected $lblTypeId;
  112. protected $lblStatusId;
  113. protected $lblViewCount;
  114. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  115. protected $lstProductCategories;
  116. protected $lstParentProductsAsRelated;
  117. protected $lstProductsAsRelated;
  118. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  119. protected $lblProductCategories;
  120. protected $lblParentProductsAsRelated;
  121. protected $lblProductsAsRelated;
  122. /**
  123. * Main constructor. Constructor OR static create methods are designed to be called in either
  124. * a parent QPanel or the main QForm when wanting to create a
  125. * ProductMetaControl to edit a single Product object within the
  126. * QPanel or QForm.
  127. *
  128. * This constructor takes in a single Product object, while any of the static
  129. * create methods below can be used to construct based off of individual PK ID(s).
  130. *
  131. * @param mixed $objParentObject QForm or QPanel which will be using this ProductMetaControl
  132. * @param Product $objProduct new or existing Product object
  133. */
  134. public function __construct($objParentObject, Product $objProduct) {
  135. // Setup Parent Object (e.g. QForm or QPanel which will be using this ProductMetaControl)
  136. $this->objParentObject = $objParentObject;
  137. // Setup linked Product object
  138. $this->objProduct = $objProduct;
  139. // Figure out if we're Editing or Creating New
  140. if ($this->objProduct->__Restored) {
  141. $this->strTitleVerb = QApplication::Translate('Edit');
  142. $this->blnEditMode = true;
  143. } else {
  144. $this->strTitleVerb = QApplication::Translate('Create');
  145. $this->blnEditMode = false;
  146. }
  147. }
  148. /**
  149. * Static Helper Method to Create using PK arguments
  150. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  151. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  152. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  153. * edit, or if we are also allowed to create a new one, etc.
  154. *
  155. * @param mixed $objParentObject QForm or QPanel which will be using this ProductMetaControl
  156. * @param integer $intId primary key value
  157. * @param QMetaControlCreateType $intCreateType rules governing Product object creation - defaults to CreateOrEdit
  158. * @return ProductMetaControl
  159. */
  160. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  161. // Attempt to Load from PK Arguments
  162. if (strlen($intId)) {
  163. $objProduct = Product::Load($intId);
  164. // Product was found -- return it!
  165. if ($objProduct)
  166. return new ProductMetaControl($objParentObject, $objProduct);
  167. // If CreateOnRecordNotFound not specified, throw an exception
  168. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  169. throw new QCallerException('Could not find a Product object with PK arguments: ' . $intId);
  170. // If EditOnly is specified, throw an exception
  171. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  172. throw new QCallerException('No PK arguments specified');
  173. // If we are here, then we need to create a new record
  174. return new ProductMetaControl($objParentObject, new Product());
  175. }
  176. /**
  177. * Static Helper Method to Create using PathInfo arguments
  178. *
  179. * @param mixed $objParentObject QForm or QPanel which will be using this ProductMetaControl
  180. * @param QMetaControlCreateType $intCreateType rules governing Product object creation - defaults to CreateOrEdit
  181. * @return ProductMetaControl
  182. */
  183. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  184. $intId = QApplication::PathInfo(0);
  185. return ProductMetaControl::Create($objParentObject, $intId, $intCreateType);
  186. }
  187. /**
  188. * Static Helper Method to Create using QueryString arguments
  189. *
  190. * @param mixed $objParentObject QForm or QPanel which will be using this ProductMetaControl
  191. * @param QMetaControlCreateType $intCreateType rules governing Product object creation - defaults to CreateOrEdit
  192. * @return ProductMetaControl
  193. */
  194. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  195. $intId = QApplication::QueryString('intId');
  196. return ProductMetaControl::Create($objParentObject, $intId, $intCreateType);
  197. }
  198. ///////////////////////////////////////////////
  199. // PUBLIC CREATE and REFRESH METHODS
  200. ///////////////////////////////////////////////
  201. /**
  202. * Create and setup QLabel lblId
  203. * @param string $strControlId optional ControlId to use
  204. * @return QLabel
  205. */
  206. public function lblId_Create($strControlId = null) {
  207. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  208. $this->lblId->Name = QApplication::Translate('Id');
  209. if ($this->blnEditMode)
  210. $this->lblId->Text = $this->objProduct->Id;
  211. else
  212. $this->lblId->Text = 'N/A';
  213. return $this->lblId;
  214. }
  215. /**
  216. * Create and setup QListBox lstManufacturer
  217. * @param string $strControlId optional ControlId to use
  218. * @return QListBox
  219. */
  220. public function lstManufacturer_Create($strControlId = null) {
  221. $this->lstManufacturer = new QListBox($this->objParentObject, $strControlId);
  222. $this->lstManufacturer->Name = QApplication::Translate('Manufacturer');
  223. $this->lstManufacturer->AddItem(QApplication::Translate('- Select One -'), null);
  224. $objManufacturerArray = Person::LoadAll();
  225. if ($objManufacturerArray) foreach ($objManufacturerArray as $objManufacturer) {
  226. $objListItem = new QListItem($objManufacturer->__toString(), $objManufacturer->Id);
  227. if (($this->objProduct->Manufacturer) && ($this->objProduct->Manufacturer->Id == $objManufacturer->Id))
  228. $objListItem->Selected = true;
  229. $this->lstManufacturer->AddItem($objListItem);
  230. }
  231. return $this->lstManufacturer;
  232. }
  233. /**
  234. * Create and setup QLabel lblManufacturerId
  235. * @param string $strControlId optional ControlId to use
  236. * @return QLabel
  237. */
  238. public function lblManufacturerId_Create($strControlId = null) {
  239. $this->lblManufacturerId = new QLabel($this->objParentObject, $strControlId);
  240. $this->lblManufacturerId->Name = QApplication::Translate('Manufacturer');
  241. $this->lblManufacturerId->Text = ($this->objProduct->Manufacturer) ? $this->objProduct->Manufacturer->__toString() : null;
  242. return $this->lblManufacturerId;
  243. }
  244. /**
  245. * Create and setup QListBox lstSupplier
  246. * @param string $strControlId optional ControlId to use
  247. * @return QListBox
  248. */
  249. public function lstSupplier_Create($strControlId = null) {
  250. $this->lstSupplier = new QListBox($this->objParentObject, $strControlId);
  251. $this->lstSupplier->Name = QApplication::Translate('Supplier');
  252. $this->lstSupplier->AddItem(QApplication::Translate('- Select One -'), null);
  253. $objSupplierArray = Person::LoadAll();
  254. if ($objSupplierArray) foreach ($objSupplierArray as $objSupplier) {
  255. $objListItem = new QListItem($objSupplier->__toString(), $objSupplier->Id);
  256. if (($this->objProduct->Supplier) && ($this->objProduct->Supplier->Id == $objSupplier->Id))
  257. $objListItem->Selected = true;
  258. $this->lstSupplier->AddItem($objListItem);
  259. }
  260. return $this->lstSupplier;
  261. }
  262. /**
  263. * Create and setup QLabel lblSupplierId
  264. * @param string $strControlId optional ControlId to use
  265. * @return QLabel
  266. */
  267. public function lblSupplierId_Create($strControlId = null) {
  268. $this->lblSupplierId = new QLabel($this->objParentObject, $strControlId);
  269. $this->lblSupplierId->Name = QApplication::Translate('Supplier');
  270. $this->lblSupplierId->Text = ($this->objProduct->Supplier) ? $this->objProduct->Supplier->__toString() : null;
  271. return $this->lblSupplierId;
  272. }
  273. /**
  274. * Create and setup QLabel lblCreationDate
  275. * @param string $strControlId optional ControlId to use
  276. * @return QLabel
  277. */
  278. public function lblCreationDate_Create($strControlId = null) {
  279. $this->lblCreationDate = new QLabel($this->objParentObject, $strControlId);
  280. $this->lblCreationDate->Name = QApplication::Translate('Creation Date');
  281. if ($this->blnEditMode)
  282. $this->lblCreationDate->Text = $this->objProduct->CreationDate;
  283. else
  284. $this->lblCreationDate->Text = 'N/A';
  285. return $this->lblCreationDate;
  286. }
  287. /**
  288. * Create and setup QTextBox txtName
  289. * @param string $strControlId optional ControlId to use
  290. * @return QTextBox
  291. */
  292. public function txtName_Create($strControlId = null) {
  293. $this->txtName = new QTextBox($this->objParentObject, $strControlId);
  294. $this->txtName->Name = QApplication::Translate('Name');
  295. $this->txtName->Text = $this->objProduct->Name;
  296. $this->txtName->Required = true;
  297. $this->txtName->MaxLength = Product::NameMaxLength;
  298. return $this->txtName;
  299. }
  300. /**
  301. * Create and setup QLabel lblName
  302. * @param string $strControlId optional ControlId to use
  303. * @return QLabel
  304. */
  305. public function lblName_Create($strControlId = null) {
  306. $this->lblName = new QLabel($this->objParentObject, $strControlId);
  307. $this->lblName->Name = QApplication::Translate('Name');
  308. $this->lblName->Text = $this->objProduct->Name;
  309. $this->lblName->Required = true;
  310. return $this->lblName;
  311. }
  312. /**
  313. * Create and setup QTextBox txtModel
  314. * @param string $strControlId optional ControlId to use
  315. * @return QTextBox
  316. */
  317. public function txtModel_Create($strControlId = null) {
  318. $this->txtModel = new QTextBox($this->objParentObject, $strControlId);
  319. $this->txtModel->Name = QApplication::Translate('Model');
  320. $this->txtModel->Text = $this->objProduct->Model;
  321. $this->txtModel->Required = true;
  322. $this->txtModel->MaxLength = Product::ModelMaxLength;
  323. return $this->txtModel;
  324. }
  325. /**
  326. * Create and setup QLabel lblModel
  327. * @param string $strControlId optional ControlId to use
  328. * @return QLabel
  329. */
  330. public function lblModel_Create($strControlId = null) {
  331. $this->lblModel = new QLabel($this->objParentObject, $strControlId);
  332. $this->lblModel->Name = QApplication::Translate('Model');
  333. $this->lblModel->Text = $this->objProduct->Model;
  334. $this->lblModel->Required = true;
  335. return $this->lblModel;
  336. }
  337. /**
  338. * Create and setup QTextBox txtShortDescription
  339. * @param string $strControlId optional ControlId to use
  340. * @return QTextBox
  341. */
  342. public function txtShortDescription_Create($strControlId = null) {
  343. $this->txtShortDescription = new QTextBox($this->objParentObject, $strControlId);
  344. $this->txtShortDescription->Name = QApplication::Translate('Short Description');
  345. $this->txtShortDescription->Text = $this->objProduct->ShortDescription;
  346. $this->txtShortDescription->MaxLength = Product::ShortDescriptionMaxLength;
  347. return $this->txtShortDescription;
  348. }
  349. /**
  350. * Create and setup QLabel lblShortDescription
  351. * @param string $strControlId optional ControlId to use
  352. * @return QLabel
  353. */
  354. public function lblShortDescription_Create($strControlId = null) {
  355. $this->lblShortDescription = new QLabel($this->objParentObject, $strControlId);
  356. $this->lblShortDescription->Name = QApplication::Translate('Short Description');
  357. $this->lblShortDescription->Text = $this->objProduct->ShortDescription;
  358. return $this->lblShortDescription;
  359. }
  360. /**
  361. * Create and setup QTextBox txtLongDescription
  362. * @param string $strControlId optional ControlId to use
  363. * @return QTextBox
  364. */
  365. public function txtLongDescription_Create($strControlId = null) {
  366. $this->txtLongDescription = new QTextBox($this->objParentObject, $strControlId);
  367. $this->txtLongDescription->Name = QApplication::Translate('Long Description');
  368. $this->txtLongDescription->Text = $this->objProduct->LongDescription;
  369. $this->txtLongDescription->TextMode = QTextMode::MultiLine;
  370. return $this->txtLongDescription;
  371. }
  372. /**
  373. * Create and setup QLabel lblLongDescription
  374. * @param string $strControlId optional ControlId to use
  375. * @return QLabel
  376. */
  377. public function lblLongDescription_Create($strControlId = null) {
  378. $this->lblLongDescription = new QLabel($this->objParentObject, $strControlId);
  379. $this->lblLongDescription->Name = QApplication::Translate('Long Description');
  380. $this->lblLongDescription->Text = $this->objProduct->LongDescription;
  381. return $this->lblLongDescription;
  382. }
  383. /**
  384. * Create and setup QFloatTextBox txtMsrp
  385. * @param string $strControlId optional ControlId to use
  386. * @return QFloatTextBox
  387. */
  388. public function txtMsrp_Create($strControlId = null) {
  389. $this->txtMsrp = new QFloatTextBox($this->objParentObject, $strControlId);
  390. $this->txtMsrp->Name = QApplication::Translate('Msrp');
  391. $this->txtMsrp->Text = $this->objProduct->Msrp;
  392. return $this->txtMsrp;
  393. }
  394. /**
  395. * Create and setup QLabel lblMsrp
  396. * @param string $strControlId optional ControlId to use
  397. * @param string $strFormat optional sprintf format to use
  398. * @return QLabel
  399. */
  400. public function lblMsrp_Create($strControlId = null, $strFormat = null) {
  401. $this->lblMsrp = new QLabel($this->objParentObject, $strControlId);
  402. $this->lblMsrp->Name = QApplication::Translate('Msrp');
  403. $this->lblMsrp->Text = $this->objProduct->Msrp;
  404. $this->lblMsrp->Format = $strFormat;
  405. return $this->lblMsrp;
  406. }
  407. /**
  408. * Create and setup QFloatTextBox txtWholesalePrice
  409. * @param string $strControlId optional ControlId to use
  410. * @return QFloatTextBox
  411. */
  412. public function txtWholesalePrice_Create($strControlId = null) {
  413. $this->txtWholesalePrice = new QFloatTextBox($this->objParentObject, $strControlId);
  414. $this->txtWholesalePrice->Name = QApplication::Translate('Wholesale Price');
  415. $this->txtWholesalePrice->Text = $this->objProduct->WholesalePrice;
  416. return $this->txtWholesalePrice;
  417. }
  418. /**
  419. * Create and setup QLabel lblWholesalePrice
  420. * @param string $strControlId optional ControlId to use
  421. * @param string $strFormat optional sprintf format to use
  422. * @return QLabel
  423. */
  424. public function lblWholesalePrice_Create($strControlId = null, $strFormat = null) {
  425. $this->lblWholesalePrice = new QLabel($this->objParentObject, $strControlId);
  426. $this->lblWholesalePrice->Name = QApplication::Translate('Wholesale Price');
  427. $this->lblWholesalePrice->Text = $this->objProduct->WholesalePrice;
  428. $this->lblWholesalePrice->Format = $strFormat;
  429. return $this->lblWholesalePrice;
  430. }
  431. /**
  432. * Create and setup QFloatTextBox txtRetailPrice
  433. * @param string $strControlId optional ControlId to use
  434. * @return QFloatTextBox
  435. */
  436. public function txtRetailPrice_Create($strControlId = null) {
  437. $this->txtRetailPrice = new QFloatTextBox($this->objParentObject, $strControlId);
  438. $this->txtRetailPrice->Name = QApplication::Translate('Retail Price');
  439. $this->txtRetailPrice->Text = $this->objProduct->RetailPrice;
  440. return $this->txtRetailPrice;
  441. }
  442. /**
  443. * Create and setup QLabel lblRetailPrice
  444. * @param string $strControlId optional ControlId to use
  445. * @param string $strFormat optional sprintf format to use
  446. * @return QLabel
  447. */
  448. public function lblRetailPrice_Create($strControlId = null, $strFormat = null) {
  449. $this->lblRetailPrice = new QLabel($this->objParentObject, $strControlId);
  450. $this->lblRetailPrice->Name = QApplication::Translate('Retail Price');
  451. $this->lblRetailPrice->Text = $this->objProduct->RetailPrice;
  452. $this->lblRetailPrice->Format = $strFormat;
  453. return $this->lblRetailPrice;
  454. }
  455. /**
  456. * Create and setup QFloatTextBox txtCost
  457. * @param string $strControlId optional ControlId to use
  458. * @return QFloatTextBox
  459. */
  460. public function txtCost_Create($strControlId = null) {
  461. $this->txtCost = new QFloatTextBox($this->objParentObject, $strControlId);
  462. $this->txtCost->Name = QApplication::Translate('Cost');
  463. $this->txtCost->Text = $this->objProduct->Cost;
  464. return $this->txtCost;
  465. }
  466. /**
  467. * Create and setup QLabel lblCost
  468. * @param string $strControlId optional ControlId to use
  469. * @param string $strFormat optional sprintf format to use
  470. * @return QLabel
  471. */
  472. public function lblCost_Create($strControlId = null, $strFormat = null) {
  473. $this->lblCost = new QLabel($this->objParentObject, $strControlId);
  474. $this->lblCost->Name = QApplication::Translate('Cost');
  475. $this->lblCost->Text = $this->objProduct->Cost;
  476. $this->lblCost->Format = $strFormat;
  477. return $this->lblCost;
  478. }
  479. /**
  480. * Create and setup QFloatTextBox txtWeight
  481. * @param string $strControlId optional ControlId to use
  482. * @return QFloatTextBox
  483. */
  484. public function txtWeight_Create($strControlId = null) {
  485. $this->txtWeight = new QFloatTextBox($this->objParentObject, $strControlId);
  486. $this->txtWeight->Name = QApplication::Translate('Weight');
  487. $this->txtWeight->Text = $this->objProduct->Weight;
  488. return $this->txtWeight;
  489. }
  490. /**
  491. * Create and setup QLabel lblWeight
  492. * @param string $strControlId optional ControlId to use
  493. * @param string $strFormat optional sprintf format to use
  494. * @return QLabel
  495. */
  496. public function lblWeight_Create($strControlId = null, $strFormat = null) {
  497. $this->lblWeight = new QLabel($this->objParentObject, $strControlId);
  498. $this->lblWeight->Name = QApplication::Translate('Weight');
  499. $this->lblWeight->Text = $this->objProduct->Weight;
  500. $this->lblWeight->Format = $strFormat;
  501. return $this->lblWeight;
  502. }
  503. /**
  504. * Create and setup QFloatTextBox txtHeight
  505. * @param string $strControlId optional ControlId to use
  506. * @return QFloatTextBox
  507. */
  508. public function txtHeight_Create($strControlId = null) {
  509. $this->txtHeight = new QFloatTextBox($this->objParentObject, $strControlId);
  510. $this->txtHeight->Name = QApplication::Translate('Height');
  511. $this->txtHeight->Text = $this->objProduct->Height;
  512. return $this->txtHeight;
  513. }
  514. /**
  515. * Create and setup QLabel lblHeight
  516. * @param string $strControlId optional ControlId to use
  517. * @param string $strFormat optional sprintf format to use
  518. * @return QLabel
  519. */
  520. public function lblHeight_Create($strControlId = null, $strFormat = null) {
  521. $this->lblHeight = new QLabel($this->objParentObject, $strControlId);
  522. $this->lblHeight->Name = QApplication::Translate('Height');
  523. $this->lblHeight->Text = $this->objProduct->Height;
  524. $this->lblHeight->Format = $strFormat;
  525. return $this->lblHeight;
  526. }
  527. /**
  528. * Create and setup QFloatTextBox txtWidth
  529. * @param string $strControlId optional ControlId to use
  530. * @return QFloatTextBox
  531. */
  532. public function txtWidth_Create($strControlId = null) {
  533. $this->txtWidth = new QFloatTextBox($this->objParentObject, $strControlId);
  534. $this->txtWidth->Name = QApplication::Translate('Width');
  535. $this->txtWidth->Text = $this->objProduct->Width;
  536. return $this->txtWidth;
  537. }
  538. /**
  539. * Create and setup QLabel lblWidth
  540. * @param string $strControlId optional ControlId to use
  541. * @param string $strFormat optional sprintf format to use
  542. * @return QLabel
  543. */
  544. public function lblWidth_Create($strControlId = null, $strFormat = null) {
  545. $this->lblWidth = new QLabel($this->objParentObject, $strControlId);
  546. $this->lblWidth->Name = QApplication::Translate('Width');
  547. $this->lblWidth->Text = $this->objProduct->Width;
  548. $this->lblWidth->Format = $strFormat;
  549. return $this->lblWidth;
  550. }
  551. /**
  552. * Create and setup QFloatTextBox txtDepth
  553. * @param string $strControlId optional ControlId to use
  554. * @return QFloatTextBox
  555. */
  556. public function txtDepth_Create($strControlId = null) {
  557. $this->txtDepth = new QFloatTextBox($this->objParentObject, $strControlId);
  558. $this->txtDepth->Name = QApplication::Translate('Depth');
  559. $this->txtDepth->Text = $this->objProduct->Depth;
  560. return $this->txtDepth;
  561. }
  562. /**
  563. * Create and setup QLabel lblDepth
  564. * @param string $strControlId optional ControlId to use
  565. * @param string $strFormat optional sprintf format to use
  566. * @return QLabel
  567. */
  568. public function lblDepth_Create($strControlId = null, $strFormat = null) {
  569. $this->lblDepth = new QLabel($this->objParentObject, $strControlId);
  570. $this->lblDepth->Name = QApplication::Translate('Depth');
  571. $this->lblDepth->Text = $this->objProduct->Depth;
  572. $this->lblDepth->Format = $strFormat;
  573. return $this->lblDepth;
  574. }
  575. /**
  576. * Create and setup QCheckBox chkIsVirtual
  577. * @param string $strControlId optional ControlId to use
  578. * @return QCheckBox
  579. */
  580. public function chkIsVirtual_Create($strControlId = null) {
  581. $this->chkIsVirtual = new QCheckBox($this->objParentObject, $strControlId);
  582. $this->chkIsVirtual->Name = QApplication::Translate('Is Virtual');
  583. $this->chkIsVirtual->Checked = $this->objProduct->IsVirtual;
  584. return $this->chkIsVirtual;
  585. }
  586. /**
  587. * Create and setup QLabel lblIsVirtual
  588. * @param string $strControlId optional ControlId to use
  589. * @return QLabel
  590. */
  591. public function lblIsVirtual_Create($strControlId = null) {
  592. $this->lblIsVirtual = new QLabel($this->objParentObject, $strControlId);
  593. $this->lblIsVirtual->Name = QApplication::Translate('Is Virtual');
  594. $this->lblIsVirtual->Text = ($this->objProduct->IsVirtual) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  595. return $this->lblIsVirtual;
  596. }
  597. /**
  598. * Create and setup QListBox lstType
  599. * @param string $strControlId optional ControlId to use
  600. * @return QListBox
  601. */
  602. public function lstType_Create($strControlId = null) {
  603. $this->lstType = new QListBox($this->objParentObject, $strControlId);
  604. $this->lstType->Name = QApplication::Translate('Type');
  605. $this->lstType->Required = true;
  606. foreach (ProductType::$NameArray as $intId => $strValue)
  607. $this->lstType->AddItem(new QListItem($strValue, $intId, $this->objProduct->TypeId == $intId));
  608. return $this->lstType;
  609. }
  610. /**
  611. * Create and setup QLabel lblTypeId
  612. * @param string $strControlId optional ControlId to use
  613. * @return QLabel
  614. */
  615. public function lblTypeId_Create($strControlId = null) {
  616. $this->lblTypeId = new QLabel($this->objParentObject, $strControlId);
  617. $this->lblTypeId->Name = QApplication::Translate('Type');
  618. $this->lblTypeId->Text = ($this->objProduct->TypeId) ? ProductType::$NameArray[$this->objProduct->TypeId] : null;
  619. $this->lblTypeId->Required = true;
  620. return $this->lblTypeId;
  621. }
  622. /**
  623. * Create and setup QListBox lstStatus
  624. * @param string $strControlId optional ControlId to use
  625. * @return QListBox
  626. */
  627. public function lstStatus_Create($strControlId = null) {
  628. $this->lstStatus = new QListBox($this->objParentObject, $strControlId);
  629. $this->lstStatus->Name = QApplication::Translate('Status');
  630. $this->lstStatus->Required = true;
  631. foreach (ProductStatusType::$NameArray as $intId => $strValue)
  632. $this->lstStatus->AddItem(new QListItem($strValue, $intId, $this->objProduct->StatusId == $intId));
  633. return $this->lstStatus;
  634. }
  635. /**
  636. * Create and setup QLabel lblStatusId
  637. * @param string $strControlId optional ControlId to use
  638. * @return QLabel
  639. */
  640. public function lblStatusId_Create($strControlId = null) {
  641. $this->lblStatusId = new QLabel($this->objParentObject, $strControlId);
  642. $this->lblStatusId->Name = QApplication::Translate('Status');
  643. $this->lblStatusId->Text = ($this->objProduct->StatusId) ? ProductStatusType::$NameArray[$this->objProduct->StatusId] : null;
  644. $this->lblStatusId->Required = true;
  645. return $this->lblStatusId;
  646. }
  647. /**
  648. * Create and setup QIntegerTextBox txtViewCount
  649. * @param string $strControlId optional ControlId to use
  650. * @return QIntegerTextBox
  651. */
  652. public function txtViewCount_Create($strControlId = null) {
  653. $this->txtViewCount = new QIntegerTextBox($this->objParentObject, $strControlId);
  654. $this->txtViewCount->Name = QApplication::Translate('View Count');
  655. $this->txtViewCount->Text = $this->objProduct->ViewCount;
  656. return $this->txtViewCount;
  657. }
  658. /**
  659. * Create and setup QLabel lblViewCount
  660. * @param string $strControlId optional ControlId to use
  661. * @param string $strFormat optional sprintf format to use
  662. * @return QLabel
  663. */
  664. public function lblViewCount_Create($strControlId = null, $strFormat = null) {
  665. $this->lblViewCount = new QLabel($this->objParentObject, $strControlId);
  666. $this->lblViewCount->Name = QApplication::Translate('View Count');
  667. $this->lblViewCount->Text = $this->objProduct->ViewCount;
  668. $this->lblViewCount->Format = $strFormat;
  669. return $this->lblViewCount;
  670. }
  671. /**
  672. * Create and setup QListBox lstProductCategories
  673. * @param string $strControlId optional ControlId to use
  674. * @return QListBox
  675. */
  676. public function lstProductCategories_Create($strControlId = null) {
  677. $this->lstProductCategories = new QListBox($this->objParentObject, $strControlId);
  678. $this->lstProductCategories->Name = QApplication::Translate('Product Categories');
  679. $this->lstProductCategories->SelectionMode = QSelectionMode::Multiple;
  680. $objAssociatedArray = $this->objProduct->GetProductCategoryArray();
  681. $objProductCategoryArray = ProductCategory::LoadAll();
  682. if ($objProductCategoryArray) foreach ($objProductCategoryArray as $objProductCategory) {
  683. $objListItem = new QListItem($objProductCategory->__toString(), $objProductCategory->Id);
  684. foreach ($objAssociatedArray as $objAssociated) {
  685. if ($objAssociated->Id == $objProductCategory->Id)
  686. $objListItem->Selected = true;
  687. }
  688. $this->lstProductCategories->AddItem($objListItem);
  689. }
  690. return $this->lstProductCategories;
  691. }
  692. /**
  693. * Create and setup QLabel lblProductCategories
  694. * @param string $strControlId optional ControlId to use
  695. * @param string $strGlue glue to display in between each associated object
  696. * @return QLabel
  697. */
  698. public function lblProductCategories_Create($strControlId = null, $strGlue = ', ') {
  699. $this->lblProductCategories = new QLabel($this->objParentObject, $strControlId);
  700. $this->lblProductCategories->Name = QApplication::Translate('Product Categories');
  701. $objAssociatedArray = $this->objProduct->GetProductCategoryArray();
  702. $strItems = array();
  703. foreach ($objAssociatedArray as $objAssociated)
  704. $strItems[] = $objAssociated->__toString();
  705. $this->lblProductCategories->Text = implode($strGlue, $strItems);
  706. return $this->lblProductCategories;
  707. }
  708. /**
  709. * Create and setup QListBox lstParentProductsAsRelated
  710. * @param string $strControlId optional ControlId to use
  711. * @return QListBox
  712. */
  713. public function lstParentProductsAsRelated_Create($strControlId = null) {
  714. $this->lstParentProductsAsRelated = new QListBox($this->objParentObject, $strControlId);
  715. $this->lstParentProductsAsRelated->Name = QApplication::Translate('Parent Products As Related');
  716. $this->lstParentProductsAsRelated->SelectionMode = QSelectionMode::Multiple;
  717. $objAssociatedArray = $this->objProduct->GetParentProductAsRelatedArray();
  718. $objProductArray = Product::LoadAll();
  719. if ($objProductArray) foreach ($objProductArray as $objProduct) {
  720. $objListItem = new QListItem($objProduct->__toString(), $objProduct->Id);
  721. foreach ($objAssociatedArray as $objAssociated) {
  722. if ($objAssociated->Id == $objProduct->Id)
  723. $objListItem->Selected = true;
  724. }
  725. $this->lstParentProductsAsRelated->AddItem($objListItem);
  726. }
  727. return $this->lstParentProductsAsRelated;
  728. }
  729. /**
  730. * Create and setup QLabel lblParentProductsAsRelated
  731. * @param string $strControlId optional ControlId to use
  732. * @param string $strGlue glue to display in between each associated object
  733. * @return QLabel
  734. */
  735. public function lblParentProductsAsRelated_Create($strControlId = null, $strGlue = ', ') {
  736. $this->lblParentProductsAsRelated = new QLabel($this->objParentObject, $strControlId);
  737. $this->lblParentProductsAsRelated->Name = QApplication::Translate('Parent Products As Related');
  738. $objAssociatedArray = $this->objProduct->GetParentProductAsRelatedArray();
  739. $strItems = array();
  740. foreach ($objAssociatedArray as $objAssociated)
  741. $strItems[] = $objAssociated->__toString();
  742. $this->lblParentProductsAsRelated->Text = implode($strGlue, $strItems);
  743. return $this->lblParentProductsAsRelated;
  744. }
  745. /**
  746. * Create and setup QListBox lstProductsAsRelated
  747. * @param string $strControlId optional ControlId to use
  748. * @return QListBox
  749. */
  750. public function lstProductsAsRelated_Create($strControlId = null) {
  751. $this->lstProductsAsRelated = new QListBox($this->objParentObject, $strControlId);
  752. $this->lstProductsAsRelated->Name = QApplication::Translate('Products As Related');
  753. $this->lstProductsAsRelated->SelectionMode = QSelectionMode::Multiple;
  754. $objAssociatedArray = $this->objProduct->GetProductAsRelatedArray();
  755. $objProductArray = Product::LoadAll();
  756. if ($objProductArray) foreach ($objProductArray as $objProduct) {
  757. $objListItem = new QListItem($objProduct->__toString(), $objProduct->Id);
  758. foreach ($objAssociatedArray as $objAssociated) {
  759. if ($objAssociated->Id == $objProduct->Id)
  760. $objListItem->Selected = true;
  761. }
  762. $this->lstProductsAsRelated->AddItem($objListItem);
  763. }
  764. return $this->lstProductsAsRelated;
  765. }
  766. /**
  767. * Create and setup QLabel lblProductsAsRelated
  768. * @param string $strControlId optional ControlId to use
  769. * @param string $strGlue glue to display in between each associated object
  770. * @return QLabel
  771. */
  772. public function lblProductsAsRelated_Create($strControlId = null, $strGlue = ', ') {
  773. $this->lblProductsAsRelated = new QLabel($this->objParentObject, $strControlId);
  774. $this->lblProductsAsRelated->Name = QApplication::Translate('Products As Related');
  775. $objAssociatedArray = $this->objProduct->GetProductAsRelatedArray();
  776. $strItems = array();
  777. foreach ($objAssociatedArray as $objAssociated)
  778. $strItems[] = $objAssociated->__toString();
  779. $this->lblProductsAsRelated->Text = implode($strGlue, $strItems);
  780. return $this->lblProductsAsRelated;
  781. }
  782. /**
  783. * Refresh this MetaControl with Data from the local Product object.
  784. * @param boolean $blnReload reload Product from the database
  785. * @return void
  786. */
  787. public function Refresh($blnReload = false) {
  788. if ($blnReload)
  789. $this->objProduct->Reload();
  790. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objProduct->Id;
  791. if ($this->lstManufacturer) {
  792. $this->lstManufacturer->RemoveAllItems();
  793. $this->lstManufacturer->AddItem(QApplication::Translate('- Select One -'), null);
  794. $objManufacturerArray = Person::LoadAll();
  795. if ($objManufacturerArray) foreach ($objManufacturerArray as $objManufacturer) {
  796. $objListItem = new QListItem($objManufacturer->__toString(), $objManufacturer->Id);
  797. if (($this->objProduct->Manufacturer) && ($this->objProduct->Manufacturer->Id == $objManufacturer->Id))
  798. $objListItem->Selected = true;
  799. $this->lstManufacturer->AddItem($objListItem);
  800. }
  801. }
  802. if ($this->lblManufacturerId) $this->lblManufacturerId->Text = ($this->objProduct->Manufacturer) ? $this->objProduct->Manufacturer->__toString() : null;
  803. if ($this->lstSupplier) {
  804. $this->lstSupplier->RemoveAllItems();
  805. $this->lstSupplier->AddItem(QApplication::Translate('- Select One -'), null);
  806. $objSupplierArray = Person::LoadAll();
  807. if ($objSupplierArray) foreach ($objSupplierArray as $objSupplier) {
  808. $objListItem = new QListItem($objSupplier->__toString(), $objSupplier->Id);
  809. if (($this->objProduct->Supplier) && ($this->objProduct->Supplier->Id == $objSupplier->Id))
  810. $objListItem->Selected = true;
  811. $this->lstSupplier->AddItem($objListItem);
  812. }
  813. }
  814. if ($this->lblSupplierId) $this->lblSupplierId->Text = ($this->objProduct->Supplier) ? $this->objProduct->Supplier->__toString() : null;
  815. if ($this->lblCreationDate) if ($this->blnEditMode) $this->lblCreationDate->Text = $this->objProduct->CreationDate;
  816. if ($this->txtName) $this->txtName->Text = $this->objProduct->Name;
  817. if ($this->lblName) $this->lblName->Text = $this->objProduct->Name;
  818. if ($this->txtModel) $this->txtModel->Text = $this->objProduct->Model;
  819. if ($this->lblModel) $this->lblModel->Text = $this->objProduct->Model;
  820. if ($this->txtShortDescription) $this->txtShortDescription->Text = $this->objProduct->ShortDescription;
  821. if ($this->lblShortDescription) $this->lblShortDescription->Text = $this->objProduct->ShortDescription;
  822. if ($this->txtLongDescription) $this->txtLongDescription->Text = $this->objProduct->LongDescription;
  823. if ($this->lblLongDescription) $this->lblLongDescription->Text = $this->objProduct->LongDescription;
  824. if ($this->txtMsrp) $this->txtMsrp->Text = $this->objProduct->Msrp;
  825. if ($this->lblMsrp) $this->lblMsrp->Text = $this->objProduct->Msrp;
  826. if ($this->txtWholesalePrice) $this->txtWholesalePrice->Text = $this->objProduct->WholesalePrice;
  827. if ($this->lblWholesalePrice) $this->lblWholesalePrice->Text = $this->objProduct->WholesalePrice;
  828. if ($this->txtRetailPrice) $this->txtRetailPrice->Text = $this->objProduct->RetailPrice;
  829. if ($this->lblRetailPrice) $this->lblRetailPrice->Text = $this->objProduct->RetailPrice;
  830. if ($this->txtCost) $this->txtCost->Text = $this->objProduct->Cost;
  831. if ($this->lblCost) $this->lblCost->Text = $this->objProduct->Cost;
  832. if ($this->txtWeight) $this->txtWeight->Text = $this->objProduct->Weight;
  833. if ($this->lblWeight) $this->lblWeight->Text = $this->objProduct->Weight;
  834. if ($this->txtHeight) $this->txtHeight->Text = $this->objProduct->Height;
  835. if ($this->lblHeight) $this->lblHeight->Text = $this->objProduct->Height;
  836. if ($this->txtWidth) $this->txtWidth->Text = $this->objProduct->Width;
  837. if ($this->lblWidth) $this->lblWidth->Text = $this->objProduct->Width;
  838. if ($this->txtDepth) $this->txtDepth->Text = $this->objProduct->Depth;
  839. if ($this->lblDepth) $this->lblDepth->Text = $this->objProduct->Depth;
  840. if ($this->chkIsVirtual) $this->chkIsVirtual->Checked = $this->objProduct->IsVirtual;
  841. if ($this->lblIsVirtual) $this->lblIsVirtual->Text = ($this->objProduct->IsVirtual) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  842. if ($this->lstType) $this->lstType->SelectedValue = $this->objProduct->TypeId;
  843. if ($this->lblTypeId) $this->lblTypeId->Text = ($this->objProduct->TypeId) ? ProductType::$NameArray[$this->objProduct->TypeId] : null;
  844. if ($this->lstStatus) $this->lstStatus->SelectedValue = $this->objProduct->StatusId;
  845. if ($this->lblStatusId) $this->lblStatusId->Text = ($this->objProduct->StatusId) ? ProductStatusType::$NameArray[$this->objProduct->StatusId] : null;
  846. if ($this->txtViewCount) $this->txtViewCount->Text = $this->objProduct->ViewCount;
  847. if ($this->lblViewCount) $this->lblViewCount->Text = $this->objProduct->ViewCount;
  848. if ($this->lstProductCategories) {
  849. $this->lstProductCategories->RemoveAllItems();
  850. $objAssociatedArray = $this->objProduct->GetProductCategoryArray();
  851. $objProductCategoryArray = ProductCategory::LoadAll();
  852. if ($objProductCategoryArray) foreach ($objProductCategoryArray as $objProductCategory) {
  853. $objListItem = new QListItem($objProductCategory->__toString(), $objProductCategory->Id);
  854. foreach ($objAssociatedArray as $objAssociated) {
  855. if ($objAssociated->Id == $objProductCategory->Id)
  856. $objListItem->Selected = true;
  857. }
  858. $this->lstProductCategories->AddItem($objListItem);
  859. }
  860. }
  861. if ($this->lblProductCategories) {
  862. $objAssociatedArray = $this->objProduct->GetProductCategoryArray();
  863. $strItems = array();
  864. foreach ($objAssociatedArray as $objAssociated)
  865. $strItems[] = $objAssociated->__toString();
  866. $this->lblProductCategories->Text = implode($strGlue, $strItems);
  867. }
  868. if ($this->lstParentProductsAsRelated) {
  869. $this->lstParentProductsAsRelated->RemoveAllItems();
  870. $objAssociatedArray = $this->objProduct->GetParentProductAsRelatedArray();
  871. $objProductArray = Product::LoadAll();
  872. if ($objProductArray) foreach ($objProductArray as $objProduct) {
  873. $objListItem = new QListItem($objProduct->__toString(), $objProduct->Id);
  874. foreach ($objAssociatedArray as $objAssociated) {
  875. if ($objAssociated->Id == $objProduct->Id)
  876. $objListItem->Selected = true;
  877. }
  878. $this->lstParentProductsAsRelated->AddItem($objListItem);
  879. }
  880. }
  881. if ($this->lblParentProductsAsRelated) {
  882. $objAssociatedArray = $this->objProduct->GetParentProductAsRelatedArray();
  883. $strItems = array();
  884. foreach ($objAssociatedArray as $objAssociated)
  885. $strItems[] = $objAssociated->__toString();
  886. $this->lblParentProductsAsRelated->Text = implode($strGlue, $strItems);
  887. }
  888. if ($this->lstProductsAsRelated) {
  889. $this->lstProductsAsRelated->RemoveAllItems();
  890. $objAssociatedArray = $this->objProduct->GetProductAsRelatedArray();
  891. $objProductArray = Product::LoadAll();
  892. if ($objProductArray) foreach ($objProductArray as $objProduct) {
  893. $objListItem = new QListItem($objProduct->__toString(), $objProduct->Id);
  894. foreach ($objAssociatedArray as $objAssociated) {
  895. if ($objAssociated->Id == $objProduct->Id)
  896. $objListItem->Selected = true;
  897. }
  898. $this->lstProductsAsRelated->AddItem($objListItem);
  899. }
  900. }
  901. if ($this->lblProductsAsRelated) {
  902. $objAssociatedArray = $this->objProduct->GetProductAsRelatedArray();
  903. $strItems = array();
  904. foreach ($objAssociatedArray as $objAssociated)
  905. $strItems[] = $objAssociated->__toString();
  906. $this->lblProductsAsRelated->Text = implode($strGlue, $strItems);
  907. }
  908. }
  909. ///////////////////////////////////////////////
  910. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  911. ///////////////////////////////////////////////
  912. protected function lstProductCategories_Update() {
  913. if ($this->lstProductCategories) {
  914. $this->objProduct->UnassociateAllProductCategories();
  915. $objSelectedListItems = $this->lstProductCategories->SelectedItems;
  916. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  917. $this->objProduct->AssociateProductCategory(ProductCategory::Load($objListItem->Value));
  918. }
  919. }
  920. }
  921. protected function lstParentProductsAsRelated_Update() {
  922. if ($this->lstParentProductsAsRelated) {
  923. $this->objProduct->UnassociateAllParentProductsAsRelated();
  924. $objSelectedListItems = $this->lstParentProductsAsRelated->SelectedItems;
  925. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  926. $this->objProduct->AssociateParentProductAsRelated(Product::Load($objListItem->Value));
  927. }
  928. }
  929. }
  930. protected function lstProductsAsRelated_Update() {
  931. if ($this->lstProductsAsRelated) {
  932. $this->objProduct->UnassociateAllProductsAsRelated();
  933. $objSelectedListItems = $this->lstProductsAsRelated->SelectedItems;
  934. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  935. $this->objProduct->AssociateProductAsRelated(Product::Load($objListItem->Value));
  936. }
  937. }
  938. }
  939. ///////////////////////////////////////////////
  940. // PUBLIC PRODUCT OBJECT MANIPULATORS
  941. ///////////////////////////////////////////////
  942. /**
  943. * This will save this object's Product instance,
  944. * updating only the fields which have had a control created for it.
  945. */
  946. public function SaveProduct() {
  947. try {
  948. // Update any fields for controls that have been created
  949. if ($this->lstManufacturer) $this->objProduct->ManufacturerId = $this->lstManufacturer->SelectedValue;
  950. if ($this->lstSupplier) $this->objProduct->SupplierId = $this->lstSupplier->SelectedValue;
  951. if ($this->txtName) $this->objProduct->Name = $this->txtName->Text;
  952. if ($this->txtModel) $this->objProduct->Model = $this->txtModel->Text;
  953. if ($this->txtShortDescription) $this->objProduct->ShortDescription = $this->txtShortDescription->Text;
  954. if ($this->txtLongDescription) $this->objProduct->LongDescription = $this->txtLongDescription->Text;
  955. if ($this->txtMsrp) $this->objProduct->Msrp = $this->txtMsrp->Text;
  956. if ($this->txtWholesalePrice) $this->objProduct->WholesalePrice = $this->txtWholesalePrice->Text;
  957. if ($this->txtRetailPrice) $this->objProduct->RetailPrice = $this->txtRetailPrice->Text;
  958. if ($this->txtCost) $this->objProduct->Cost = $this->txtCost->Text;
  959. if ($this->txtWeight) $this->objProduct->Weight = $this->txtWeight->Text;
  960. if ($this->txtHeight) $this->objProduct->Height = $this->txtHeight->Text;
  961. if ($this->txtWidth) $this->objProduct->Width = $this->txtWidth->Text;
  962. if ($this->txtDepth) $this->objProduct->Depth = $this->txtDepth->Text;
  963. if ($this->chkIsVirtual) $this->objProduct->IsVirtual = $this->chkIsVirtual->Checked;
  964. if ($this->lstType) $this->objProduct->TypeId = $this->lstType->SelectedValue;
  965. if ($this->lstStatus) $this->objProduct->StatusId = $this->lstStatus->SelectedValue;
  966. if ($this->txtViewCount) $this->objProduct->ViewCount = $this->txtViewCount->Text;
  967. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  968. // Save the Product object
  969. $this->objProduct->Save();
  970. // Finally, update any ManyToManyReferences (if any)
  971. $this->lstProductCategories_Update();
  972. $this->lstParentProductsAsRelated_Update();
  973. $this->lstProductsAsRelated_Update();
  974. } catch (QCallerException $objExc) {
  975. $objExc->IncrementOffset();
  976. throw $objExc;
  977. }
  978. }
  979. /**
  980. * This will DELETE this object's Product instance from the database.
  981. * It will also unassociate itself from any ManyToManyReferences.
  982. */
  983. public function DeleteProduct() {
  984. $this->objProduct->UnassociateAllProductCategories();
  985. $this->objProduct->UnassociateAllParentProductsAsRelated();
  986. $this->objProduct->UnassociateAllProductsAsRelated();
  987. $this->objProduct->Delete();
  988. }
  989. ///////////////////////////////////////////////
  990. // PUBLIC GETTERS and SETTERS
  991. ///////////////////////////////////////////////
  992. /**
  993. * Override method to perform a property "Get"
  994. * This will get the value of $strName
  995. *
  996. * @param string $strName Name of the property to get
  997. * @return mixed
  998. */
  999. public function __get($strName) {
  1000. switch ($strName) {
  1001. // General MetaControlVariables
  1002. case 'Product': return $this->objProduct;
  1003. case 'TitleVerb': return $this->strTitleVerb;
  1004. case 'EditMode': return $this->blnEditMode;
  1005. // Controls that point to Product fields -- will be created dynamically if not yet created
  1006. case 'IdControl':
  1007. if (!$this->lblId) return $this->lblId_Create();
  1008. return $this->lblId;
  1009. case 'IdLabel':
  1010. if (!$this->lblId) return $this->lblId_Create();
  1011. return $this->lblId;
  1012. case 'ManufacturerIdControl':
  1013. if (!$this->lstManufacturer) return $this->lstManufacturer_Create();
  1014. return $this->lstManufacturer;
  1015. case 'ManufacturerIdLabel':
  1016. if (!$this->lblManufacturerId) return $this->lblManufacturerId_Create();
  1017. return $this->lblManufacturerId;
  1018. case 'SupplierIdControl':
  1019. if (!$this->lstSupplier) return $this->lstSupplier_Create();
  1020. return $this->lstSupplier;
  1021. case 'SupplierIdLabel':
  1022. if (!$this->lblSupplierId) return $this->lblSupplierId_Create();
  1023. return $this->lblSupplierId;
  1024. case 'CreationDateControl':
  1025. if (!$this->lblCreationDate) return $this->lblCreationDate_Create();
  1026. return $this->lblCreationDate;
  1027. case 'CreationDateLabel':
  1028. if (!$this->lblCreationDate) return $this->lblCreationDate_Create();
  1029. return $this->lblCreationDate;
  1030. case 'NameControl':
  1031. if (!$this->txtName) return $this->txtName_Create();
  1032. return $this->txtName;
  1033. case 'NameLabel':
  1034. if (!$this->lblName) return $this->lblName_Create();
  1035. return $this->lblName;
  1036. case 'ModelControl':
  1037. if (!$this->txtModel) return $this->txtModel_Create();
  1038. return $this->txtModel;
  1039. case 'ModelLabel':
  1040. if (!$this->lblModel) return $this->lblModel_Create();
  1041. return $this->lblModel;
  1042. case 'ShortDescriptionControl':
  1043. if (!$this->txtShortDescription) return $this->txtShortDescription_Create();
  1044. return $this->txtShortDescription;
  1045. case 'ShortDescriptionLabel':
  1046. if (!$this->lblShortDescription) return $this->lblShortDescription_Create();
  1047. return $this->lblShortDescription;
  1048. case 'LongDescriptionControl':
  1049. if (!$this->txtLongDescription) return $this->txtLongDescription_Create();
  1050. return $this->txtLongDescription;
  1051. case 'LongDescriptionLabel':
  1052. if (!$this->lblLongDescription) return $this->lblLongDescription_Create();
  1053. return $this->lblLongDescription;
  1054. case 'MsrpControl':
  1055. if (!$this->txtMsrp) return $this->txtMsrp_Create();
  1056. return $this->txtMsrp;
  1057. case 'MsrpLabel':
  1058. if (!$this->lblMsrp) return $this->lblMsrp_Create();
  1059. return $this->lblMsrp;
  1060. case 'WholesalePriceControl':
  1061. if (!$this->txtWholesalePrice) return $this->txtWholesalePrice_Create();
  1062. return $this->txtWholesalePrice;
  1063. case 'WholesalePriceLabel':
  1064. if (!$this->lblWholesalePrice) return $this->lblWholesalePrice_Create();
  1065. return $this->lblWholesalePrice;
  1066. case 'RetailPriceControl':
  1067. if (!$this->txtRetailPrice) return $this->txtRetailPrice_Create();
  1068. return $this->txtRetailPrice;
  1069. case 'RetailPriceLabel':
  1070. if (!$this->lblRetailPrice) return $this->lblRetailPrice_Create();
  1071. return $this->lblRetailPrice;
  1072. case 'CostControl':
  1073. if (!$this->txtCost) return $this->txtCost_Create();
  1074. return $this->txtCost;
  1075. case 'CostLabel':
  1076. if (!$this->lblCost) return $this->lblCost_Create();
  1077. return $this->lblCost;
  1078. case 'WeightControl':
  1079. if (!$this->txtWeight) return $this->txtWeight_Create();
  1080. return $this->txtWeight;
  1081. case 'WeightLabel':
  1082. if (!$this->lblWeight) return $this->lblWeight_Create();
  1083. return $this->lblWeight;
  1084. case 'HeightControl':
  1085. if (!$this->txtHeight) return $this->txtHeight_Create();
  1086. return $this->txtHeight;
  1087. case 'HeightLabel':
  1088. if (!$this->lblHeight) return $this->lblHeight_Create();
  1089. return $this->lblHeight;
  1090. case 'WidthControl':
  1091. if (!$this->txtWidth) return $this->txtWidth_Create();
  1092. return $this->txtWidth;
  1093. case 'WidthLabel':
  1094. if (!$this->lblWidth) return $this->lblWidth_Create();
  1095. return $this->lblWidth;
  1096. case 'DepthControl':
  1097. if (!$this->txtDepth) return $this->txtDepth_Create();
  1098. return $this->txtDepth;
  1099. case 'DepthLabel':
  1100. if (!$this->lblDepth) return $this->lblDepth_Create();
  1101. return $this->lblDepth;
  1102. case 'IsVirtualControl':
  1103. if (!$this->chkIsVirtual) return $this->chkIsVirtual_Create();
  1104. return $this->chkIsVirtual;
  1105. case 'IsVirtualLabel':
  1106. if (!$this->lblIsVirtual) return $this->lblIsVirtual_Create();
  1107. return $this->lblIsVirtual;
  1108. case 'TypeIdControl':
  1109. if (!$this->lstType) return $this->lstType_Create();
  1110. return $this->lstType;
  1111. case 'TypeIdLabel':
  1112. if (!$this->lblTypeId) return $this->lblTypeId_Create();
  1113. return $this->lblTypeId;
  1114. case 'StatusIdControl':
  1115. if (!$this->lstStatus) return $this->lstStatus_Create();
  1116. return $this->lstStatus;
  1117. case 'StatusIdLabel':
  1118. if (!$this->lblStatusId) return $this->lblStatusId_Create();
  1119. return $this->lblStatusId;
  1120. case 'ViewCountControl':
  1121. if (!$this->txtViewCount) return $this->txtViewCount_Create();
  1122. return $this->txtViewCount;
  1123. case 'ViewCountLabel':
  1124. if (!$this->lblViewCount) return $this->lblViewCount_Create();
  1125. return $this->lblViewCount;
  1126. case 'ProductCategoryControl':
  1127. if (!$this->lstProductCategories) return $this->lstProductCategories_Create();
  1128. return $this->lstProductCategories;
  1129. case 'ProductCategoryLabel':
  1130. if (!$this->lblProductCategories) return $this->lblProductCategories_Create();
  1131. return $this->lblProductCategories;
  1132. case 'ParentProductAsRelatedControl':
  1133. if (!$this->lstParentProductsAsRelated) return $this->lstParentProductsAsRelated_Create();
  1134. return $this->lstParentProductsAsRelated;
  1135. case 'ParentProductAsRelatedLabel':
  1136. if (!$this->lblParentProductsAsRelated) return $this->lblParentProductsAsRelated_Create();
  1137. return $this->lblParentProductsAsRelated;
  1138. case 'ProductAsRelatedControl':
  1139. if (!$this->lstProductsAsRelated) return $this->lstProductsAsRelated_Create();
  1140. return $this->lstProductsAsRelated;
  1141. case 'ProductAsRelatedLabel':
  1142. if (!$this->lblProductsAsRelated) return $this->lblProductsAsRelated_Create();
  1143. return $this->lblProductsAsRelated;
  1144. default:
  1145. try {
  1146. return parent::__get($strName);
  1147. } catch (QCallerException $objExc) {
  1148. $objExc->IncrementOffset();
  1149. throw $objExc;
  1150. }
  1151. }
  1152. }
  1153. /**
  1154. * Override method to perform a property "Set"
  1155. * This will set the property $strName to be $mixValue
  1156. *
  1157. * @param string $strName Name of the property to set
  1158. * @param string $mixValue New value of the property
  1159. * @return mixed
  1160. */
  1161. public function __set($strName, $mixValue) {
  1162. try {
  1163. switch ($strName) {
  1164. // Controls that point to Product fields
  1165. case 'IdControl':
  1166. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  1167. case 'ManufacturerIdControl':
  1168. return ($this->lstManufacturer = QType::Cast($mixValue, 'QControl'));
  1169. case 'SupplierIdControl':
  1170. return ($this->lstSupplier = QType::Cast($mixValue, 'QControl'));
  1171. case 'CreationDateControl':
  1172. return ($this->lblCreationDate = QType::Cast($mixValue, 'QControl'));
  1173. case 'NameControl':
  1174. return ($this->txtName = QType::Cast($mixValue, 'QControl'));
  1175. case 'ModelControl':
  1176. return ($this->txtModel = QType::Cast($mixValue, 'QControl'));
  1177. case 'ShortDescriptionControl':
  1178. return ($this->txtShortDescription = QType::Cast($mixValue, 'QControl'));
  1179. case 'LongDescriptionControl':
  1180. return ($this->txtLongDescription = QType::Cast($mixValue, 'QControl'));
  1181. case 'MsrpControl':
  1182. return ($this->txtMsrp = QType::Cast($mixValue, 'QControl'));
  1183. case 'WholesalePriceControl':
  1184. return ($this->txtWholesalePrice = QType::Cast($mixValue, 'QControl'));
  1185. case 'RetailPriceControl':
  1186. return ($this->txtRetailPrice = QType::Cast($mixValue, 'QControl'));
  1187. case 'CostControl':
  1188. return ($this->txtCost = QType::Cast($mixValue, 'QControl'));
  1189. case 'WeightControl':
  1190. return ($this->txtWeight = QType::Cast($mixValue, 'QControl'));
  1191. case 'HeightControl':
  1192. return ($this->txtHeight = QType::Cast($mixValue, 'QControl'));
  1193. case 'WidthControl':
  1194. return ($this->txtWidth = QType::Cast($mixValue, 'QControl'));
  1195. case 'DepthControl':
  1196. return ($this->txtDepth = QType::Cast($mixValue, 'QControl'));
  1197. case 'IsVirtualControl':
  1198. return ($this->chkIsVirtual = QType::Cast($mixValue, 'QControl'));
  1199. case 'TypeIdControl':
  1200. return ($this->lstType = QType::Cast($mixValue, 'QControl'));
  1201. case 'StatusIdControl':
  1202. return ($this->lstStatus = QType::Cast($mixValue, 'QControl'));
  1203. case 'ViewCountControl':
  1204. return ($this->txtViewCount = QType::Cast($mixValue, 'QControl'));
  1205. case 'ProductCategoryControl':
  1206. return ($this->lstProductCategories = QType::Cast($mixValue, 'QControl'));
  1207. case 'ParentProductAsRelatedControl':
  1208. return ($this->lstParentProductsAsRelated = QType::Cast($mixValue, 'QControl'));
  1209. case 'ProductAsRelatedControl':
  1210. return ($this->lstProductsAsRelated = QType::Cast($mixValue, 'QControl'));
  1211. default:
  1212. return parent::__set($strName, $mixValue);
  1213. }
  1214. } catch (QCallerException $objExc) {
  1215. $objExc->IncrementOffset();
  1216. throw $objExc;
  1217. }
  1218. }
  1219. }
  1220. ?>