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

https://github.com/kennethreitz-archive/wordpress-skeleton · PHP · 297 lines · 267 code · 30 blank · 0 comment · 40 complexity · 12138cfd308d9955bfdd3d321c83ae6c MD5 · raw file

  1. <div class="wrap shopp">
  2. <h2><?php _e('Customers','Shopp'); ?></h2>
  3. <form action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" id="orders" method="get">
  4. <div>
  5. <input type="hidden" name="page" value="<?php echo $page; ?>" />
  6. <input type="hidden" name="status" value="<?php echo $status; ?>" />
  7. </div>
  8. <br class="clear" />
  9. <p id="post-search" class="search-box">
  10. <input type="text" id="customers-search-input" class="search-input" name="s" value="<?php echo attribute_escape($s); ?>" />
  11. <input type="submit" value="<?php _e('Search','Shopp'); ?>" class="button" />
  12. </p>
  13. <div class="tablenav">
  14. <div class="alignleft actions">
  15. <button type="submit" id="delete-button" name="deleting" value="customer" class="button-secondary"><?php _e('Delete','Shopp'); ?></button>
  16. <span class="filtering">
  17. <select name="range" id="range">
  18. <?php echo menuoptions($ranges,$range,true); ?>
  19. </select>
  20. <span id="dates">
  21. <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>
  22. <small><?php _e('to','Shopp'); ?></small>
  23. <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>
  24. </span>
  25. <button type="submit" id="filter-button" name="filter" value="customers" class="button-secondary"><?php _e('Filter','Shopp'); ?></button>
  26. </span>
  27. </div>
  28. <?php if ($page_links) echo "<div class='tablenav-pages'>$page_links</div>"; ?>
  29. <div class="clear"></div>
  30. </div>
  31. <?php if (SHOPP_WP27): ?><div class="clear"></div>
  32. <?php else: ?><br class="clear" /><?php endif; ?>
  33. <table class="widefat" cellspacing="0">
  34. <thead>
  35. <tr><?php shopp_print_column_headers('shopp_page_shopp-customers'); ?></tr>
  36. </thead>
  37. <?php if (SHOPP_WP27): ?>
  38. <tfoot>
  39. <tr><?php shopp_print_column_headers('shopp_page_shopp-customers',false); ?></tr>
  40. </tfoot>
  41. <?php endif; ?>
  42. <?php if (sizeof($Customers) > 0): ?>
  43. <tbody id="customers-table" class="list orders">
  44. <?php
  45. if (SHOPP_WP27) $hidden = get_hidden_columns('shopp_page_shopp-customers');
  46. else $hidden = array();
  47. $even = false;
  48. foreach ($Customers as $Customer):
  49. $CustomerName = (empty($Customer->firstname) && empty($Customer->lastname))?'('.__('no contact name','Shopp').')':"{$Customer->firstname} {$Customer->lastname}";
  50. ?>
  51. <tr<?php if (!$even) echo " class='alternate'"; $even = !$even; ?>>
  52. <th scope='row' class='check-column'><input type='checkbox' name='selected[]' value='<?php echo $Customer->id; ?>' /></th>
  53. <td class="name column-name"><a class='row-title' href='<?php echo add_query_arg(array('page'=>$this->Admin->editcustomer,'id'=>$Customer->id),$Shopp->wpadminurl."admin.php"); ?>' title='<?php _e('Edit','Shopp'); ?> &quot;<?php echo $CustomerName; ?>&quot;'><?php echo $CustomerName; ?></a><?php echo !empty($Customer->company)?"<br />$Customer->company":""; ?></td>
  54. <td class="login column-login<?php echo in_array('login',$hidden)?' hidden':''; ?>"><?php echo $Customer->user_login; ?></td>
  55. <td class="email column-email<?php echo in_array('email',$hidden)?' hidden':''; ?>"><a href="mailto:<?php echo $Customer->email; ?>"><?php echo $Customer->email; ?></a></td>
  56. <td class="location column-location<?php echo in_array('location',$hidden)?' hidden':''; ?>"><?php
  57. $location = '';
  58. $location = $Customer->city;
  59. if (!empty($location) && !empty($Customer->state)) $location .= ', ';
  60. $location .= $Customer->state;
  61. if (!empty($location) && !empty($Customer->country))
  62. $location .= ' &mdash; ';
  63. $location .= $Customer->country;
  64. echo $location;
  65. ?></td>
  66. <td class="total column-total<?php echo in_array('total',$hidden)?' hidden':''; ?>"><?php echo $Customer->orders; ?> &mdash; <?php echo money($Customer->total); ?></td>
  67. <td class="date column-date<?php echo in_array('date',$hidden)?' hidden':''; ?>"><?php echo date("Y/m/d",mktimestamp($Customer->created)); ?></td>
  68. </tr>
  69. <?php endforeach; ?>
  70. </tbody>
  71. <?php else: ?>
  72. <tbody><tr><td colspan="6"><?php _e('No','Shopp'); ?> <?php _e('customers, yet.','Shopp'); ?></td></tr></tbody>
  73. <?php endif; ?>
  74. </table>
  75. </form>
  76. <div class="tablenav">
  77. <div class="alignleft actions">
  78. <form action="<?php echo esc_url(add_query_arg(array_merge($_GET,array('lookup'=>'customerexport')),$Shopp->wpadminurl."admin.php")); ?>" id="log" method="post">
  79. <button type="button" id="export-settings-button" name="export-settings" class="button-secondary"><?php _e('Export Options','Shopp'); ?></button>
  80. <span id="export-settings" class="hidden">
  81. <div id="export-columns" class="multiple-select">
  82. <ul>
  83. <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>
  84. <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>
  85. <?php $even = true; foreach ($columns as $name => $label): ?>
  86. <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>
  87. <?php endforeach; ?>
  88. </ul>
  89. </div><br />
  90. <select name="settings[customerexport_format]">
  91. <?php echo menuoptions($exports,$formatPref,true); ?>
  92. </select></span>
  93. <button type="submit" id="download-button" name="download" value="export" class="button-secondary"><?php _e('Download','Shopp'); ?></button>
  94. </div>
  95. <?php if ($page_links) echo "<div class='tablenav-pages'>$page_links</div>"; ?>
  96. <div class="clear"></div>
  97. </div>
  98. </div>
  99. <div id="start-calendar" class="calendar"></div>
  100. <div id="end-calendar" class="calendar"></div>
  101. <script type="text/javascript">
  102. helpurl = "<?php echo SHOPP_DOCS; ?>Managing Orders";
  103. var lastexport = new Date(<?php echo date("Y,(n-1),j",$Shopp->Settings->get('customerexport_lastexport')); ?>);
  104. jQuery(document).ready( function() {
  105. var $=jQuery.noConflict();
  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 getDateInput(input) {
  117. var match = false;
  118. match = $(input).get(0).value.match(/^(\d{1,2}).{1}(\d{1,2}).{1}(\d{4})/);
  119. if (match) return new Date(match[3],(match[1]-1),match[2]);
  120. return false;
  121. }
  122. function formatDate (e) {
  123. if (this.value == "") match = false;
  124. if (this.value.match(/^(\d{6,8})/))
  125. match = this.value.match(/(\d{1,2}?)(\d{1,2})(\d{4,4})$/);
  126. else if (this.value.match(/^(\d{1,2}.{1}\d{1,2}.{1}\d{4})/))
  127. match = this.value.match(/^(\d{1,2}).{1}(\d{1,2}).{1}(\d{4})/);
  128. if (match) this.setDate(new Date(match[3],(match[1]-1),match[2]));
  129. $('#start-calendar, #end-calendar').hide();
  130. }
  131. function setDate(date,calendar) {
  132. $(this).val((date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear());
  133. if (calendar) {
  134. calendar.render(date.getMonth()+1,date.getDate(),date.getFullYear());
  135. calendar.selection = date;
  136. calendar.autoselect();
  137. }
  138. }
  139. var start = $('#start');
  140. var startdate = getDateInput(start);
  141. var StartCalendar = new PopupCalendar($('#start-calendar'));
  142. StartCalendar.scheduling = false;
  143. if (startdate) {
  144. StartCalendar.render(startdate.getMonth()+1,startdate.getDate(),startdate.getFullYear());
  145. StartCalendar.selection = startdate;
  146. StartCalendar.autoselect();
  147. } else StartCalendar.render();
  148. start.setDate = setDate;
  149. start.get(0).setDate = setDate;
  150. start.calendar = StartCalendar;
  151. start.change(formatDate);
  152. var end = $('#end');
  153. var enddate = getDateInput(end);
  154. var EndCalendar = new PopupCalendar($('#end-calendar'));
  155. EndCalendar.scheduling = false;
  156. if (enddate) {
  157. EndCalendar.render(enddate.getMonth()+1,enddate.getDate(),enddate.getFullYear());
  158. EndCalendar.selection = enddate;
  159. EndCalendar.autoselect();
  160. } else EndCalendar.render();
  161. end.setDate = setDate;
  162. end.get(0).setDate = setDate;
  163. end.calendar = EndCalendar;
  164. end.change(formatDate);
  165. var scpos = $('#start-position').offset();
  166. $('#start-calendar').hide()
  167. .css({left:scpos.left,
  168. top:scpos.top+$('#start-position').height()+10});
  169. $('#start').click(function (e) {
  170. $('#end-calendar').hide();
  171. $('#start-calendar').toggle();
  172. $(StartCalendar).change(function () {
  173. $('#start').val((StartCalendar.selection.getMonth()+1)+"/"+
  174. StartCalendar.selection.getDate()+"/"+
  175. StartCalendar.selection.getFullYear());
  176. });
  177. });
  178. var ecpos = $('#end-position').offset();
  179. $('#end-calendar').hide()
  180. .css({left:ecpos.left,
  181. top:ecpos.top+$('#end-position input').height()+10});
  182. $('#end').click(function (e) {
  183. $('#start-calendar').hide();
  184. $('#end-calendar').toggle();
  185. $(EndCalendar).change(function () {
  186. $('#end').val((EndCalendar.selection.getMonth()+1)+"/"+
  187. EndCalendar.selection.getDate()+"/"+
  188. EndCalendar.selection.getFullYear());
  189. });
  190. });
  191. $('#range').change(function () {
  192. if (this.selectedIndex == 0) {
  193. start.val(''); end.val('');
  194. $('#dates').addClass('hidden');
  195. return;
  196. } else $('#dates').removeClass('hidden');
  197. var today = new Date();
  198. var startdate = getDateInput($('#start'));
  199. var enddate = getDateInput($('#end'));
  200. if (!startdate) startdate = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  201. if (!enddate) enddate = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  202. today = new Date(today.getFullYear(),today.getMonth(),today.getDate());
  203. switch($(this).val()) {
  204. case 'week':
  205. startdate.setDate(today.getDate()-today.getDay());
  206. enddate = new Date(startdate.getFullYear(),startdate.getMonth(),startdate.getDate()+6);
  207. break;
  208. case 'month':
  209. startdate.setDate(1);
  210. enddate = new Date(startdate.getFullYear(),startdate.getMonth()+1,0);
  211. break;
  212. case 'quarter':
  213. quarter = Math.floor(today.getMonth()/3);
  214. startdate = new Date(today.getFullYear(),today.getMonth()-(today.getMonth()%3),1);
  215. enddate = new Date(today.getFullYear(),startdate.getMonth()+3,0);
  216. break;
  217. case 'year':
  218. startdate = new Date(today.getFullYear(),0,1);
  219. enddate = new Date(today.getFullYear()+1,0,0);
  220. break;
  221. case 'yesterday':
  222. startdate.setDate(today.getDate()-1);
  223. enddate.setDate(today.getDate()-1);
  224. break;
  225. case 'lastweek':
  226. startdate.setDate(today.getDate()-today.getDay()-7);
  227. enddate.setDate((today.getDate()-today.getDay()+6)-7);
  228. break;
  229. case 'last30':
  230. startdate.setDate(today.getDate()-30);
  231. enddate.setDate(today.getDate());
  232. break;
  233. case 'last90':
  234. startdate.setDate(today.getDate()-90);
  235. enddate.setDate(today.getDate());
  236. break;
  237. case 'lastmonth':
  238. startdate = new Date(today.getFullYear(),today.getMonth()-1,1);
  239. enddate = new Date(today.getFullYear(),today.getMonth(),0);
  240. break;
  241. case 'lastquarter':
  242. startdate = new Date(today.getFullYear(),(today.getMonth()-(today.getMonth()%3))-3,1);
  243. enddate = new Date(today.getFullYear(),startdate.getMonth()+3,0);
  244. break;
  245. case 'lastyear':
  246. startdate = new Date(today.getFullYear()-1,0,1);
  247. enddate = new Date(today.getFullYear(),0,0);
  248. break;
  249. case 'lastexport':
  250. startdate = lastexport;
  251. enddate = today;
  252. break;
  253. case 'custom': break;
  254. }
  255. start.setDate(startdate,StartCalendar); end.setDate(enddate,EndCalendar);
  256. }).change();
  257. $('#export-settings-button').click(function () { $('#export-settings-button').hide(); $('#export-settings').removeClass('hidden'); });
  258. $('#selectall_columns').change(function () {
  259. if ($(this).attr('checked')) $('#export-columns input').not(this).attr('checked',true);
  260. else $('#export-columns input').not(this).attr('checked',false);
  261. });
  262. <?php if (SHOPP_WP27): ?>
  263. pagenow = 'shopp_page_shopp-customers';
  264. columns.init(pagenow);
  265. <?php endif; ?>
  266. });
  267. </script>