Product.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* * ********************************************************************
  3. * Wordpress_Manager Product developed. (Dec 8, 2017)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\ProxmoxAddon\App\Models\Whmcs;
  20. use Illuminate\Database\Capsule\Manager as DB;
  21. use ModulesGarden\ProxmoxAddon\App\Models\ProductConfiguration;
  22. /**
  23. * Description of Product
  24. *
  25. * @author Pawel Kopec <pawelk@modulesgarden.com>
  26. * @property int $id
  27. * @property string $type
  28. * @property int $gid
  29. * @property string $name
  30. * @property string $description
  31. * @property int $hidden
  32. * @property int $showdomainoptions
  33. * @property int $welcomeemail
  34. * @property int $stockcontrol
  35. * @property int $qty
  36. * @property int $proratabilling
  37. * @property int $proratadate
  38. * @property int $proratachargenextmonth
  39. * @property string $paytype
  40. * @property int $allowqty
  41. * @property string $subdomain
  42. * @property string $autosetup
  43. * @property string $servertype
  44. * @property int $servergroup
  45. * @property string $configoption1
  46. * @property string $configoption2
  47. * @property string $configoption3
  48. * @property string $configoption4
  49. * @property string $configoption5
  50. * @property string $configoption6
  51. * @property string $configoption7
  52. * @property string $configoption8
  53. * @property string $configoption9
  54. * @property string $configoption10
  55. * @property string $configoption11
  56. * @property string $configoption12
  57. * @property string $configoption13
  58. * @property string $configoption14
  59. * @property string $configoption15
  60. * @property string $configoption16
  61. * @property string $configoption17
  62. * @property string $configoption18
  63. * @property string $configoption19
  64. * @property string $configoption20
  65. * @property string $configoption21
  66. * @property string $configoption22
  67. * @property string $configoption23
  68. * @property string $configoption24
  69. * @property string $freedomain
  70. * @property string $freedomainpaymentterms
  71. * @property string $freedomaintlds
  72. * @property int $recurringcycles
  73. * @property int $autoterminatedays
  74. * @property int $autoterminateemail
  75. * @property int $configoptionsupgrade
  76. * @property string $billingcycleupgrade
  77. * @property int $upgradeemail
  78. * @property string $overagesenabled
  79. * @property int $overagesdisklimit
  80. * @property int $overagesbwlimit
  81. * @property float $overagesdiskprice
  82. * @property float $overagesbwprice
  83. * @property int $tax
  84. * @property int $affiliateonetime
  85. * @property string $affiliatepaytype
  86. * @property float $affiliatepayamount
  87. * @property int $order
  88. * @property int $retired
  89. * @property int $is_featured
  90. * @property string $created_at
  91. * @property string $updated_at
  92. * @property ProductConfiguration $configuration
  93. * @method static $this ofProxmoxCloud()
  94. */
  95. class Product extends \ModulesGarden\ProxmoxAddon\Core\Models\Whmcs\Product
  96. {
  97. /**
  98. *
  99. * @return ProductConfiguration
  100. */
  101. public function configuration()
  102. {
  103. return $this->hasOne('\ModulesGarden\ProxmoxAddon\App\Models\ProductConfiguration', 'product_id', 'id');
  104. }
  105. /**
  106. * @return []
  107. */
  108. public function getParams()
  109. {
  110. $statement = DB::connection()
  111. ->getPdo()
  112. ->prepare("SELECT s.ipaddress AS serverip, s.hostname AS serverhostname, s.username AS serverusername, s.password AS serverpassword, s.secure AS serversecure,
  113. s.accesshash AS serveraccesshash, s.id AS serverid, s.port AS serverport,
  114. configoption1,configoption2,configoption3,configoption4,configoption5,configoption6,configoption7,configoption8,configoption9
  115. FROM tblservers AS s
  116. JOIN tblservergroupsrel AS sgr ON sgr.serverid = s.id
  117. JOIN tblservergroups AS sg ON sgr.groupid = sg.id
  118. JOIN tblproducts AS p ON p.servergroup = sg.id
  119. WHERE p.id = :pid
  120. ORDER BY s.active DESC LIMIT 1");
  121. $statement->execute(["pid" => $this->id]);
  122. $row = $statement->fetch(\PDO::FETCH_ASSOC);
  123. if (empty($row))
  124. {
  125. $s = 'tblservers';
  126. $p = 'tblproducts';
  127. $row = (array)DB::table($s)
  128. ->select("{$s}.ipaddress AS serverip", "{$s}.hostname AS serverhostname", "{$s}.username AS serverusername",
  129. "{$s}.password AS serverpassword", "{$s}.secure AS serversecure", "{$s}.accesshash AS serveraccesshash", "{$s}.port AS serverport")
  130. ->rightJoin($p, "{$p}.servertype", "=", "{$s}.type")
  131. ->where("{$p}.id", $this->id)
  132. ->orderBy("{$s}.active", 'desc')
  133. ->first();
  134. }
  135. $row['serverpassword'] = html_entity_decode(decrypt($row['serverpassword']),ENT_QUOTES);;
  136. $row['packageid'] = $this->id;
  137. return $row;
  138. }
  139. public function scopeOfProxmoxCloud($query){
  140. $query->where('servertype', 'ProxmoxCloudVps');
  141. return $query;
  142. }
  143. }