PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/sanders_nick/legacy-media
PHP | 245 lines | 217 code | 28 blank | 0 comment | 28 complexity | 40ce87a30dbf7e5673a05ce54bd10f3b 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. <?php if (!empty($updated)): ?><div id="message" class="updated fade"><p><?php echo $updated; ?></p></div><?php endif; ?>
  3. <div class="icon32"></div>
  4. <h2><?php _e('Customers','Shopp'); ?> <a href="<?php echo esc_url( add_query_arg('id','new', $action) ); ?>" class="button add-new"><?php _e('Add New','Shopp'); ?></a></h2>
  5. <form action="<?php echo esc_url($action); ?>" id="orders-list" method="get">
  6. <div>
  7. <input type="hidden" name="page" value="<?php echo $page; ?>" />
  8. <input type="hidden" name="status" value="<?php echo $status; ?>" />
  9. </div>
  10. <br class="clear" />
  11. <p id="post-search" class="search-box">
  12. <input type="text" id="customers-search-input" class="search-input" name="s" value="<?php echo esc_attr($s); ?>" />
  13. <input type="submit" value="<?php _e('Search','Shopp'); ?>" class="button" />
  14. </p>
  15. <div class="tablenav">
  16. <div class="alignleft actions inline">
  17. <?php if(current_user_can('shopp_delete_customers')): ?><button type="submit" id="delete-button" name="deleting" value="customer" class="button-secondary"><?php _e('Delete','Shopp'); ?></button><?php endif; ?>
  18. <div class="filtering">
  19. <select name="range" id="range">
  20. <?php echo menuoptions($ranges,$range,true); ?>
  21. </select>
  22. <div id="dates">
  23. <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>
  24. <small><?php _e('to','Shopp'); ?></small>
  25. <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>
  26. </div>
  27. <button type="submit" id="filter-button" name="filter" value="customers" class="button-secondary"><?php _e('Filter','Shopp'); ?></button>
  28. </div>
  29. </div>
  30. <?php $ListTable->pagination('top'); ?>
  31. <div class="clear"></div>
  32. </div>
  33. <div class="clear"></div>
  34. <table class="widefat" cellspacing="0">
  35. <thead>
  36. <tr><?php print_column_headers('shopp_page_shopp-customers'); ?></tr>
  37. </thead>
  38. <tfoot>
  39. <tr><?php print_column_headers('shopp_page_shopp-customers',false); ?></tr>
  40. </tfoot>
  41. <?php if (count($Customers) > 0): ?>
  42. <tbody id="customers-table" class="list orders">
  43. <?php
  44. $hidden = get_hidden_columns('shopp_page_shopp-customers');
  45. $even = false;
  46. foreach ($Customers as $Customer):
  47. $CustomerName = (empty($Customer->firstname) && empty($Customer->lastname))?'('.__('no contact name','Shopp').')':"{$Customer->firstname} {$Customer->lastname}";
  48. ?>
  49. <tr<?php if (!$even) echo " class='alternate'"; $even = !$even; ?>>
  50. <th scope='row' class='check-column'><input type='checkbox' name='selected[]' value='<?php echo $Customer->id; ?>' /></th>
  51. <td class="name column-name"><a class='row-title' href='<?php echo esc_url( add_query_arg(array('page'=>'shopp-customers','id'=>$Customer->id),admin_url('admin.php'))); ?>' title='<?php _e('Edit','Shopp'); ?> &quot;<?php echo esc_attr($CustomerName); ?>&quot;'><?php echo esc_html($CustomerName); ?></a><?php echo !empty($Customer->company)?"<br />".esc_html($Customer->company):""; ?></td>
  52. <td class="login column-login<?php echo in_array('login',$hidden)?' hidden':''; ?>"><?php echo esc_html($Customer->user_login); ?></td>
  53. <td class="email column-email<?php echo in_array('email',$hidden)?' hidden':''; ?>"><a href="mailto:<?php echo esc_attr($Customer->email); ?>"><?php echo esc_html($Customer->email); ?></a></td>
  54. <td class="location column-location<?php echo in_array('location',$hidden)?' hidden':''; ?>"><?php
  55. $location = '';
  56. $location = $Customer->city;
  57. if (!empty($location) && !empty($Customer->state)) $location .= ', ';
  58. $location .= $Customer->state;
  59. if (!empty($location) && !empty($Customer->country))
  60. $location .= ' &mdash; ';
  61. $location .= $Customer->country;
  62. echo esc_html($location);
  63. ?></td>
  64. <td class="total column-total<?php echo in_array('total',$hidden)?' hidden':''; ?>"><a href="<?php echo esc_url( add_query_arg(array('page'=>'shopp-orders','customer'=>$Customer->id),admin_url('admin.php'))); ?>"><?php echo $Customer->orders; ?> &mdash; <?php echo money($Customer->total); ?></a></td>
  65. <td class="date column-date<?php echo in_array('date',$hidden)?' hidden':''; ?>"><?php echo date("Y/m/d",mktimestamp($Customer->created)); ?></td>
  66. </tr>
  67. <?php endforeach; ?>
  68. </tbody>
  69. <?php else: ?>
  70. <tbody><tr><td colspan="7"><?php _e('No customers yet.','Shopp'); ?></td></tr></tbody>
  71. <?php endif; ?>
  72. </table>
  73. </form>
  74. <div class="tablenav">
  75. <?php if(current_user_can('shopp_export_customers')): ?>
  76. <div class="alignleft actions">
  77. <form action="<?php echo esc_url(add_query_arg(array_merge($_GET,array('src'=>'export_customers')),admin_url("admin.php"))); ?>" id="log" method="post">
  78. <button type="button" id="export-settings-button" name="export-settings" class="button-secondary"><?php _e('Export Options','Shopp'); ?></button>
  79. <div id="export-settings" class="hidden">
  80. <div id="export-columns" class="multiple-select">
  81. <ul>
  82. <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>
  83. <li<?php if ($even) echo ' class="odd"'; $even = !$even; ?>><input type="hidden" name="settings[customerexport_headers]" value="off" /><input type="checkbox" name="settings[customerexport_headers]" id="purchaselog_headers" value="on" /><label for="purchaselog_headers"><strong><?php _e('Include column headings','Shopp'); ?></strong></label></li>
  84. <?php $even = true; foreach ($columns as $name => $label): ?>
  85. <li<?php if ($even) echo ' class="odd"'; $even = !$even; ?>><input type="checkbox" name="settings[customerexport_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>
  86. <?php endforeach; ?>
  87. </ul>
  88. </div><br />
  89. <select name="settings[customerexport_format]">
  90. <?php echo menuoptions($exports,$formatPref,true); ?>
  91. </select></div>
  92. <button type="submit" id="download-button" name="download" value="export" class="button-secondary"><?php _e('Download','Shopp'); ?></button>
  93. </form>
  94. </div>
  95. <?php endif; ?>
  96. <?php $ListTable->pagination('bottom'); ?>
  97. <div class="clear"></div>
  98. </div>
  99. </div>
  100. <div id="start-calendar" class="calendar"></div>
  101. <div id="end-calendar" class="calendar"></div>
  102. <script type="text/javascript">
  103. var lastexport = new Date(<?php echo date("Y,(n-1),j",shopp_setting('customerexport_lastexport')); ?>);
  104. jQuery(document).ready( function() {
  105. var $=jqnc();
  106. $('#selectall').change( function() {
  107. $('#customers-table th input').each( function () {
  108. if (this.checked) this.checked = false;
  109. else this.checked = true;
  110. });
  111. });
  112. $('#delete-button').click(function() {
  113. if (confirm("<?php echo addslashes(__('Are you sure you want to delete the selected customers?','Shopp')); ?>")) return true;
  114. else return false;
  115. });
  116. function formatDate (e) {
  117. if (this.value == "") match = false;
  118. if (this.value.match(/^(\d{6,8})/))
  119. match = this.value.match(/(\d{1,2}?)(\d{1,2})(\d{4,4})$/);
  120. else if (this.value.match(/^(\d{1,2}.{1}\d{1,2}.{1}\d{4})/))
  121. match = this.value.match(/^(\d{1,2}).{1}(\d{1,2}).{1}(\d{4})/);
  122. if (match) {
  123. date = new Date(match[3],(match[1]-1),match[2]);
  124. $(this).val((date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear());
  125. range.val('custom');
  126. }
  127. }
  128. var range = $('#range'),
  129. start = $('#start').change(formatDate),
  130. StartCalendar = $('<div id="start-calendar" class="calendar"></div>').appendTo('#wpwrap').PopupCalendar({
  131. scheduling:false,
  132. input:start
  133. }).bind('calendarSelect',function () {
  134. range.val('custom');
  135. }),
  136. end = $('#end').change(formatDate),
  137. EndCalendar = $('<div id="end-calendar" class="calendar"></div>').appendTo('#wpwrap').PopupCalendar({
  138. scheduling:true,
  139. input:end,
  140. scheduleAfter:StartCalendar
  141. }).bind('calendarSelect',function () {
  142. range.val('custom');
  143. });
  144. range.change(function () {
  145. if (this.selectedIndex == 0) {
  146. start.val(''); end.val('');
  147. $('#dates').addClass('hidden');
  148. return;
  149. } else $('#dates').removeClass('hidden');
  150. var today = new Date(),
  151. startdate = new Date(today.getFullYear(),today.getMonth(),today.getDate()),
  152. enddate = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  153. today = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  154. switch($(this).val()) {
  155. case 'week':
  156. startdate.setDate(today.getDate()-today.getDay());
  157. enddate = new Date(startdate.getFullYear(),startdate.getMonth(),startdate.getDate()+6);
  158. break;
  159. case 'month':
  160. startdate.setDate(1);
  161. enddate = new Date(startdate.getFullYear(),startdate.getMonth()+1,0);
  162. break;
  163. case 'quarter':
  164. quarter = Math.floor(today.getMonth()/3);
  165. startdate = new Date(today.getFullYear(),today.getMonth()-(today.getMonth()%3),1);
  166. enddate = new Date(today.getFullYear(),startdate.getMonth()+3,0);
  167. break;
  168. case 'year':
  169. startdate = new Date(today.getFullYear(),0,1);
  170. enddate = new Date(today.getFullYear()+1,0,0);
  171. break;
  172. case 'yesterday':
  173. startdate.setDate(today.getDate()-1);
  174. enddate.setDate(today.getDate()-1);
  175. break;
  176. case 'lastweek':
  177. startdate.setDate(today.getDate()-today.getDay()-7);
  178. enddate.setDate((today.getDate()-today.getDay()+6)-7);
  179. break;
  180. case 'last30':
  181. startdate.setDate(today.getDate()-30);
  182. enddate.setDate(today.getDate());
  183. break;
  184. case 'last90':
  185. startdate.setDate(today.getDate()-90);
  186. enddate.setDate(today.getDate());
  187. break;
  188. case 'lastmonth':
  189. startdate = new Date(today.getFullYear(),today.getMonth()-1,1);
  190. enddate = new Date(today.getFullYear(),today.getMonth(),0);
  191. break;
  192. case 'lastquarter':
  193. startdate = new Date(today.getFullYear(),(today.getMonth()-(today.getMonth()%3))-3,1);
  194. enddate = new Date(today.getFullYear(),startdate.getMonth()+3,0);
  195. break;
  196. case 'lastyear':
  197. startdate = new Date(today.getFullYear()-1,0,1);
  198. enddate = new Date(today.getFullYear(),0,0);
  199. break;
  200. case 'lastexport':
  201. startdate = lastexport;
  202. enddate = today;
  203. break;
  204. case 'custom': return; break;
  205. }
  206. StartCalendar.select(startdate);
  207. EndCalendar.select(enddate);
  208. }).change();
  209. $('#export-settings-button').click(function () { $('#export-settings-button').hide(); $('#export-settings').removeClass('hidden'); });
  210. $('#selectall_columns').change(function () {
  211. if ($(this).attr('checked')) $('#export-columns input').not(this).attr('checked',true);
  212. else $('#export-columns input').not(this).attr('checked',false);
  213. });
  214. pagenow = 'shopp_page_shopp-customers';
  215. columns.init(pagenow);
  216. });
  217. </script>