PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/shopp/core/ui/orders/orders.php

https://bitbucket.org/sanders_nick/legacy-media
PHP | 284 lines | 248 code | 36 blank | 0 comment | 31 complexity | c4394f29ebcaefd76bc1a34d47dee2a3 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, GPL-2.0, BSD-3-Clause, GPL-3.0
  1. <div class="wrap shopp">
  2. <div class="icon32"></div>
  3. <h2><?php _e('Orders','Shopp'); ?></h2>
  4. <?php do_action('shopp_admin_notices'); ?>
  5. <form action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" id="orders" method="get">
  6. <?php include("navigation.php"); ?>
  7. <div>
  8. <input type="hidden" name="page" value="<?php echo $page; ?>" />
  9. </div>
  10. <div class="clear"></div>
  11. <p id="post-search" class="search-box">
  12. <input type="text" id="orders-search-input" class="search-input" name="s" value="<?php echo esc_attr($s); ?>" />
  13. <input type="submit" value="<?php _e('Search Orders','Shopp'); ?>" class="button" />
  14. </p>
  15. <?php if (current_user_can('shopp_financials')): ?>
  16. <ul id="report">
  17. <li><strong><?php echo $ordercount->total; ?></strong> <span><?php _e('Orders','Shopp'); ?></span></li>
  18. <li><strong><?php echo money($ordercount->sales); ?></strong> <span><?php _e('Total Sales','Shopp'); ?></span></li>
  19. <li><strong><?php echo money($ordercount->avgsale); ?></strong> <span><?php _e('Average Sale','Shopp'); ?></span></li>
  20. </ul>
  21. <?php endif; ?>
  22. <div class="tablenav">
  23. <div class="alignleft actions inline">
  24. <?php if (current_user_can('shopp_delete_orders')): ?><button type="submit" id="delete-button" name="deleting" value="order" class="button-secondary"><?php _e('Delete','Shopp'); ?></button><?php endif; ?>
  25. <select name="newstatus">
  26. <?php echo menuoptions($statusLabels,false,true); ?>
  27. </select>
  28. <button type="submit" id="update-button" name="update" value="order" class="button-secondary"><?php _e('Update','Shopp'); ?></button>
  29. <div class="filtering">
  30. <select name="range" id="range">
  31. <?php echo menuoptions($ranges,$range,true); ?>
  32. </select>
  33. <div id="dates" class="hide-if-js">
  34. <div id="start-position" class="calendar-wrap"><input type="text" id="start" name="start" value="<?php echo $startdate; ?>" size="10" class="search-input selectall" /></div>
  35. <small>to</small>
  36. <div id="end-position" class="calendar-wrap"><input type="text" id="end" name="end" value="<?php echo $enddate; ?>" size="10" class="search-input selectall" /></div>
  37. </div>
  38. <button type="submit" id="filter-button" name="filter" value="order" class="button-secondary"><?php _e('Filter','Shopp'); ?></button>
  39. </div>
  40. </div>
  41. <?php $ListTable->pagination('top'); ?>
  42. <div class="clear"></div>
  43. </div>
  44. <div class="clear"></div>
  45. <table class="widefat" cellspacing="0">
  46. <thead>
  47. <tr><?php print_column_headers('toplevel_page_shopp-orders'); ?></tr>
  48. </thead>
  49. <tfoot>
  50. <tr><?php print_column_headers('toplevel_page_shopp-orders',false); ?></tr>
  51. </tfoot>
  52. <?php if (count($Orders) > 0): ?>
  53. <tbody id="orders-table" class="list orders">
  54. <?php
  55. $hidden = get_hidden_columns('toplevel_page_shopp-orders');
  56. $url = add_query_arg('page','shopp-orders', admin_url('admin.php') );
  57. $even = false; foreach ($Orders as $Order):
  58. $classes = array();
  59. $viewurl = add_query_arg('id',$Order->id,$url);
  60. $customer = '' == trim($Order->firstname.$Order->lastname) ? "(".__('no contact name','Shopp').")" : ucfirst("{$Order->firstname} {$Order->lastname}");
  61. $customerurl = add_query_arg('customer',$Order->customer,$url);
  62. $txnstatus = isset($txnstatus_labels[$Order->txnstatus]) ? $txnstatus_labels[$Order->txnstatus] : $Order->txnstatus;
  63. $classes[] = strtolower(preg_replace('/[^\w]/','_',$Order->txnstatus));
  64. $gateway = $Gateways[$Order->gateway]->name;
  65. $addrfields = array('city','state','country');
  66. $format = '%3$s, %2$s &mdash; %1$s';
  67. if (empty($Order->shipaddress))
  68. $location = sprintf($format,$Order->country,$Order->state,$Order->city);
  69. else $location = sprintf($format,$Order->shipcountry,$Order->shipstate,$Order->shipcity);
  70. $location = ltrim($location,' ,');
  71. if (0 === strpos($location,'&mdash;'))
  72. $location = str_replace('&mdash; ','',$location);
  73. $location = str_replace(', &mdash;',' &mdash;',$location);
  74. if (!$even) $classes[] = "alternate";
  75. do_action_ref_array('shopp_order_row_css',array(&$classes,&$Order));
  76. $even = !$even;
  77. ?>
  78. <tr class="<?php echo join(' ',$classes); ?>">
  79. <th scope='row' class='check-column'><input type='checkbox' name='selected[]' value='<?php echo $Order->id; ?>' /></th>
  80. <td class="order column-order<?php echo in_array('order',$hidden)?' hidden':''; ?>"><a class='row-title' href='<?php echo esc_url($viewurl); ?>' title='<?php printf(__('View Order #%d','Shopp'),$Order->id); ?>'><?php printf(__('Order #%d','Shopp'),$Order->id); ?></a></td>
  81. <td class="name column-name"><a href="<?php echo esc_url($customerurl); ?>"><?php echo esc_html($customer); ?></a><?php echo !empty($Order->company)?"<br />".esc_html($Order->company):""; ?></td>
  82. <td class="destination column-destination<?php echo in_array('destination',$hidden)?' hidden':''; ?>"><?php echo esc_html($location); ?></td>
  83. <td class="txn column-txn<?php echo in_array('txn',$hidden)?' hidden':''; ?>"><?php echo $Order->txnid; ?><br /><?php echo esc_html($gateway); ?></td>
  84. <td class="date column-date<?php echo in_array('date',$hidden)?' hidden':''; ?>"><?php echo date("Y/m/d",mktimestamp($Order->created)); ?><br />
  85. <strong><?php echo $statusLabels[$Order->status]; ?></strong></td>
  86. <td class="total column-total<?php echo in_array('total',$hidden)?' hidden':''; ?>"><?php echo money($Order->total); ?><br /><span class="status"><?php echo $txnstatus; ?></span></td>
  87. </tr>
  88. <?php endforeach; ?>
  89. </tbody>
  90. <?php else: ?>
  91. <tbody><tr><td colspan="7"><?php
  92. printf(__('No %s orders yet.','Shopp'),(
  93. isset($_GET['status'],$statusLabels[$_GET['status']]) ? strtolower($statusLabels[$_GET['status']]) : ''
  94. )); ?></td></tr></tbody>
  95. <?php endif; ?>
  96. </table>
  97. </form>
  98. <div class="tablenav">
  99. <?php if (current_user_can('shopp_financials') && current_user_can('shopp_export_orders')): ?>
  100. <div class="alignleft actions">
  101. <form action="<?php echo esc_url( add_query_arg(urlencode_deep(array_merge(stripslashes_deep($_GET),array('src'=>'export_purchases'))),admin_url('admin.php')) ); ?>" id="log" method="post">
  102. <button type="button" id="export-settings-button" name="export-settings" class="button-secondary"><?php _e('Export Options','Shopp'); ?></button>
  103. <div id="export-settings" class="hidden">
  104. <div id="export-columns" class="multiple-select">
  105. <ul>
  106. <li<?php $even = true; if ($even) echo ' class="odd"'; $even = !$even; ?>><input type="checkbox" name="selectall_columns" id="selectall_columns" /><label for="selectall_columns"><strong><?php _e('Select All','Shopp'); ?></strong></label></li>
  107. <li<?php if ($even) echo ' class="odd"'; $even = !$even; ?>><input type="hidden" name="settings[purchaselog_headers]" value="off" /><input type="checkbox" name="settings[purchaselog_headers]" id="purchaselog_headers" value="on" /><label for="purchaselog_headers"><strong><?php _e('Include column headings','Shopp'); ?></strong></label></li>
  108. <?php $even = true; foreach ($columns as $name => $label): ?>
  109. <li<?php if ($even) echo ' class="odd"'; $even = !$even; ?>><input type="checkbox" name="settings[purchaselog_columns][]" value="<?php echo $name; ?>" id="column-<?php echo $name; ?>" <?php echo in_array($name,$selected)?' checked="checked"':''; ?> /><label for="column-<?php echo $name; ?>" ><?php echo $label; ?></label></li>
  110. <?php endforeach; ?>
  111. </ul>
  112. </div>
  113. <?php PurchasesIIFExport::settings(); ?>
  114. <br />
  115. <select name="settings[purchaselog_format]" id="purchaselog-format">
  116. <?php echo menuoptions($exports,$formatPref,true); ?>
  117. </select>
  118. </div>
  119. <button type="submit" id="download-button" name="download" value="export" class="button-secondary"<?php if (count($Orders) < 1) echo ' disabled="disabled"'; ?>><?php _e('Download','Shopp'); ?></button>
  120. <div class="clear"></div>
  121. </form>
  122. </div>
  123. <?php endif; ?>
  124. <?php $ListTable->pagination('bottom'); ?>
  125. <div class="clear"></div>
  126. </div>
  127. </div>
  128. <script type="text/javascript">
  129. var lastexport = new Date(<?php echo date("Y,(n-1),j",shopp_setting('purchaselog_lastexport')); ?>);
  130. jQuery(document).ready( function() {
  131. var $=jqnc();
  132. pagenow = 'toplevel_page_shopp-orders';
  133. columns.init(pagenow);
  134. $('#selectall').change( function() {
  135. $('#orders-table th input').each( function () {
  136. if (this.checked) this.checked = false;
  137. else this.checked = true;
  138. });
  139. });
  140. $('#delete-button').click(function() {
  141. if (confirm("<?php echo addslashes(__('Are you sure you want to delete the selected orders?','Shopp')); ?>")) return true;
  142. else return false;
  143. });
  144. $('#update-button').click(function() {
  145. if (confirm("<?php echo addslashes(__('Are you sure you want to update the status of the selected orders?','Shopp')); ?>")) return true;
  146. else return false;
  147. });
  148. function formatDate (e) {
  149. if (this.value == "") match = false;
  150. if (this.value.match(/^(\d{6,8})/))
  151. match = this.value.match(/(\d{1,2}?)(\d{1,2})(\d{4,4})$/);
  152. else if (this.value.match(/^(\d{1,2}.{1}\d{1,2}.{1}\d{4})/))
  153. match = this.value.match(/^(\d{1,2}).{1}(\d{1,2}).{1}(\d{4})/);
  154. if (match) {
  155. date = new Date(match[3],(match[1]-1),match[2]);
  156. $(this).val((date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear());
  157. range.val('custom');
  158. }
  159. }
  160. var range = $('#range'),
  161. start = $('#start').change(formatDate),
  162. StartCalendar = $('<div id="start-calendar" class="calendar"></div>').appendTo('#wpwrap').PopupCalendar({
  163. scheduling:false,
  164. input:start
  165. }).bind('calendarSelect',function () {
  166. range.val('custom');
  167. }),
  168. end = $('#end').change(formatDate),
  169. EndCalendar = $('<div id="end-calendar" class="calendar"></div>').appendTo('#wpwrap').PopupCalendar({
  170. scheduling:true,
  171. input:end,
  172. scheduleAfter:StartCalendar
  173. }).bind('calendarSelect',function () {
  174. range.val('custom');
  175. });
  176. range.change(function () {
  177. if (this.selectedIndex == 0) {
  178. start.val(''); end.val('');
  179. $('#dates').hide();
  180. return;
  181. } else $('#dates').show();
  182. var today = new Date(),
  183. startdate = new Date(today.getFullYear(),today.getMonth(),today.getDate()),
  184. enddate = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  185. today = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  186. switch($(this).val()) {
  187. case 'week':
  188. startdate.setDate(today.getDate()-today.getDay());
  189. enddate = new Date(startdate.getFullYear(),startdate.getMonth(),startdate.getDate()+6);
  190. break;
  191. case 'month':
  192. startdate.setDate(1);
  193. enddate = new Date(startdate.getFullYear(),startdate.getMonth()+1,0);
  194. break;
  195. case 'quarter':
  196. quarter = Math.floor(today.getMonth()/3);
  197. startdate = new Date(today.getFullYear(),today.getMonth()-(today.getMonth()%3),1);
  198. enddate = new Date(today.getFullYear(),startdate.getMonth()+3,0);
  199. break;
  200. case 'year':
  201. startdate = new Date(today.getFullYear(),0,1);
  202. enddate = new Date(today.getFullYear()+1,0,0);
  203. break;
  204. case 'yesterday':
  205. startdate.setDate(today.getDate()-1);
  206. enddate.setDate(today.getDate()-1);
  207. break;
  208. case 'lastweek':
  209. startdate.setDate(today.getDate()-today.getDay()-7);
  210. enddate.setDate((today.getDate()-today.getDay()+6)-7);
  211. break;
  212. case 'last30':
  213. startdate.setDate(today.getDate()-30);
  214. enddate.setDate(today.getDate());
  215. break;
  216. case 'last90':
  217. startdate.setDate(today.getDate()-90);
  218. enddate.setDate(today.getDate());
  219. break;
  220. case 'lastmonth':
  221. startdate = new Date(today.getFullYear(),today.getMonth()-1,1);
  222. enddate = new Date(today.getFullYear(),today.getMonth(),0);
  223. break;
  224. case 'lastquarter':
  225. startdate = new Date(today.getFullYear(),(today.getMonth()-(today.getMonth()%3))-3,1);
  226. enddate = new Date(today.getFullYear(),startdate.getMonth()+3,0);
  227. break;
  228. case 'lastyear':
  229. startdate = new Date(today.getFullYear()-1,0,1);
  230. enddate = new Date(today.getFullYear(),0,0);
  231. break;
  232. case 'lastexport':
  233. startdate = lastexport;
  234. enddate = today;
  235. break;
  236. case 'custom': return; break;
  237. }
  238. StartCalendar.select(startdate);
  239. EndCalendar.select(enddate);
  240. }).change();
  241. $('#export-settings-button').click(function () { $('#export-settings-button').hide(); $('#export-settings').removeClass('hidden'); });
  242. $('#selectall_columns').change(function () {
  243. if ($(this).attr('checked')) $('#export-columns input').not(this).attr('checked',true);
  244. else $('#export-columns input').not(this).attr('checked',false);
  245. });
  246. $('input.current-page').unbind('mouseup.select').bind('mouseup.select',function () { this.select(); });
  247. });
  248. </script>