PageRenderTime 60ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

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

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