Listing.php 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ yWmrd6SsYKr+Ju1kqDkgXtlajw1PaVMT9T2YTgnUX0c=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2017 Online Ventures Software & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.10 [rev.7.10.03]
  11. */
  12. namespace Ppb\Model\Elements;
  13. use Cube\Controller\Front,
  14. Cube\Validate,
  15. Ppb\Db\Table,
  16. Ppb\Db\Table\Row\User as UserModel,
  17. Ppb\Model\Shipping as ShippingModel,
  18. Ppb\Service;
  19. class Listing extends AbstractElements
  20. {
  21. /**
  22. *
  23. * form id
  24. *
  25. * @var string
  26. */
  27. protected $_formId;
  28. /**
  29. *
  30. * listing owner
  31. *
  32. * @var \Ppb\Db\Table\Row\User
  33. */
  34. protected $_user;
  35. /**
  36. *
  37. * listing types available
  38. * Default: auction, product, wanted, reverse, first_bidder
  39. *
  40. * @var array
  41. */
  42. protected $_listingTypes = array();
  43. /**
  44. *
  45. * list in options
  46. *
  47. * @var array
  48. */
  49. protected $_listIn = array();
  50. /**
  51. *
  52. * currencies table service
  53. *
  54. * @var \Ppb\Service\Table\Currencies
  55. */
  56. protected $_currencies;
  57. /**
  58. *
  59. * durations table service
  60. *
  61. * @var \Ppb\Service\Table\Durations
  62. */
  63. protected $_durations;
  64. /**
  65. *
  66. * offline payment methods table service
  67. *
  68. * @var \Ppb\Service\Table\OfflinePaymentMethods
  69. */
  70. protected $_paymentMethods;
  71. /**
  72. *
  73. * payment gateways table service
  74. *
  75. * @var \Ppb\Service\Table\PaymentGateways
  76. */
  77. protected $_paymentGateways;
  78. /**
  79. *
  80. * fees service
  81. *
  82. * @var \Ppb\Service\Fees
  83. */
  84. protected $_fees;
  85. /**
  86. *
  87. * admin flag
  88. *
  89. * @var bool
  90. */
  91. protected $_inAdmin = false;
  92. /**
  93. *
  94. * class constructor
  95. *
  96. * @param string $formId
  97. * @param bool $inAdmin
  98. */
  99. public function __construct($formId = null, $inAdmin = false)
  100. {
  101. parent::__construct();
  102. $this->_formId = $formId;
  103. $this->_inAdmin = $inAdmin;
  104. }
  105. /**
  106. *
  107. * get current user
  108. *
  109. * @return \Ppb\Db\Table\Row\User
  110. */
  111. public function getUser()
  112. {
  113. if (!$this->_user instanceof UserModel) {
  114. $this->setUser(
  115. Front::getInstance()->getBootstrap()->getResource('user'));
  116. }
  117. return $this->_user;
  118. }
  119. /**
  120. *
  121. * set current user
  122. *
  123. * @param \Ppb\Db\Table\Row\User $user
  124. *
  125. * @return $this
  126. */
  127. public function setUser(UserModel $user)
  128. {
  129. $this->_user = $user;
  130. return $this;
  131. }
  132. /**
  133. *
  134. * get list in options
  135. *
  136. * @return array
  137. */
  138. public function getListIn()
  139. {
  140. if (empty($this->_listIn)) {
  141. $this->setListIn();
  142. }
  143. return $this->_listIn;
  144. }
  145. /**
  146. *
  147. * set list in field options
  148. * if store only mode is enabled, items will all be listed as in "Both"
  149. *
  150. * @param array $listIn
  151. *
  152. * @return $this
  153. */
  154. public function setListIn(array $listIn = null)
  155. {
  156. if ($listIn === null) {
  157. $settings = $this->getSettings();
  158. $user = $this->getUser();
  159. if (!$settings['store_only_mode']) {
  160. $listIn['site'] = 'Site';
  161. }
  162. $storeEnabled = false;
  163. if ($user['id']) {
  164. $storeEnabled = $user->storeStatus();
  165. }
  166. if ($storeEnabled) {
  167. if ($settings['stores_force_list_in_both']) {
  168. $listIn = array();
  169. }
  170. else if (!$settings['store_only_mode']) {
  171. $listIn['store'] = 'Store';
  172. }
  173. $listIn['both'] = 'Both';
  174. }
  175. }
  176. $this->_listIn = (array)$listIn;
  177. return $this;
  178. }
  179. /**
  180. *
  181. * get currencies table service
  182. *
  183. * @return \Ppb\Service\Table\Currencies
  184. */
  185. public function getCurrencies()
  186. {
  187. if (!$this->_currencies instanceof Service\Table\Currencies) {
  188. $this->setCurrencies(
  189. new Service\Table\Currencies());
  190. }
  191. return $this->_currencies;
  192. }
  193. /**
  194. *
  195. * set currencies service
  196. *
  197. * @param \Ppb\Service\Table\Currencies $currencies
  198. *
  199. * @return $this
  200. */
  201. public function setCurrencies(Service\Table\Currencies $currencies)
  202. {
  203. $this->_currencies = $currencies;
  204. return $this;
  205. }
  206. /**
  207. *
  208. * get durations table service
  209. *
  210. * @return \Ppb\Service\Table\Durations
  211. */
  212. public function getDurations()
  213. {
  214. if (!$this->_durations instanceof Service\Table\Durations) {
  215. $this->setDurations(
  216. new Service\Table\Durations());
  217. }
  218. return $this->_durations;
  219. }
  220. /**
  221. *
  222. * set durations service
  223. *
  224. * @param \Ppb\Service\Table\Durations $durations
  225. *
  226. * @return $this
  227. */
  228. public function setDurations(Service\Table\Durations $durations)
  229. {
  230. $this->_durations = $durations;
  231. return $this;
  232. }
  233. /**
  234. *
  235. * get offline payment methods table service
  236. *
  237. * @return \Ppb\Service\Table\OfflinePaymentMethods
  238. */
  239. public function getPaymentMethods()
  240. {
  241. if (!$this->_paymentMethods instanceof Service\Table\OfflinePaymentMethods) {
  242. $this->setPaymentMethods(
  243. new Service\Table\OfflinePaymentMethods());
  244. }
  245. return $this->_paymentMethods;
  246. }
  247. /**
  248. *
  249. * set offline payment methods table service
  250. *
  251. * @param \Ppb\Service\Table\OfflinePaymentMethods $paymentMethods
  252. *
  253. * @return $this
  254. */
  255. public function setPaymentMethods(Service\Table\OfflinePaymentMethods $paymentMethods)
  256. {
  257. $this->_paymentMethods = $paymentMethods;
  258. return $this;
  259. }
  260. /**
  261. *
  262. * get payment gateways table service
  263. *
  264. * @return \Ppb\Service\Table\PaymentGateways
  265. */
  266. public function getPaymentGateways()
  267. {
  268. if (!$this->_paymentGateways instanceof Service\Table\PaymentGateways) {
  269. $this->setPaymentGateways(
  270. new Service\Table\PaymentGateways());
  271. }
  272. return $this->_paymentGateways;
  273. }
  274. /**
  275. *
  276. * set payment gateways table service
  277. *
  278. * @param \Ppb\Service\Table\PaymentGateways $paymentGateways
  279. *
  280. * @return $this
  281. */
  282. public function setPaymentGateways(Service\Table\PaymentGateways $paymentGateways)
  283. {
  284. $this->_paymentGateways = $paymentGateways;
  285. return $this;
  286. }
  287. /**
  288. *
  289. * get fees service
  290. *
  291. * @return \Ppb\Service\Fees
  292. */
  293. public function getFees()
  294. {
  295. if (!$this->_fees instanceof Service\Fees) {
  296. $this->setFees(
  297. new Service\Fees());
  298. }
  299. return $this->_fees;
  300. }
  301. /**
  302. *
  303. * set fees service
  304. *
  305. * @param \Ppb\Service\Fees $fees
  306. *
  307. * @return $this
  308. */
  309. public function setFees(Service\Fees $fees)
  310. {
  311. $this->_fees = $fees;
  312. return $this;
  313. }
  314. /**
  315. *
  316. * get form data
  317. * for certain keys, generate preset values
  318. *
  319. * @param string $key
  320. *
  321. * @return mixed
  322. */
  323. public function getData($key = null)
  324. {
  325. $result = parent::getData($key);
  326. if ($result === null) {
  327. $settings = $this->getSettings();
  328. switch ($key) {
  329. case 'list_in':
  330. $listInKeys = array_keys($this->getListIn());
  331. $result = array_shift($listInKeys);
  332. $this->addData('list_in', $result);
  333. break;
  334. case 'listing_type':
  335. $listIn = $this->getData('list_in');
  336. if ($listIn != 'site' && !$settings['enable_auctions_in_stores'] && $settings['enable_products']) {
  337. $result = 'product';
  338. }
  339. else {
  340. $listingTypesKeys = array_keys($this->getListingTypes());
  341. $result = array_shift($listingTypesKeys);
  342. }
  343. $this->addData('listing_type', $result);
  344. break;
  345. case 'currency':
  346. $result = $settings['currency'];
  347. $this->addData('currency', $result);
  348. break;
  349. case 'country':
  350. $countries = $this->getLocations()->getMultiOptions();
  351. $result = intval($this->getFirstElement($countries));
  352. $this->addData('country', $result);
  353. break;
  354. }
  355. }
  356. return $result;
  357. }
  358. /**
  359. *
  360. * generate listing form elements
  361. *
  362. * @return array
  363. */
  364. public function getElements()
  365. {
  366. $listIn = $this->getListIn();
  367. $listingTypes = $this->getListingTypes();
  368. $currencies = $this->getCurrencies()->getMultiOptions('iso_code');
  369. $settings = $this->getSettings();
  370. $translate = $this->getTranslate();
  371. $durations = $this->getDurations()->getMultiOptions($this->getData('listing_type'));
  372. $countries = $this->getLocations()->getMultiOptions();
  373. $states = $this->getLocations()->getMultiOptions(
  374. $this->getData('country'));
  375. $paymentGateways = $this->getPaymentGateways()->getMultiOptions($this->_user['id']);
  376. $paymentMethods = $this->getPaymentMethods()->getMultiOptions();
  377. $categoryId = $this->getData('category_id');
  378. $addlCategoryId = $this->getData('addl_category_id');
  379. $categoriesFilter = array(0);
  380. if ($categoryId) {
  381. $categoriesFilter = array_merge($categoriesFilter, array_keys(
  382. $this->getCategories()->getBreadcrumbs($categoryId)));
  383. }
  384. if ($addlCategoryId) {
  385. $categoriesFilter = array_merge($categoriesFilter, array_keys(
  386. $this->getCategories()->getBreadcrumbs($addlCategoryId)));
  387. }
  388. $customFieldsType = (in_array($this->_formId, $this->getCustomFields()->getCustomFieldTypes())) ?
  389. $this->_formId : 'item';
  390. $customFields = $this->getCustomFields()->getFields(
  391. array(
  392. 'type' => $customFieldsType,
  393. 'active' => 1,
  394. 'category_ids' => $categoriesFilter,
  395. ))->toArray();
  396. $calculationAmount = ($this->getData('listing_type') == 'product') ?
  397. $this->getData('buyout_price') : max(array($this->getData('start_price'), $this->getData('reserve_price')));
  398. $this->getFees()->setCategoryId($this->getData('category_id'))
  399. ->setUser($this->getUser())
  400. ->setAmount($calculationAmount);
  401. // images field related description
  402. $imagesDescription = sprintf($translate->_('You can upload up to %s images. Arrange by drag and drop.'), $settings['images_max']);
  403. $imagesFeeAmount = $this->getFees()->getFeeAmount(Service\Fees::IMAGES);
  404. $nbFreeImages = intval($this->getFees()->getFeeAmount(Service\Fees::NB_FREE_IMAGES));
  405. if ($imagesFeeAmount > 0) {
  406. if ($nbFreeImages < $settings['images_max']) {
  407. $imagesDescription .= '<br>';
  408. if ($nbFreeImages > 0) {
  409. $imagesDescription .= sprintf($translate->_('Upload %s images for free.'), $nbFreeImages)
  410. . ' ' . sprintf($translate->_('Each additional image costs %s.'), $this->getView()->amount($imagesFeeAmount));
  411. }
  412. else {
  413. $imagesDescription .= sprintf($translate->_('Each image costs %s.'), $this->getView()->amount($imagesFeeAmount));
  414. }
  415. }
  416. }
  417. // media upload field related description
  418. $videosDescription = sprintf($translate->_('You can upload up to %s videos.'), $settings['videos_max']);
  419. $videosFeeAmount = $this->getFees()->getFeeAmount(Service\Fees::MEDIA);
  420. $nbFreeVideos = intval($this->getFees()->getFeeAmount(Service\Fees::NB_FREE_MEDIA));
  421. if ($videosFeeAmount > 0) {
  422. if ($nbFreeVideos < $settings['videos_max']) {
  423. $videosDescription .= '<br>';
  424. if ($nbFreeVideos > 0) {
  425. $videosDescription .= sprintf($translate->_('Upload %s media for free.'), $nbFreeVideos)
  426. . ' ' . sprintf($translate->_('Each additional media upload costs %s.'), $this->getView()->amount($videosFeeAmount));
  427. }
  428. else {
  429. $videosDescription .= sprintf($translate->_('Each media file upload costs %s.'), $this->getView()->amount($videosFeeAmount));
  430. }
  431. }
  432. }
  433. // digital downloads field related description
  434. $downloadsDescription = $translate->_('If this listing contains digital downloads, please upload the files using this field.') . '<br>' .
  435. sprintf($translate->_('You can upload up to %s digital downloads.'),
  436. $settings['digital_downloads_max']);
  437. $downloadsFeeAmount = $this->getFees()->getFeeAmount(Service\Fees::DIGITAL_DOWNLOADS);
  438. $nbFreeDownloads = intval($this->getFees()->getFeeAmount(Service\Fees::NB_FREE_DOWNLOADS));
  439. if ($downloadsFeeAmount > 0) {
  440. $downloadsDescription .= '<br>';
  441. if ($nbFreeDownloads < $settings['digital_downloads_max']) {
  442. if ($nbFreeDownloads > 0) {
  443. $downloadsDescription .= sprintf($translate->_('First %s uploaded files are free.'), $nbFreeDownloads)
  444. . ' ' . sprintf($translate->_('Each additional upload costs %s.'), $this->getView()->amount($downloadsFeeAmount));
  445. }
  446. else {
  447. $downloadsDescription .= sprintf($translate->_('Each file upload costs %s.'), $this->getView()->amount($downloadsFeeAmount));
  448. }
  449. }
  450. }
  451. $bulkArraySeparator = Service\Listings\BulkLister::ARRAY_SEPARATOR;
  452. $locationRecordExists = new Validate\Db\RecordExists(array(
  453. 'table' => new Table\Locations(),
  454. 'field' => 'id',
  455. ));
  456. $locationRecordExists->setMessage($translate->_("The country id '%value%' is invalid."));
  457. /**
  458. * @version 7.5: moved above the array initialization due to the product attributes module
  459. */
  460. $isProductAttributes = false;
  461. foreach ($customFields as $key => $customField) {
  462. $customFields[$key]['form_id'] = array($customField['type'], 'product_edit');
  463. $customFields[$key]['id'] = 'custom_field_' . $customField['id'];
  464. $customFields[$key]['subform'] = 'details';
  465. if (!empty($customField['multiOptions'])) {
  466. $multiOptions = \Ppb\Utility::unserialize($customField['multiOptions']);
  467. $customFields[$key]['bulk']['multiOptions'] = (!empty($multiOptions['key'])) ?
  468. array_flip(array_filter($multiOptions['key'])) : array();
  469. }
  470. if ($customField['product_attribute']) {
  471. $isProductAttributes = true;
  472. $customFields[$key]['required'] = false;
  473. $customFields[$key]['attributes'] = array('class' => 'product-attribute');
  474. }
  475. }
  476. $array = array(
  477. array(
  478. 'form_id' => array('global', 'prefilled', 'fees_calculator'),
  479. 'id' => 'user_id',
  480. 'element' => 'hidden',
  481. 'bodyCode' => "
  482. <script type=\"text/javascript\">
  483. function checkListingFormFields()
  484. {
  485. var listIn = $('[name=\"list_in\"]');
  486. var listingType = $('[name=\"listing_type\"]');
  487. var startTimeTypeChecked = $('input:radio[name=\"start_time_type\"]:checked');
  488. if (listIn.val() !== 'site') {
  489. " . (($settings['enable_auctions_in_stores']) ? '' : "listingType.val('product').closest('.form-group').hide();") . "
  490. $('.btn-category').attr('data-store-id', {$this->_user['id']});
  491. }
  492. else {
  493. listingType.closest('.form-group').show();
  494. $('.btn-category').removeAttr('data-store-id');
  495. }
  496. if (listIn.val() === 'store') {
  497. $('[name=\"hpfeat\"]').prop('checked', false).closest('.form-group').hide();
  498. $('[name=\"catfeat\"]').prop('checked', false).closest('.form-group').hide();
  499. $('[name=\"highlighted\"]').prop('checked', false).closest('.form-group').hide();
  500. }
  501. else {
  502. $('[name=\"hpfeat\"]').closest('.form-group').show();
  503. $('[name=\"catfeat\"]').closest('.form-group').show();
  504. $('[name=\"highlighted\"]').closest('.form-group').show();
  505. }
  506. if (listingType.val() === 'auction') {
  507. $('[name=\"quantity\"]').val('1').closest('.form-group').hide();
  508. $('[name^=\"stock_levels\"]').closest('.form-group').hide();
  509. $('[name=\"start_price\"]').closest('.form-group').show();
  510. $('[name=\"enable_reserve_price\"]').closest('.form-group').show();
  511. $('[name=\"enable_buyout_price\"]').closest('.form-group').show();
  512. $('[name=\"bid_increment_type\"]').closest('.form-group').show();
  513. $('[name=\"private_auction\"]').closest('.form-group').show();
  514. $('[name=\"disable_sniping\"]').closest('.form-group').show();
  515. }
  516. else if (listingType.val() === 'product') {
  517. var qty = $('input:text[name=\"quantity\"]');
  518. if (qty.length > 0) {
  519. $('.product-attribute').on('click', function() {
  520. $('body').addClass('loading');
  521. displayQuantityStockLevels(qty);
  522. });
  523. displayQuantityStockLevels(qty);
  524. }
  525. $('[name=\"start_price\"]').val('').closest('.form-group').hide();
  526. $('[name=\"enable_reserve_price\"]').prop('checked', false).closest('.form-group').hide();
  527. $('[name=\"reserve_price\"]').val('').closest('.form-group').hide();
  528. $('[name=\"enable_buyout_price\"]').prop('checked', false).closest('.form-group').hide();
  529. $('[name=\"buyout_price\"]').closest('.form-group').show();
  530. $('[name=\"bid_increment_type\"]').closest('.form-group').hide();
  531. $('[name=\"private_auction\"]').prop('checked', false).closest('.form-group').hide();
  532. $('[name=\"disable_sniping\"]').prop('checked', false).closest('.form-group').hide();
  533. }
  534. if ($('input:checkbox[name=\"enable_reserve_price\"]').is(':checked')) {
  535. $('input:text[name=\"reserve_price\"]').closest('.form-group').show();
  536. }
  537. else {
  538. $('input:text[name=\"reserve_price\"]').val('').closest('.form-group').hide();
  539. }
  540. if ($('input:checkbox[name=\"enable_buyout_price\"]').is(':checked')) {
  541. $('input:text[name=\"buyout_price\"]').closest('.form-group').show();
  542. }
  543. else if (listingType.val() === 'auction') {
  544. $('input:text[name=\"buyout_price\"]').val('').closest('.form-group').hide();
  545. }
  546. if ($('input:checkbox[name=\"enable_make_offer\"]').is(':checked')) {
  547. $('input:text[name=\"make_offer_min\"]').closest('.form-group').show();
  548. $('input:text[name=\"make_offer_max\"]').closest('.form-group').show();
  549. }
  550. else {
  551. $('input:text[name=\"make_offer_min\"]').val('').closest('.form-group').hide();
  552. $('input:text[name=\"make_offer_max\"]').val('').closest('.form-group').hide();
  553. }
  554. if ($('input:radio[name=\"bid_increment_type\"]:checked').val() === '1') {
  555. $('input:text[name=\"bid_increment\"]').closest('.form-group').show();
  556. }
  557. else {
  558. $('input:text[name=\"bid_increment\"]').val('').closest('.form-group').hide();
  559. }
  560. if (startTimeTypeChecked.val() === '1') {
  561. $('input:text[name=\"start_time\"]').closest('.form-group').show();
  562. }
  563. else if (startTimeTypeChecked.val() === '0') {
  564. $('input:text[name=\"start_time\"]').val('').closest('.form-group').hide();
  565. }
  566. if ($('input:radio[name=\"end_time_type\"]:checked').val() === '1') {
  567. $('select[name=\"duration\"]').closest('.form-group').hide();
  568. $('input:text[name=\"end_time\"]').closest('.form-group').show();
  569. }
  570. else {
  571. $('input:text[name=\"end_time\"]').val('').closest('.form-group').hide();
  572. $('select[name=\"duration\"]').closest('.form-group').show();
  573. }
  574. if ($('input:checkbox[name=\"enable_auto_relist\"]').is(':checked')) {
  575. $('input:text[name=\"nb_relists\"]').closest('.form-group').show();
  576. $('input:checkbox[name=\"auto_relist_sold\"]').closest('.form-group').show();
  577. }
  578. else {
  579. $('input:text[name=\"nb_relists\"]').val('').closest('.form-group').hide();
  580. $('input:checkbox[name=\"auto_relist_sold\"]').prop('checked', false).closest('.form-group').hide();
  581. }
  582. if ($('input:checkbox[name=\"accept_returns\"]').is(':checked')) {
  583. $('textarea[name=\"returns_policy\"]').closest('.form-group').show();
  584. }
  585. else {
  586. $('textarea[name=\"returns_policy\"]').val('').closest('.form-group').hide();
  587. }
  588. if ($('[name=\"pickup_options\"]').val() === '" . ShippingModel::MUST_PICKUP . "') {
  589. $('.field-shipping').closest('.form-group').hide();
  590. }
  591. else {
  592. $('.field-shipping').closest('.form-group').show();
  593. }
  594. $('.listing-currency').html($('[name=\"currency\"]').val());
  595. $('.direct-payment').on('click', function() {
  596. var checkbox = $(this);
  597. if (checkbox.is(':checked')) {
  598. $.ajax({
  599. type: 'POST',
  600. url: '" . $this->getView()->url(array('module' => 'app', 'controller' => 'async', 'action' => 'check-direct-payment-method')) . "',
  601. data: {
  602. userId: '" . $this->_user['id'] . "',
  603. gatewayId: checkbox.val()
  604. },
  605. dataType: 'json',
  606. success: function(data) {
  607. if (!data.active) {
  608. bootbox.alert('" . $translate->_('Warning! This direct payment gateway is currently disabled. To enable it, you will need to set the necessary credentials.') . "');
  609. checkbox.prop('checked', false);
  610. }
  611. }
  612. });
  613. }
  614. });
  615. }
  616. function displayQuantityStockLevels(qty)
  617. {
  618. var stk = $('.stock-levels');
  619. $.ajax({
  620. type: 'POST',
  621. url: '" . $this->getView()->url(array('module' => 'app', 'controller' => 'async', 'action' => 'update-stock-levels-element')) . "',
  622. data: qty.closest('form').serialize(),
  623. dataType: 'json',
  624. success: function(data) {
  625. stk.html(data.output);
  626. if (!data.empty) {
  627. stk.closest('.form-group').show();
  628. qty.closest('.form-group').hide();
  629. }
  630. else {
  631. stk.closest('.form-group').hide();
  632. qty.closest('.form-group').show();
  633. }
  634. $('body').removeClass('loading');
  635. }
  636. });
  637. }
  638. $(document).ready(function() {
  639. checkListingFormFields();
  640. });
  641. $(document).on('change', '.field-changeable', function() {
  642. checkListingFormFields();
  643. });
  644. $(document).on('change', '.form-refresh', function() {
  645. $('body').addClass('loading');
  646. $(this).closest('form').submit();
  647. });
  648. </script>"
  649. ),
  650. array(
  651. 'form_id' => 'global',
  652. 'id' => 'option',
  653. 'element' => 'hidden',
  654. ),
  655. array(
  656. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  657. 'subform' => 'details',
  658. 'id' => 'list_in',
  659. 'element' => (count($listIn) > 1) ? 'select' : 'hidden',
  660. 'label' => $this->_('List In'),
  661. 'multiOptions' => $listIn,
  662. 'required' => true,
  663. 'hideDefault' => true,
  664. 'value' => $this->getFirstElement($listIn),
  665. 'description' => $this->_('Choose where to list your item.'),
  666. 'attributes' => array(
  667. 'class' => 'form-control input-small field-changeable form-refresh',
  668. ),
  669. ),
  670. array(
  671. 'form_id' => 'product_edit',
  672. 'id' => 'list_in',
  673. 'element' => 'hidden',
  674. ),
  675. array(
  676. 'form_id' => array('product_edit'),
  677. 'id' => 'listing_type',
  678. 'element' => 'hidden',
  679. ),
  680. array(
  681. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  682. 'subform' => 'details',
  683. 'id' => 'listing_type',
  684. 'element' => (count($listingTypes) > 1) ? 'select' : 'hidden',
  685. 'label' => $this->_('Listing Type'),
  686. 'multiOptions' => $listingTypes,
  687. 'required' => true,
  688. 'hideDefault' => true,
  689. 'value' => $this->getFirstElement($listingTypes),
  690. 'description' => $this->_('Choose the listing type you wish to create.'),
  691. 'attributes' => array(
  692. 'class' => 'form-control input-small field-changeable form-refresh',
  693. ),
  694. ),
  695. array(
  696. 'subtitle' => $this->_('Select Category'),
  697. 'subform' => 'details',
  698. 'form_id' => array('global', 'fees_calculator', 'bulk'),
  699. 'id' => 'category_id',
  700. 'element' => '\\Ppb\\Form\\Element\\Category',
  701. 'label' => $this->_('Main Category'),
  702. 'description' => $this->_('Select a main category where the item will be listed.'),
  703. 'required' => true,
  704. 'validators' => array(
  705. '\\Ppb\\Validate\\Db\\Category',
  706. ),
  707. 'bulk' => array(
  708. 'notes' => $translate->_('Category IDs allowed are available in the "Categories" tab.'),
  709. 'type' => $translate->_('integer'),
  710. 'sample' => 7425,
  711. ),
  712. ),
  713. array(
  714. 'form_id' => array('global', 'bulk'),
  715. 'subform' => 'details',
  716. 'id' => 'addl_category_id',
  717. 'element' => ($settings['addl_category_listing']) ? '\\Ppb\\Form\\Element\\Category' : false,
  718. 'label' => $this->_('Additional Category'),
  719. 'suffix' => $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::ADDL_CATEGORY),
  720. null,
  721. '(+%s)'),
  722. 'description' => $this->_('Select an additional category where to list your item (optional).'),
  723. 'validators' => $this->getData('addl_category_id') ? array(
  724. '\\Ppb\\Validate\\Db\\Category',
  725. array('Different', array($translate->_('Main Category'), $this->getData('category_id')))
  726. ) : null,
  727. 'bulk' => array(
  728. 'type' => $translate->_('integer'),
  729. ),
  730. ),
  731. array(
  732. 'form_id' => 'fees_calculator',
  733. 'id' => 'addl_category_id',
  734. 'element' => ($settings['addl_category_listing']) ? 'checkbox' : false,
  735. 'label' => $this->_('Additional Category'),
  736. 'description' => $this->_('Check the above checkbox if you wish to list the item in an additional category.'),
  737. 'multiOptions' => array(
  738. 1 => $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::ADDL_CATEGORY),
  739. null,
  740. '(+%s)'),
  741. ),
  742. ),
  743. array(
  744. 'subtitle' => $this->_('Listing Details'),
  745. 'form_id' => array('global', 'prefilled', 'bulk'),
  746. 'subform' => 'details',
  747. 'id' => 'name',
  748. 'element' => 'text',
  749. 'label' => $this->_('Item Title'),
  750. 'description' => $this->_('Enter a title for your listing.'),
  751. 'required' => ($this->_formId !== 'prefilled') ? true : false,
  752. 'validators' => array(
  753. 'NoHtml',
  754. array('StringLength', array(null, min(255, $settings['character_length']))),
  755. ),
  756. 'filters' => array(
  757. '\\Ppb\\Filter\\BadWords',
  758. ),
  759. 'attributes' => array(
  760. 'class' => 'form-control input-xlarge',
  761. ),
  762. 'bulk' => array(
  763. 'sample' => 'My Listing',
  764. ),
  765. ),
  766. array(
  767. 'form_id' => array('item', 'bulk'),
  768. 'subform' => 'details',
  769. 'id' => 'subtitle',
  770. 'element' => ($settings['enable_subtitle']) ? 'text' : false,
  771. 'label' => $this->_('Sub Title'),
  772. 'description' => $this->_('Enter a sub title for your listing (optional).'),
  773. 'suffix' => $this->getView()->amount(
  774. $this->getFees()->getFeeAmount(Service\Fees::SUBTITLE), null, '(+%s)'),
  775. 'validators' => array(
  776. 'NoHtml',
  777. array('StringLength', array(null, min(255, $settings['character_length']))),
  778. ),
  779. 'filters' => array(
  780. '\\Ppb\\Filter\\BadWords',
  781. ),
  782. 'attributes' => array(
  783. 'class' => 'form-control input-xlarge',
  784. ),
  785. 'bulk' => array(
  786. 'sample' => 'Listing Subtitle',
  787. ),
  788. ),
  789. array(
  790. 'form_id' => array('global', 'prefilled', 'bulk'),
  791. 'subform' => 'details',
  792. 'id' => 'description',
  793. 'element' => '\\Ppb\\Form\\Element\\Wysiwyg',
  794. 'label' => $this->_('Description'),
  795. 'description' => $this->_('Enter a description for your item.'),
  796. 'required' => ($this->_formId !== 'prefilled') ? true : false,
  797. 'filters' => array(
  798. '\\Ppb\\Filter\\BadWords',
  799. ),
  800. 'attributes' => array(
  801. 'class' => 'form-control',
  802. 'rows' => '12',
  803. ),
  804. 'bulk' => array(
  805. 'sample' => 'Listing Description',
  806. ),
  807. ),
  808. array(
  809. 'form_id' => array('global', 'bulk'),
  810. 'subform' => 'details',
  811. 'id' => 'image',
  812. 'element' => ($settings['images_max'] > 0) ? '\\Ppb\\Form\\Element\\MultiUpload\\Sortable' : false,
  813. 'label' => $this->_('Images'),
  814. 'description' => $imagesDescription,
  815. 'required' => ($settings['mandatory_images']) ? true : false,
  816. 'multiple' => true,
  817. 'customData' => array(
  818. 'buttonText' => $translate->_('Select Images'),
  819. 'acceptFileTypes' => '/(\.|\/)(gif|jpe?g|png)$/i',
  820. 'remoteUploads' => ($settings['remote_uploads']) ? true : false,
  821. 'formData' => array(
  822. 'watermark' => $settings['images_watermark'],
  823. 'fileSizeLimit' => ($settings['images_size'] * 1024),
  824. 'uploadLimit' => $settings['images_max'],
  825. ),
  826. ),
  827. 'bulk' => array(
  828. 'sample' => $settings['site_path'] . '/images/sample1.jpg'
  829. . $bulkArraySeparator
  830. . $settings['site_path'] . '/images/sample2.jpg',
  831. 'notes' => sprintf($translate->_('Absolute path to images is highly recommended. '
  832. . 'For local images, the "%s" folder will be used. Multiple images are to be separated by "%s"'),
  833. \Ppb\Utility::getFolder('uploads'), $bulkArraySeparator),
  834. )
  835. ),
  836. array(
  837. 'form_id' => 'fees_calculator',
  838. 'id' => 'image',
  839. 'element' => ($settings['images_max'] > 0) ? 'text' : false,
  840. 'label' => $this->_('Images'),
  841. 'description' => $translate->_('Enter the number of images you wish to upload with your listing.') . '<br>' . $imagesDescription,
  842. 'attributes' => array(
  843. 'class' => 'form-control input-mini',
  844. ),
  845. ),
  846. array(
  847. 'form_id' => 'global',
  848. 'subform' => 'details',
  849. 'id' => 'video',
  850. 'element' => ($settings['videos_max'] > 0) ? '\\Ppb\\Form\\Element\\MultiUpload' : false,
  851. 'label' => $this->_('Media'),
  852. 'description' => $videosDescription,
  853. 'required' => false,
  854. 'multiple' => true,
  855. 'customData' => array(
  856. 'buttonText' => $translate->_('Select Media'),
  857. 'acceptFileTypes' => '/(\.|\/)(mov|mp4|flv)$/i',
  858. 'embeddedCode' => ($settings['embedded_code']) ? true : false,
  859. 'formData' => array(
  860. 'fileSizeLimit' => ($settings['videos_size'] * 1024),
  861. 'uploadLimit' => $settings['videos_max'],
  862. ),
  863. ),
  864. ),
  865. array(
  866. 'form_id' => 'fees_calculator',
  867. 'id' => 'video',
  868. 'element' => ($settings['videos_max'] > 0) ? 'text' : false,
  869. 'label' => $this->_('Media'),
  870. 'description' => $translate->_('Enter the number of videos you wish to add to your listing.') . '<br>' . $videosDescription,
  871. 'attributes' => array(
  872. 'class' => 'form-control input-mini',
  873. ),
  874. ),
  875. array(
  876. 'form_id' => 'global',
  877. 'subform' => 'details',
  878. 'id' => 'download',
  879. 'element' => ($settings['digital_downloads_max'] > 0) ? '\\Ppb\\Form\\Element\\MultiUpload' : false,
  880. 'label' => $this->_('Digital Downloads'),
  881. 'description' => $downloadsDescription,
  882. 'required' => false,
  883. 'multiple' => true,
  884. 'customData' => array(
  885. 'buttonText' => $translate->_('Select Files'),
  886. 'acceptFileTypes' => '/(\.|\/)(doc?x|xls?x|txt|zip|tar|gz|exe|pdf)$/i',
  887. 'formData' => array(
  888. 'uploadType' => 'download',
  889. 'fileSizeLimit' => ($settings['digital_downloads_size'] * 1024),
  890. 'uploadLimit' => $settings['digital_downloads_max'],
  891. ),
  892. ),
  893. ),
  894. array(
  895. 'form_id' => 'fees_calculator',
  896. 'id' => 'download',
  897. 'element' => ($settings['digital_downloads_max'] > 0) ? 'text' : false,
  898. 'label' => $this->_('Digital Downloads'),
  899. 'description' => $translate->_('Enter the number of digital downloads you wish to upload with your listing.') . '<br>' . $downloadsDescription,
  900. 'attributes' => array(
  901. 'class' => 'form-control input-mini',
  902. ),
  903. ),
  904. array(
  905. 'subtitle' => $this->_('Listing Settings'),
  906. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  907. 'subform' => 'settings',
  908. 'id' => 'currency',
  909. 'element' => (count($currencies) > 1) ? 'select' : 'hidden',
  910. 'label' => $this->_('Currency'),
  911. 'multiOptions' => $currencies,
  912. 'value' => $this->getData('currency'),
  913. 'description' => $this->_('Select your item\'s currency.'),
  914. 'required' => true,
  915. 'attributes' => array(
  916. 'class' => 'form-control input-small field-changeable',
  917. ),
  918. ),
  919. array(
  920. 'form_id' => array('item', 'product_edit', 'bulk'),
  921. 'subform' => 'settings',
  922. 'id' => 'quantity',
  923. 'element' => '\\Ppb\\Form\\Element\\Quantity',
  924. 'label' => $this->_('Quantity'),
  925. 'description' => $this->_('Enter the number of items you are offering for sale.'),
  926. 'required' => true,
  927. 'value' => 1,
  928. 'attributes' => array(
  929. 'class' => 'form-control input-mini',
  930. ),
  931. 'source' => array(
  932. '1' => '1',
  933. '2' => '2',
  934. '3' => '3',
  935. '4' => '4',
  936. '5' => '5',
  937. '10' => '10',
  938. '-1' => $translate->_('Unlimited'),
  939. ),
  940. 'validators' => array(
  941. 'Digits',
  942. ),
  943. 'bulk' => array(
  944. 'notes' => $translate->_('Only editable for products. For auctions it will always be reset to 1.'),
  945. 'type' => $translate->_('integer'),
  946. ),
  947. ),
  948. array(
  949. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  950. 'subform' => 'settings',
  951. 'id' => 'start_price',
  952. 'element' => ($settings['enable_auctions']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : false,
  953. 'label' => $this->_('Start Price'),
  954. 'description' => $this->_('Enter the start price for your item.'),
  955. 'required' => ($this->getData('listing_type') == 'auction') ? true : false,
  956. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  957. 'attributes' => array(
  958. 'class' => 'form-control input-mini',
  959. ),
  960. 'filters' => array(
  961. '\\Ppb\\Filter\\LocalizedNumeric',
  962. ),
  963. 'validators' => array(
  964. 'Numeric',
  965. array('GreaterThan',
  966. ($this->getData('listing_type') == 'auction') ?
  967. array(0, false, true) : array(0, true)),
  968. ),
  969. 'bulk' => array(
  970. 'notes' => $translate->_('Field required for auctions.'),
  971. 'type' => $translate->_('decimal'),
  972. 'sample' => 5,
  973. ),
  974. ),
  975. array(
  976. 'form_id' => 'item',
  977. 'subform' => 'settings',
  978. 'id' => 'enable_reserve_price',
  979. 'element' => ($settings['enable_auctions']) ? 'checkbox' : false,
  980. 'label' => $this->_('Enable Reserve'),
  981. 'multiOptions' => array(
  982. 1 => $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::RESERVE), null, '(+%s)'),
  983. ),
  984. 'value' => ($this->getData('reserve_price') > 0) ? 1 : null,
  985. 'description' => $this->_('By enabling reserve, the auction wont be awarded unless the high bid is above the reserve price. The amount is hidden.'),
  986. 'attributes' => array(
  987. 'class' => 'form-control field-changeable',
  988. ),
  989. ),
  990. array(
  991. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  992. 'subform' => 'settings',
  993. 'id' => 'reserve_price',
  994. 'element' => ($settings['enable_auctions']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : false,
  995. 'label' => $this->_('Reserve Price'),
  996. 'description' => $this->_('Enter the reserve price.'),
  997. 'required' => ($this->getData('enable_reserve_price')) ? true : false,
  998. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  999. 'attributes' => array(
  1000. 'class' => 'form-control input-mini',
  1001. ),
  1002. 'filters' => array(
  1003. '\\Ppb\\Filter\\LocalizedNumeric',
  1004. ),
  1005. 'validators' => array(
  1006. 'Numeric',
  1007. array('GreaterThan',
  1008. array((($this->getData('enable_reserve_price') || $this->_formId == 'bulk') ? $this->getData('start_price') : -0.01), false)),
  1009. ),
  1010. 'bulk' => array(
  1011. 'notes' => $translate->_('Only available for auctions. If set, it needs to be greater than the start price.'),
  1012. 'type' => $translate->_('decimal'),
  1013. ),
  1014. ),
  1015. array(
  1016. 'form_id' => array('item', 'fees_calculator'),
  1017. 'subform' => 'settings',
  1018. 'id' => 'enable_buyout_price',
  1019. 'element' => ($settings['enable_buyout']) ? 'checkbox' : false,
  1020. 'label' => $this->_('Enable Buy Out'),
  1021. 'multiOptions' => array(
  1022. 1 => $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::BUYOUT), null, '(+%s)'),
  1023. ),
  1024. 'value' => ($this->getData('buyout_price') > 0) ? 1 : null,
  1025. 'description' => $this->_('Enable Buy Out if you want to allow your users to purchase your item instantly.'),
  1026. 'attributes' => array(
  1027. 'class' => 'form-control field-changeable',
  1028. ),
  1029. ),
  1030. array(
  1031. 'form_id' => array('item', 'fees_calculator', 'product_edit', 'bulk'),
  1032. 'subform' => 'settings',
  1033. 'id' => 'buyout_price',
  1034. 'element' => ($settings['enable_buyout'] || $settings['enable_products']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : false,
  1035. 'label' => $this->_('Buy Out Price'),
  1036. 'description' => $this->_('Enter the buy out price for your item.'),
  1037. 'required' => (
  1038. $this->getData('enable_buyout_price') ||
  1039. $this->getData('listing_type') == 'product' ||
  1040. $this->_formId == 'bulk'
  1041. ) ? true : false,
  1042. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  1043. 'attributes' => array(
  1044. 'class' => 'form-control input-mini',
  1045. ),
  1046. 'filters' => array(
  1047. '\\Ppb\\Filter\\LocalizedNumeric',
  1048. ),
  1049. 'validators' => array(
  1050. 'Numeric',
  1051. array(
  1052. 'GreaterThan',
  1053. array(
  1054. ($this->getData('listing_type') == 'product') ? 0 : max(array($this->getData('start_price'), $this->getData('reserve_price'))),
  1055. false,
  1056. ($this->getData('listing_type') == 'product') ? true : false
  1057. ),
  1058. ),
  1059. ),
  1060. 'bulk' => array(
  1061. 'notes' => $translate->_('Required for products. For auctions, if set, it needs to be greater than the start price and reserve price.'),
  1062. 'type' => $translate->_('decimal'),
  1063. 'sample' => 15,
  1064. ),
  1065. ),
  1066. array(
  1067. 'form_id' => array('item', 'product_edit', 'bulk'),
  1068. 'subform' => 'settings',
  1069. 'id' => 'stock_levels',
  1070. 'element' => ($isProductAttributes) ? '\\Ppb\\Form\\Element\\StockLevels' : 'hidden',
  1071. 'label' => $this->_('Stock Levels'),
  1072. 'description' => $this->_('Enter the stock levels and variations from the base price corresponding to your selected product attributes combinations.'),
  1073. 'attributes' => array(
  1074. 'class' => 'form-control input-mini',
  1075. ),
  1076. 'validators' => ($this->getData('listing_type') == 'product' && $isProductAttributes) ? array('\\Ppb\\Validate\\StockLevels') : array(),
  1077. 'customFields' => $customFields,
  1078. 'formData' => $this->getData(),
  1079. 'bulk' => array(), // TODO
  1080. ),
  1081. array(
  1082. 'form_id' => array('item', 'product_edit', 'fees_calculator', 'bulk'),
  1083. 'subform' => 'settings',
  1084. 'id' => 'enable_make_offer',
  1085. 'element' => ($settings['enable_make_offer']) ? 'checkbox' : false,
  1086. 'label' => $this->_('Accept Offers'),
  1087. 'multiOptions' => array(
  1088. 1 => $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::MAKE_OFFER), null,
  1089. '(+%s)'),
  1090. ),
  1091. 'description' => $this->_('Check the above checkbox if you wish to accept offers for your item.'),
  1092. 'attributes' => array(
  1093. 'class' => 'field-changeable',
  1094. ),
  1095. 'bulk' => array(
  1096. 'multiOptions' => array(0, 1),
  1097. 'type' => $translate->_('integer'),
  1098. ),
  1099. ),
  1100. array(
  1101. 'form_id' => array('item', 'product_edit', 'bulk'),
  1102. 'subform' => 'settings',
  1103. 'id' => 'make_offer_min',
  1104. 'element' => ($settings['enable_make_offer']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : false,
  1105. 'label' => $this->_('Minimum Offer Range'),
  1106. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  1107. 'attributes' => array(
  1108. 'class' => 'form-control input-mini',
  1109. ),
  1110. 'filters' => array(
  1111. '\\Ppb\\Filter\\LocalizedNumeric',
  1112. ),
  1113. 'validators' => array(
  1114. 'Numeric',
  1115. array('GreaterThan', array(0, true)),
  1116. ),
  1117. 'bulk' => array(
  1118. 'type' => $translate->_('decimal'),
  1119. ),
  1120. ),
  1121. array(
  1122. 'form_id' => array('item', 'product_edit', 'bulk'),
  1123. 'subform' => 'settings',
  1124. 'id' => 'make_offer_max',
  1125. 'element' => ($settings['enable_make_offer']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : false,
  1126. 'label' => $this->_('Maximum Offer Range'),
  1127. 'description' => $this->_('Enter a range between which users can place offers (Optional).'),
  1128. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  1129. 'attributes' => array(
  1130. 'class' => 'form-control input-mini',
  1131. ),
  1132. 'filters' => array(
  1133. '\\Ppb\\Filter\\LocalizedNumeric',
  1134. ),
  1135. 'validators' => array(
  1136. 'Numeric',
  1137. array('GreaterThan', array($this->getData('make_offer_min'), true)),
  1138. ),
  1139. 'bulk' => array(
  1140. 'type' => $translate->_('decimal'),
  1141. ),
  1142. ),
  1143. array(
  1144. 'form_id' => 'item',
  1145. 'subform' => 'settings',
  1146. 'id' => 'bid_increment_type',
  1147. 'element' => ($settings['enable_auctions']) ? 'radio' : false,
  1148. 'label' => $this->_('Bid Increment'),
  1149. 'multiOptions' => array(
  1150. 0 => array(
  1151. $translate->_('Use the built-in proportional increments table'),
  1152. ),
  1153. 1 => array(
  1154. $translate->_('Enter your custom increment amount'),
  1155. ),
  1156. ),
  1157. 'value' => ($this->getData('bid_increment') > 0) ? 1 : 0,
  1158. 'description' => $this->_('Select how the bid increments will be calculated.'),
  1159. 'attributes' => array(
  1160. 'class' => 'field-changeable',
  1161. ),
  1162. ),
  1163. array(
  1164. 'form_id' => array('item', 'bulk'),
  1165. 'subform' => 'settings',
  1166. 'id' => 'bid_increment',
  1167. 'element' => ($settings['enable_auctions']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : false,
  1168. 'label' => $this->_('Bid Increment Amount'),
  1169. 'description' => $this->_('Enter your custom bid increment amount.'),
  1170. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  1171. 'attributes' => array(
  1172. 'class' => 'form-control input-mini',
  1173. ),
  1174. 'filters' => array(
  1175. '\\Ppb\\Filter\\LocalizedNumeric',
  1176. ),
  1177. 'validators' => array(
  1178. 'Numeric',
  1179. array('GreaterThan', array(0, false)),
  1180. ),
  1181. 'bulk' => array(
  1182. 'notes' => $translate->_('Only set if you wish to use a custom increment amount for your auction. '
  1183. . 'By default, the bid increments table will be used.'),
  1184. 'type' => $translate->_('decimal'),
  1185. ),
  1186. ),
  1187. array(
  1188. 'form_id' => array('global', 'bulk'),
  1189. 'subform' => 'settings',
  1190. 'id' => 'start_time_type',
  1191. 'element' => ($settings['enable_custom_start_time']) ? 'radio' : 'hidden',
  1192. 'label' => $this->_('Start Time'),
  1193. 'description' => $this->_('Enter the start time for your listing.'),
  1194. 'value' => 0,
  1195. 'multiOptions' => array(
  1196. 0 => $translate->_('Now'),
  1197. 1 => $translate->_('Custom'),
  1198. ),
  1199. 'attributes' => array(
  1200. 'class' => 'field-changeable',
  1201. ),
  1202. 'bulk' => array(
  1203. 'notes' => $translate->_('Allowed types: 0 => Now, 1 => Custom'),
  1204. 'type' => $translate->_('integer'),
  1205. ),
  1206. ),
  1207. array(
  1208. 'form_id' => array('global', 'bulk'),
  1209. 'subform' => 'settings',
  1210. 'id' => 'start_time',
  1211. 'element' => ($settings['enable_custom_start_time']) ? '\\Ppb\\Form\\Element\\DateTime' : 'hidden',
  1212. 'label' => $this->_('Custom Start Time'),
  1213. 'description' => $this->_('Choose a custom start time for the listing.'),
  1214. 'required' => ($this->getData('start_time_type') == 1) ? true : false,
  1215. 'validators' => ($settings['enable_custom_start_time']) ? array(
  1216. array('GreaterThan', array(date('Y-m-d H:i:s', time()), false)),
  1217. ) : null,
  1218. 'attributes' => array(
  1219. 'class' => 'form-control input-medium',
  1220. ),
  1221. 'customData' => array(
  1222. 'formData' => array(
  1223. 'format' => '"YYYY-MM-DD HH:mm"',
  1224. 'minDate' => 'new Date()',
  1225. 'stepping' => '5',
  1226. 'showClear' => 'true',
  1227. ),
  1228. ),
  1229. 'bulk' => array(
  1230. 'type' => $translate->_('datetime'),
  1231. 'notes' => $translate->_('Accepted format: yyyy-mm-dd hh:mm:ss'),
  1232. ),
  1233. ),
  1234. array(
  1235. 'form_id' => array('global', 'bulk'),
  1236. 'subform' => 'settings',
  1237. 'id' => 'end_time_type',
  1238. 'element' => (($settings['enable_unlimited_duration'] &&
  1239. $settings['force_unlimited_duration'] &&
  1240. $this->getData('listing_type') == 'product') || !$settings['enable_custom_end_time']) ? false : 'radio',
  1241. 'label' => $this->_('End Time'),
  1242. 'description' => $translate->_('Enter the end time for your listing.') .
  1243. (($settings['enable_change_duration'] && $this->getData('listing_type') == 'auction') ?
  1244. '<br>' . sprintf(
  1245. $translate->_('Note: If the time left is greater than %s days when the first bid is placed, the duration will be reduced to %s days.'),
  1246. $settings['change_duration_days'],
  1247. $settings['change_duration_days']) : ''),
  1248. 'values' => 0,
  1249. 'multiOptions' => array(
  1250. 0 => $translate->_('Duration'),
  1251. 1 => $translate->_('Custom'),
  1252. ),
  1253. 'attributes' => array(
  1254. 'class' => 'field-changeable',
  1255. ),
  1256. 'bulk' => array(
  1257. 'notes' => $translate->_('Allowed types: 0 => Duration, 1 => Custom'),
  1258. 'type' => $translate->_('integer'),
  1259. ),
  1260. ),
  1261. array(
  1262. 'form_id' => array('global', 'prefilled', 'bulk'),
  1263. 'subform' => 'settings',
  1264. 'id' => 'duration',
  1265. 'element' => (count($durations) > 1) ? 'select' : 'hidden',
  1266. 'label' => $this->_('Duration'),
  1267. 'multiOptions' => $durations,
  1268. 'description' => $this->_('Select a duration for your listing.'),
  1269. 'attributes' => array(
  1270. 'class' => 'form-control input-medium',
  1271. ),
  1272. ),
  1273. array(
  1274. 'form_id' => array('global', 'bulk'),
  1275. 'subform' => 'settings',
  1276. 'id' => 'end_time',
  1277. 'element' => '\\Ppb\\Form\\Element\\DateTime',
  1278. 'label' => $this->_('Custom End Time'),
  1279. 'description' => $this->_('Choose a custom end time for the listing.'),
  1280. 'required' => ($this->getData('end_time_type') == 1) ? true : false,
  1281. 'validators' => array(
  1282. array('GreaterThan', array($this->getData('start_time'), false)),
  1283. ),
  1284. 'attributes' => array(
  1285. 'class' => 'form-control input-medium',
  1286. ),
  1287. 'customData' => array(
  1288. 'formData' => array(
  1289. 'format' => '"YYYY-MM-DD HH:mm"',
  1290. 'minDate' => 'new Date()',
  1291. 'stepping' => '5',
  1292. 'showClear' => 'true',
  1293. ),
  1294. ),
  1295. 'bulk' => array(
  1296. 'type' => $translate->_('datetime'),
  1297. 'notes' => $translate->_('Accepted format: yyyy-mm-dd hh:mm:ss'),
  1298. ),
  1299. ),
  1300. array(
  1301. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  1302. 'subform' => 'settings',
  1303. 'id' => 'apply_tax',
  1304. 'element' => ($this->getUser()->canApplyTax()) ? 'checkbox' : false,
  1305. 'label' => $this->_('Apply Tax'),
  1306. 'multiOptions' => array(
  1307. 1 => null,
  1308. ),
  1309. 'description' => $this->_('Check the above checkbox to apply tax for this listing.'),
  1310. 'attributes' => array(
  1311. 'class' => 'field-changeable',
  1312. ),
  1313. 'bulk' => array(
  1314. 'multiOptions' => array(0, 1),
  1315. 'type' => $translate->_('integer'),
  1316. ),
  1317. ),
  1318. array(
  1319. 'form_id' => array('item', 'prefilled', 'bulk'),
  1320. 'subform' => 'settings',
  1321. 'id' => 'private_auction',
  1322. 'element' => ($settings['enable_auctions']) ? 'checkbox' : false,
  1323. 'label' => $this->_('Private Auction'),
  1324. 'multiOptions' => array(
  1325. 1 => null,
  1326. ),
  1327. 'description' => $this->_('By enabling this option, bidders on this auction will be hidden to site users, and only you '
  1328. . '(the owner of the auction) will be able to see the usernames of the bidders. Bid amounts will still be visible.'),
  1329. 'bulk' => array(
  1330. 'multiOptions' => array(0, 1),
  1331. 'type' => $translate->_('integer'),
  1332. ),
  1333. ),
  1334. array(
  1335. 'form_id' => array('item', 'prefilled', 'bulk'),
  1336. 'subform' => 'settings',
  1337. 'id' => 'disable_sniping',
  1338. 'element' => ($settings['enable_auctions'] && $settings['enable_auctions_sniping']) ? 'checkbox' : false,
  1339. 'label' => $this->_('Disable Sniping Feature'),
  1340. 'multiOptions' => array(
  1341. 1 => null,
  1342. ),
  1343. 'description' => $this->_('Check the above checkbox if you want to disable the sniping feature for this auction.'),
  1344. 'bulk' => array(
  1345. 'multiOptions' => array(0, 1),
  1346. 'type' => $translate->_('integer'),
  1347. ),
  1348. ),
  1349. array(
  1350. 'subtitle' => $this->_('Feature Your Listing'),
  1351. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  1352. 'subform' => 'settings',
  1353. 'id' => 'hpfeat',
  1354. 'element' => 'checkbox',
  1355. 'label' => '',
  1356. 'multiOptions' => array(
  1357. 1 => $translate->_('Feature on home page') . ' ' . $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::HPFEAT),
  1358. null, '(+%s)'),
  1359. ),
  1360. 'bulk' => array(
  1361. 'multiOptions' => array(0, 1),
  1362. 'label' => $translate->_('Home Page Featuring'),
  1363. 'type' => $translate->_('integer'),
  1364. ),
  1365. ),
  1366. array(
  1367. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  1368. 'subform' => 'settings',
  1369. 'id' => 'catfeat',
  1370. 'element' => 'checkbox',
  1371. 'label' => '',
  1372. 'multiOptions' => array(
  1373. 1 => $translate->_('Feature on category page') . ' ' . $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::CATFEAT),
  1374. null, '(+%s)'),
  1375. ),
  1376. 'bulk' => array(
  1377. 'multiOptions' => array(0, 1),
  1378. 'label' => $translate->_('Category Page Featuring'),
  1379. 'type' => $translate->_('integer'),
  1380. ),
  1381. ),
  1382. // array(
  1383. // 'form_id' => array('item', 'fees_calculator'),
  1384. // 'subform' => 'settings',
  1385. // 'id' => 'bold',
  1386. // 'element' => 'checkbox',
  1387. // 'label' => '',
  1388. // 'multiOptions' => array(
  1389. // 1 => $translate->_('Bold listing') . ' ' . $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::BOLD),
  1390. // null,
  1391. // '(+%s)'),
  1392. // ),
  1393. // ),
  1394. array(
  1395. 'form_id' => array('item', 'fees_calculator', 'bulk'),
  1396. 'subform' => 'settings',
  1397. 'id' => 'highlighted',
  1398. 'element' => 'checkbox',
  1399. 'label' => '',
  1400. 'multiOptions' => array(
  1401. 1 => $translate->_('Highlight listing') . ' ' . $this->getView()->amount($this->getFees()->getFeeAmount(Service\Fees::HIGHLIGHTED),
  1402. null, '(+%s)'),
  1403. ),
  1404. 'bulk' => array(
  1405. 'multiOptions' => array(0, 1),
  1406. 'label' => $translate->_('Highlighted Listing'),
  1407. 'type' => $translate->_('integer'),
  1408. ),
  1409. ),
  1410. array(
  1411. 'form_id' => array('item', 'prefilled'),
  1412. 'subtitle' => $this->_('Auto Relist'),
  1413. 'subform' => 'settings',
  1414. 'id' => 'enable_auto_relist',
  1415. 'element' => ($settings['auto_relist']) ? 'checkbox' : false,
  1416. 'value' => ($this->getData('nb_relists') > 0) ? 1 : 0,
  1417. 'label' => $this->_('Enable Auto Relist'),
  1418. 'multiOptions' => array(
  1419. 1 => null,
  1420. ),
  1421. 'attributes' => array(
  1422. 'class' => 'field-changeable',
  1423. ),
  1424. 'description' => $this->_('Check the above checkbox for your listing to be relisted automatically.'),
  1425. ),
  1426. array(
  1427. 'form_id' => array('item', 'prefilled', 'bulk'),
  1428. 'subform' => 'settings',
  1429. 'id' => 'nb_relists',
  1430. 'element' => ($settings['auto_relist']) ? 'text' : false,
  1431. 'label' => $this->_('Number of Relists'),
  1432. 'description' => sprintf($translate->_('(Optional) Enter the number of times the item will be relisted automatically. <br>'
  1433. . 'The maximum number of auto relists allowed is %s.'), $settings['max_auto_relists']),
  1434. 'attributes' => array(
  1435. 'class' => 'form-control input-mini',
  1436. ),
  1437. 'validators' => array(
  1438. 'Digits',
  1439. array('LessThan', array($settings['max_auto_relists'], true)),
  1440. ),
  1441. 'bulk' => array(
  1442. 'type' => $translate->_('integer'),
  1443. ),
  1444. ),
  1445. array(
  1446. 'form_id' => array('item', 'prefilled', 'bulk'),
  1447. 'subform' => 'settings',
  1448. 'id' => 'auto_relist_sold',
  1449. 'element' => ($settings['auto_relist']) ? 'checkbox' : false,
  1450. 'label' => $this->_('Auto Relist if Sold'),
  1451. 'multiOptions' => array(
  1452. 1 => null,
  1453. ),
  1454. 'description' => $this->_('By enabling this option, your item will be relisted even if sold.'),
  1455. 'bulk' => array(
  1456. 'multiOptions' => array(0, 1),
  1457. 'type' => $translate->_('integer'),
  1458. ),
  1459. ),
  1460. array(
  1461. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  1462. 'subtitle' => $this->_('Location'),
  1463. 'subform' => 'settings',
  1464. 'id' => 'country',
  1465. 'element' => 'select',
  1466. 'label' => $this->_('Country'),
  1467. 'multiOptions' => $countries,
  1468. 'required' => true,
  1469. 'description' => $this->_('Enter the country where the item is located.'),
  1470. 'attributes' => array(
  1471. 'class' => 'form-control input-medium',
  1472. ),
  1473. 'bodyCode' => "
  1474. <script type=\"text/javascript\">
  1475. $(document).on('change', '[name=\"country\"]', function() {
  1476. $.post(
  1477. '" . $this->getView()->url(array('module' => 'app', 'controller' => 'async', 'action' => 'select-location')) . "',
  1478. {
  1479. id: $('[name=\"country\"]').val()
  1480. },
  1481. function (data) {
  1482. var state = $('[name=\"state\"]');
  1483. var div = state.closest('div');
  1484. state.remove();
  1485. div.prepend(data);
  1486. }
  1487. );
  1488. });
  1489. </script>",
  1490. 'validators' => array(
  1491. $locationRecordExists,
  1492. ),
  1493. 'bulk' => array(
  1494. 'type' => $translate->_('integer'),
  1495. 'notes' => $translate->_('Country IDs allowed are available in the "Locations" tab. '),
  1496. 'multiOptions' => array(),
  1497. 'sample' => 2083,
  1498. ),
  1499. ),
  1500. array(
  1501. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  1502. 'subform' => 'settings',
  1503. 'id' => 'state',
  1504. 'element' => (count($states) > 0) ? 'select' : 'text',
  1505. 'label' => $this->_('State/County'),
  1506. 'multiOptions' => $states,
  1507. 'required' => true,
  1508. 'description' => $this->_('Enter the state/county where the item is located.'),
  1509. 'attributes' => array(
  1510. 'class' => 'form-control input-medium',
  1511. ),
  1512. 'filters' => array(
  1513. '\\Ppb\\Filter\\BadWords',
  1514. ),
  1515. 'bulk' => array(
  1516. 'multiOptions' => array(),
  1517. 'sample' => 2104,
  1518. ),
  1519. ),
  1520. array(
  1521. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  1522. 'subform' => 'settings',
  1523. 'id' => 'address',
  1524. 'element' => 'text',
  1525. 'label' => $this->_('Address/Post Code'),
  1526. 'required' => true,
  1527. 'description' => $this->_('Enter the address/post code where the item is located.'),
  1528. 'attributes' => array(
  1529. 'class' => 'form-control input-medium',
  1530. ),
  1531. 'filters' => array(
  1532. '\\Ppb\\Filter\\BadWords',
  1533. ),
  1534. 'bulk' => array(
  1535. 'sample' => 'My Street',
  1536. ),
  1537. ),
  1538. array(
  1539. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  1540. 'subform' => 'shipping',
  1541. 'subtitle' => $this->_('Shipping'),
  1542. 'id' => ShippingModel::FLD_PICKUP_OPTIONS,
  1543. 'element' => ($settings['enable_shipping'] && $settings['enable_pickups']) ? 'select' : 'hidden',
  1544. 'value' => ($settings['enable_pickups']) ? $this->getData('pickups') : ShippingModel::NO_PICKUPS,
  1545. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_PICKUP_OPTIONS],
  1546. 'description' => $this->_('Select if you wish to offer pick-up options for your listing.'),
  1547. 'multiOptions' => ShippingModel::$pickupOptions,
  1548. 'attributes' => array(
  1549. 'class' => 'form-control input-medium field-changeable',
  1550. ),
  1551. ),
  1552. array(
  1553. 'form_id' => array('item', 'prefilled', 'product_edit', 'bulk'),
  1554. 'subform' => 'shipping',
  1555. 'id' => ShippingModel::FLD_POSTAGE,
  1556. 'element' => ($settings['enable_shipping'] && $this->getUser()->getShipping()->getPostageType() == ShippingModel::POSTAGE_TYPE_ITEM) ? '\\Ppb\\Form\\Element\\ListingPostageLocations' : false,
  1557. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_POSTAGE],
  1558. 'chznMultiOptions' => $this->getUser()->getShipping()->getLocationGroups(),
  1559. 'description' => $this->_('Enter the postage options that apply to this item.'),
  1560. 'attributes' => array(
  1561. 'class' => 'field-shipping',
  1562. ),
  1563. 'validators' => (
  1564. $this->_formId !== 'prefilled' &&
  1565. $this->_formId !== 'bulk' &&
  1566. $this->getData(ShippingModel::FLD_PICKUP_OPTIONS) != ShippingModel::MUST_PICKUP) ?
  1567. array(
  1568. '\\Ppb\\Validate\\ItemPostage',
  1569. ) : null,
  1570. 'filters' => array(
  1571. '\\Ppb\\Filter\\LocalizedNumeric',
  1572. ),
  1573. 'bulk' => array(
  1574. 'multiOptions' => (array)$this->getUser()->getShipping()->getLocationGroups(),
  1575. ),
  1576. ),
  1577. array(
  1578. 'form_id' => array('item', 'product_edit', 'bulk'),
  1579. 'subform' => 'shipping',
  1580. 'id' => ShippingModel::FLD_ITEM_WEIGHT,
  1581. 'element' => ($settings['enable_shipping'] && $this->getUser()->getShipping()->getPostageType() == ShippingModel::POSTAGE_TYPE_CARRIERS) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : 'hidden',
  1582. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_ITEM_WEIGHT],
  1583. 'suffix' => $this->getUser()->getShipping()->getWeightUom(),
  1584. 'description' => $this->_('Enter the weight of your item.'),
  1585. 'attributes' => array(
  1586. 'class' => 'form-control input-mini field-shipping',
  1587. ),
  1588. 'required' => (
  1589. $settings['enable_shipping'] &&
  1590. $this->getUser()->getShipping()->getPostageType() == ShippingModel::POSTAGE_TYPE_CARRIERS &&
  1591. $this->getData(ShippingModel::FLD_PICKUP_OPTIONS) != ShippingModel::MUST_PICKUP
  1592. ) ? true : false,
  1593. 'filters' => array(
  1594. '\\Ppb\\Filter\\LocalizedNumeric',
  1595. ),
  1596. 'bulk' => array(
  1597. 'type' => $translate->_('decimal'),
  1598. 'notes' => sprintf($translate->_('Weight UOM: %s'), $this->getUser()->getShipping()->getWeightUom()),
  1599. 'sample' => 1.5,
  1600. ),
  1601. ),
  1602. array(
  1603. 'form_id' => array('item', 'product_edit', 'bulk'),
  1604. 'subform' => 'shipping',
  1605. 'id' => ShippingModel::FLD_DIMENSIONS,
  1606. 'element' => ($settings['enable_shipping'] && $this->getUser()->getShipping()->getPostageType() == ShippingModel::POSTAGE_TYPE_CARRIERS) ? '\\Ppb\\Form\\Element\\Dimensions' : 'hidden',
  1607. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_DIMENSIONS],
  1608. 'suffix' => $this->getUser()->getShipping()->getDimensionsUom(),
  1609. 'description' => $this->_('Enter the dimensions of your item (L x W x H).'),
  1610. 'attributes' => array(
  1611. 'class' => 'form-control input-mini field-shipping',
  1612. 'placeholder' => array(
  1613. ShippingModel::DIMENSION_LENGTH => $translate->_('Length'),
  1614. ShippingModel::DIMENSION_WIDTH => $translate->_('Width'),
  1615. ShippingModel::DIMENSION_HEIGHT => $translate->_('Height'),
  1616. ),
  1617. ),
  1618. 'filters' => array(
  1619. '\\Ppb\\Filter\\LocalizedNumeric',
  1620. ),
  1621. 'bulk' => array(
  1622. 'type' => $translate->_('string'),
  1623. 'notes' => sprintf($translate->_('Weight UOM: %s'), $this->getUser()->getShipping()->getDimensionsUom())
  1624. . '<br>'
  1625. . $this->_('The required format for this field is: Length||Width||Height'),
  1626. 'sample' => '5' . Service\Listings\BulkLister::ARRAY_SEPARATOR . '7' . Service\Listings\BulkLister::ARRAY_SEPARATOR . '10',
  1627. ),
  1628. ),
  1629. array(
  1630. 'form_id' => array('item', 'product_edit', 'prefilled', 'bulk'),
  1631. 'subform' => 'shipping',
  1632. 'id' => ShippingModel::FLD_INSURANCE,
  1633. 'element' => ($settings['enable_shipping']) ? '\\Ppb\\Form\\Element\\LocalizedNumeric' : 'hidden',
  1634. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_INSURANCE],
  1635. 'prefix' => '<span class="listing-currency">' . $this->getData('currency') . '</span>',
  1636. 'description' => $this->_('Enter the insurance amount that applies to this item (optional).'),
  1637. 'attributes' => array(
  1638. 'class' => 'form-control input-mini field-shipping',
  1639. ),
  1640. 'filters' => array(
  1641. '\\Ppb\\Filter\\LocalizedNumeric',
  1642. ),
  1643. 'validators' => array(
  1644. 'Numeric',
  1645. array('GreaterThan', array(0, true)),
  1646. ),
  1647. 'bulk' => array(
  1648. 'type' => $translate->_('decimal'),
  1649. ),
  1650. ),
  1651. array(
  1652. 'form_id' => array('item', 'product_edit', 'prefilled', 'bulk'),
  1653. 'subform' => 'shipping',
  1654. 'id' => ShippingModel::FLD_SHIPPING_DETAILS,
  1655. 'element' => ($settings['enable_shipping']) ? 'textarea' : 'hidden',
  1656. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_SHIPPING_DETAILS],
  1657. 'description' => $this->_('Enter any shipping instructions that might apply for your item (optional).'),
  1658. 'attributes' => array(
  1659. 'rows' => '4',
  1660. 'class' => 'form-control field-shipping',
  1661. ),
  1662. 'filters' => array(
  1663. '\\Ppb\\Filter\\BadWords',
  1664. ),
  1665. 'bulk' => array(
  1666. 'sample' => 'Shipping Details',
  1667. ),
  1668. ),
  1669. array(
  1670. 'form_id' => array('item', 'product_edit', 'prefilled', 'bulk'),
  1671. 'subform' => 'shipping',
  1672. 'subtitle' => $this->_('Returns'),
  1673. 'id' => ShippingModel::FLD_ACCEPT_RETURNS,
  1674. 'element' => ($settings['enable_returns']) ? 'checkbox' : false,
  1675. 'value' => ($this->getData('returns_policy')) ? 1 : null,
  1676. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_ACCEPT_RETURNS],
  1677. 'multiOptions' => array(
  1678. 1 => null,
  1679. ),
  1680. 'attributes' => array(
  1681. 'class' => 'field-changeable',
  1682. ),
  1683. 'description' => $this->_('Check the above checkbox if you will be accepting returns for this item.'),
  1684. 'bulk' => array(
  1685. 'multiOptions' => array(0, 1),
  1686. ),
  1687. ),
  1688. array(
  1689. 'form_id' => array('item', 'product_edit', 'prefilled', 'bulk'),
  1690. 'subform' => 'shipping',
  1691. 'id' => ShippingModel::FLD_RETURNS_POLICY,
  1692. 'element' => 'textarea',
  1693. 'label' => ShippingModel::$postageFields[ShippingModel::FLD_RETURNS_POLICY],
  1694. 'description' => $this->_('Enter any return policy details that might apply for your item (optional).'),
  1695. 'attributes' => array(
  1696. 'class' => 'form-control',
  1697. ),
  1698. 'filters' => array(
  1699. '\\Ppb\\Filter\\BadWords',
  1700. ),
  1701. 'bulk' => array(
  1702. 'sample' => 'Returns Policy',
  1703. ),
  1704. ),
  1705. array(
  1706. 'form_id' => array('item', 'product_edit', 'prefilled', 'bulk'),
  1707. 'subform' => 'shipping',
  1708. 'subtitle' => $this->_('Payment Methods'),
  1709. 'id' => 'direct_payment',
  1710. 'element' => (count($paymentGateways) > 0) ? 'checkbox' : 'hidden',
  1711. 'label' => $this->_('Direct Payment'),
  1712. 'multiOptions' => $paymentGateways,
  1713. 'attributes' => array(
  1714. 'class' => 'direct-payment',
  1715. ),
  1716. 'description' => $translate->_('Select any direct payment methods that can be used to pay for this item.')
  1717. . ((!$this->_inAdmin) ? '<br>'
  1718. . sprintf($translate->_('<a class="jq-popup-form" href="%s" title="%s">Click here</a> to manage your payment gateways credentials / settings.'),
  1719. $this->getView()->url(array(
  1720. 'module' => 'members',
  1721. 'controller' => 'user',
  1722. 'action' => 'edit-payment-gateway',
  1723. 'popup' => true)),
  1724. $translate->_('Direct Payment Gateways Settings')) : ''),
  1725. 'bulk' => array(
  1726. 'notes' => sprintf(
  1727. $translate->_('Direct payment methods available are displayed in the "Payment Methods" tab. Multiple selections are to be separated by "%s"'),
  1728. $bulkArraySeparator),
  1729. 'multiOptions' => array(),
  1730. 'sample' => implode($bulkArraySeparator, array_keys($paymentGateways))
  1731. ),
  1732. ),
  1733. array(
  1734. 'form_id' => array('item', 'product_edit', 'prefilled', 'bulk'),
  1735. 'subform' => 'shipping',
  1736. 'id' => 'offline_payment',
  1737. 'element' => (count($paymentMethods) > 0) ? 'checkbox' : 'hidden',
  1738. 'label' => $this->_('Offline Payment'),
  1739. 'multiOptions' => $paymentMethods,
  1740. 'description' => $this->_('Select any payment methods from the above that the buyer might use to pay for the item.'
  1741. . 'The payment through these payment methods will be handled offline.'),
  1742. 'bulk' => array(
  1743. 'notes' => sprintf(
  1744. $translate->_('Offline payment methods available are displayed in the "Payment Methods" tab. Multiple selections are to be separated by "||"'),
  1745. $bulkArraySeparator),
  1746. 'multiOptions' => array(),
  1747. 'sample' => implode($bulkArraySeparator, array_keys($paymentMethods))
  1748. ),
  1749. ),
  1750. array(
  1751. 'form_id' => array('item', 'product_edit'),
  1752. 'subform' => 'shipping',
  1753. 'id' => 'check_payment_methods',
  1754. 'element' => 'hidden',
  1755. 'validators' => (count($paymentGateways) > 0 || count($paymentMethods) > 0) ?
  1756. array('\\Ppb\\Validate\\PaymentMethods') : null,
  1757. )
  1758. );
  1759. if ($this->_formId != 'bulk') {
  1760. array_splice($array, 10, 0, $customFields);
  1761. }
  1762. else {
  1763. $bulkListerCustomFields = $this->getCustomFields()->getFields(
  1764. array(
  1765. 'type' => $customFieldsType,
  1766. 'active' => 1,
  1767. ))->toArray();
  1768. foreach ($bulkListerCustomFields as $key => $customField) {
  1769. $bulkListerCustomFields[$key]['form_id'] = array('bulk');
  1770. $bulkListerCustomFields[$key]['id'] = 'custom_field_' . $customField['id'];
  1771. if ($customField['product_attribute']) {
  1772. $bulkListerCustomFields[$key]['required'] = false;
  1773. }
  1774. if (!empty($customField['multiOptions'])) {
  1775. $multiOptions = \Ppb\Utility::unserialize($customField['multiOptions']);
  1776. $bulkListerCustomFields[$key]['bulk']['multiOptions'] = (!empty($multiOptions['key'])) ?
  1777. array_flip(array_filter($multiOptions['key'])) : array();
  1778. }
  1779. }
  1780. $array = array_merge($array, $bulkListerCustomFields);
  1781. }
  1782. return $array;
  1783. }
  1784. }