sale.phtml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <?php
  2. /**
  3. * @version 7.9 [rev.7.9.02]
  4. */
  5. /** @var \Ppb\Db\Table\Row\Sale $sale */
  6. /** @var \Ppb\Db\Table\Rowset\SalesListings $salesListings */
  7. $salesListings = $sale->findDependentRowset('\Ppb\Db\Table\SalesListings');
  8. /** @var \Ppb\Db\Table\Row\User $buyer */
  9. $buyer = $sale->findParentRow('\Ppb\Db\Table\Users', 'Buyer');
  10. $postageDesc = (isset($postageDesc)) ? $postageDesc : false;
  11. $directPaymentButton = (isset($directPaymentButton)) ? $directPaymentButton : false;
  12. $type = (isset($type)) ? $type : '';
  13. $inAdmin = (isset($inAdmin)) ? $inAdmin : false;
  14. $caption = (isset($caption)) ? $caption : false;
  15. $displayDownloads = (isset($displayDownloads)) ? $displayDownloads : false;
  16. $invoice = (isset($invoice)) ? $invoice : false;
  17. /** @var \Ppb\Db\Table\Row\User $seller */
  18. if ($type != 'sold') {
  19. $seller = $sale->findParentRow('\Ppb\Db\Table\Users', 'Seller');
  20. }
  21. $insuranceAmount = $sale->getInsuranceAmount();
  22. $taxAmount = $sale->getTaxAmount();
  23. $rowspan = 1;
  24. if ($insuranceAmount) {
  25. $rowspan++;
  26. }
  27. if ($taxAmount) {
  28. $rowspan++;
  29. }
  30. ?>
  31. <table class="table table-sale <?php echo $invoice ? 'well' : ''; ?>">
  32. <?php if ($caption === true) { ?>
  33. <caption>
  34. <?php if (!$inAdmin) { ?>
  35. <?php $btnClass = 'btn btn-default btn-sm' . (($sale->isActive()) ? '' : ' ' . 'disabled'); ?>
  36. <div class="btn-group pull-left">
  37. <a class="<?php echo $btnClass; ?>"
  38. href="<?php echo $this->url(array('module' => 'members', 'controller' => 'invoices', 'action' => 'view', 'id' => $sale['id'])); ?>"
  39. target="_blank"
  40. title="<?php echo $this->_('View & Print Invoice'); ?>">
  41. <i class="fa fa-print"></i> <?php echo $this->_('View & Print Invoice'); ?>
  42. </a>
  43. <?php if ($sale->messagingEnabled()) { ?>
  44. <a class="<?php echo $btnClass; ?>"
  45. href="<?php echo $this->url($sale->messagingLink()); ?>"
  46. title="<?php echo $this->_('Message Board'); ?>">
  47. <i class="fa fa-comments"></i> <?php echo $this->_('Message Board'); ?>
  48. </a>
  49. <?php } ?>
  50. <?php
  51. if ($this->settings['enable_reputation']) {
  52. if (!empty($this->loggedInUser['id'])) {
  53. $reputationLink = $sale->reputationLink($this->loggedInUser['id']);
  54. if ($reputationLink) { ?>
  55. <a class="<?php echo $btnClass; ?>"
  56. href="<?php echo $this->url($reputationLink); ?>"
  57. title="<?php echo $this->_('Leave Feedback'); ?>">
  58. <i class="fa fa-commenting"></i> <?php echo $this->_('Leave Feedback'); ?>
  59. </a>
  60. <?php } ?>
  61. <?php } ?>
  62. <?php } ?>
  63. </div>
  64. <div class="clearfix"></div>
  65. <?php } ?>
  66. <div class="pull-left pdl-5">
  67. <strong><?php echo $this->_('Invoice #'); ?><?php echo $sale['id']; ?></strong>
  68. <?php echo $this->_('from'); ?>
  69. <strong><?php echo $this->date(max(array($sale['created_at'], $sale['updated_at'])),
  70. true); ?></strong>
  71. -
  72. <?php if ($type != 'sold') { ?>
  73. <strong><?php echo $this->_('Seller'); ?></strong>:
  74. <?php echo $this->userDetails()->setUser($seller)->display(); ?>
  75. <?php } ?>
  76. <?php if ($type != 'bought') { ?>
  77. <strong><?php echo $this->_('Buyer'); ?></strong>:
  78. <?php echo $this->userDetails()->setUser($buyer)->display(); ?>
  79. <?php } ?>
  80. </div>
  81. <div class="pull-right">
  82. <?php echo $this->saleOptions($sale); ?>
  83. </div>
  84. </caption>
  85. <?php
  86. }
  87. else if (!empty($caption)) {
  88. ?>
  89. <caption><?php echo $caption; ?></caption>
  90. <?php } ?>
  91. <thead>
  92. <tr>
  93. <th><?php echo $this->_('Listing'); ?></th>
  94. <th class="size-mini"><?php echo $this->_('Quantity'); ?></th>
  95. <th class="size-mini"><?php echo $this->_('Price'); ?></th>
  96. <th class="size-mini"><?php echo $this->_('Subtotal'); ?></th>
  97. </tr>
  98. </thead>
  99. <tbody>
  100. <?php
  101. /** @var \Ppb\Db\Table\Row\SaleListing $saleListing */
  102. foreach ($salesListings as $saleListing) {
  103. /** @var \Ppb\Db\Table\Row\Listing $listing */
  104. $listing = $saleListing->findParentRow('\Ppb\Db\Table\Listings');
  105. ?>
  106. <tr>
  107. <td>
  108. <?php if ($listing) { ?>
  109. <div>
  110. <a href="<?php echo $this->url($listing->link()); ?>"><?php echo $listing['name']; ?></a>
  111. <small>(#<?php echo $listing['id']; ?>)</small>
  112. </div>
  113. <?php if (!empty($saleListing['product_attributes'])) { ?>
  114. <div>
  115. <small><?php echo $this->productAttributes($saleListing['product_attributes'])->display(); ?></small>
  116. </div>
  117. <?php } ?>
  118. <?php
  119. }
  120. else {
  121. ?>
  122. <em><?php echo $this->_('Listing Deleted'); ?></em>
  123. <?php } ?>
  124. </td>
  125. <td><?php echo $saleListing['quantity']; ?></td>
  126. <td><?php echo $this->amount($saleListing->price(), $sale['currency']); ?></td>
  127. <td><?php echo $this->amount(($saleListing->price() * $saleListing['quantity']), $sale['currency']); ?></td>
  128. </tr>
  129. <?php if (($digitalDownloads = $saleListing->getDigitalDownloads()) !== false && $displayDownloads === true) {
  130. ?>
  131. <tr>
  132. <td colspan="4">
  133. <?php
  134. /** @var \Ppb\Db\Table\Row\ListingMedia $digitalDownload */
  135. foreach ($digitalDownloads as $digitalDownload) {
  136. ?>
  137. <div class="download-box">
  138. <?php if ($sale->isBuyer()) { ?>
  139. <div class="pull-left">
  140. <a href="<?php echo $this->url($digitalDownload['download_link'], null, false, null,
  141. true, false); ?>"
  142. class="btn btn-sm btn-primary<?php echo ($digitalDownload['active']) ? '' : ' disabled'; ?>">
  143. <i class="fa fa-download"></i> <?php echo $this->_('Download'); ?></a>
  144. </div>
  145. <?php } ?>
  146. <div class="pull-left">
  147. <?php echo $digitalDownload['value']; ?> <br>
  148. <?php if ($digitalDownload['active']) { ?>
  149. <small class="text-success"><?php echo $this->_('Download Active'); ?></small>
  150. <?php
  151. }
  152. else {
  153. ?>
  154. <small class="text-danger"><?php echo $this->_('Download Inactive'); ?></small>
  155. <?php } ?>
  156. &middot;
  157. <small class="text-info">
  158. <?php echo sprintf(
  159. $this->_('Downloaded %s times'),
  160. intval($digitalDownload['nb_downloads'])); ?>
  161. </small>
  162. &middot;
  163. <small class="text-primary">
  164. <?php echo sprintf(
  165. $this->_('Added on %s'),
  166. $this->date($digitalDownload['created_at'], true)); ?>
  167. </small>
  168. </div>
  169. <div class="clearfix"></div>
  170. </div>
  171. <?php } ?>
  172. <?php if ($sale->isSeller()) { ?>
  173. <a class="btn btn-sm btn-default confirm-box"
  174. href="<?php echo $this->url(array('module' => 'members', 'controller' => 'invoices', 'action' => 'update-download-links', 'sale_listing_id' => $saleListing->getData('id'))); ?>"
  175. data-message="<?php echo $this->_('Update the status of the download links for this listing?'); ?>">
  176. <?php if ($saleListing->getData('downloads_active')) { ?>
  177. <i class="fa fa-times"></i> <?php echo $this->_('Inactivate Downloads'); ?>
  178. <?php
  179. }
  180. else {
  181. ?>
  182. <i class="fa fa-check"></i> <?php echo $this->_('Activate Downloads'); ?>
  183. <?php } ?>
  184. </a>
  185. <?php } ?>
  186. </td>
  187. </tr>
  188. <?php } ?>
  189. <?php } ?>
  190. <?php if ($hasPostage = $sale->hasPostage()) { ?>
  191. <tr>
  192. <td>
  193. <?php if ($postageDesc) {
  194. $postageMethod = $sale->getPostageMethod();
  195. ?>
  196. <small>
  197. <?php echo $this->_('Postage Method:'); ?> <?php echo $this->_($postageMethod); ?>
  198. <?php if ($sale->isActive()) { ?>
  199. <?php if (!empty($sale['tracking_link'])) { ?>
  200. <a href="<?php echo $sale['tracking_link']; ?>"
  201. target="_blank"><?php echo $this->_('Track this package'); ?></a>
  202. <?php } ?>
  203. <?php if ($buyer) {
  204. $this->userDetails()->setUser($buyer);
  205. if ($postageMethod != \Ppb\Model\Shipping::VALUE_PICK_UP) {
  206. $this->userDetails()->setAddress($sale['shipping_address_id']);
  207. ?>
  208. <div>
  209. <?php echo $this->_('Delivery Address:'); ?>
  210. <?php echo $this->userDetails()->displayFullName() . ', '; ?>
  211. <?php echo $this->userDetails()->displayAddress(', '); ?>
  212. </div>
  213. <?php }
  214. else { ?>
  215. <div>
  216. <?php echo $this->_('Name:'); ?>
  217. <?php echo $this->userDetails()->displayFullName(); ?>
  218. </div>
  219. <?php } ?>
  220. <div>
  221. <?php echo $this->_('Email:'); ?>
  222. <?php echo $buyer['email']; ?>
  223. </div>
  224. <?php if ($this->settings['sale_phone_numbers']) { ?>
  225. <div>
  226. <?php echo $this->_('Phone:'); ?>
  227. <?php echo $buyer['phone']; ?>
  228. </div>
  229. <?php } ?>
  230. <?php } ?>
  231. <?php if (!empty($sale['shipping_comments'])) { ?>
  232. <div>
  233. <?php echo $this->_('Comments:'); ?>
  234. <?php echo $sale['shipping_comments']; ?>
  235. </div>
  236. <?php } ?>
  237. <?php } ?>
  238. </small>
  239. <?php } ?>
  240. </td>
  241. <td></td>
  242. <td>
  243. <small><?php echo $this->_('Postage'); ?></small>
  244. </td>
  245. <td><?php echo $this->amount($sale['postage_amount'], $sale['currency'], null, true); ?></td>
  246. </tr>
  247. <?php if ($insuranceAmount) { ?>
  248. <tr>
  249. <td></td>
  250. <td></td>
  251. <td>
  252. <small><?php echo $this->_('Insurance'); ?></small>
  253. </td>
  254. <td><?php echo $this->amount($insuranceAmount, $sale['currency'], null, true); ?></td>
  255. </tr>
  256. <?php } ?>
  257. <?php } ?>
  258. <?php if ($taxAmount) { ?>
  259. <tr>
  260. <td></td>
  261. <td></td>
  262. <td>
  263. <small><?php echo $this->_('Tax'); ?></small>
  264. </td>
  265. <td><?php echo $this->amount($taxAmount, $sale['currency'], null, true); ?></td>
  266. </tr>
  267. <?php } ?>
  268. <tr>
  269. <td>
  270. <?php if (!$sale->isActive(false)) { ?>
  271. <?php if ($sale->canPayFee() && $directPaymentButton) { ?>
  272. <a class="btn btn-sm btn-danger"
  273. href="<?php echo $this->url(array('module' => 'app', 'controller' => 'payment', 'action' => 'sale-transaction', 'id' => $sale['id'])); ?>"
  274. title="<?php echo $this->_('Make Transaction Sale Fee Payment'); ?>">
  275. <?php echo $this->_('Make Sale Transaction Fee Payment'); ?>
  276. </a>
  277. <?php }
  278. else { ?>
  279. <span class="label label-danger"><?php echo $this->_('Sale Transaction Fee Not Paid'); ?></span>
  280. <?php } ?>
  281. <?php } ?>
  282. <?php if ($inAdmin) { ?>
  283. <?php if ($sale['seller_deleted']) { ?>
  284. <span class="label label-danger"><?php echo $this->_('Seller Deleted'); ?></span>
  285. <?php } ?>
  286. <?php if ($sale['buyer_deleted']) { ?>
  287. <span class="label label-danger"><?php echo $this->_('Buyer Deleted'); ?></span>
  288. <?php } ?>
  289. <?php } ?>
  290. <?php if ($sale->canPayDirectPayment() !== false && $directPaymentButton) { ?>
  291. <a href="<?php echo $this->url(array('module' => 'app', 'controller' => 'payment', 'action' => 'direct-payment', 'id' => $sale['id'])); ?>"
  292. class="btn btn-sm btn-success"><?php echo $this->_('Make Payment'); ?></a>
  293. <?php } ?>
  294. <?php if ($sale['expires_at']) { ?>
  295. <div>
  296. <small class="text-danger">
  297. <?php echo sprintf(
  298. $this->_('The sale will be cancelled if not paid until %s'),
  299. $this->date($sale['expires_at'])); ?>
  300. </small>
  301. </div>
  302. <?php } ?>
  303. </td>
  304. <td></td>
  305. <td>
  306. <small><strong><?php echo $this->_('Total'); ?></strong></small>
  307. </td>
  308. <td><strong><?php echo $this->amount($sale->calculateTotal(), $sale['currency']); ?></strong></td>
  309. </tr>
  310. </tbody>
  311. </table>