PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/wp-e-commerce/admin-form-functions.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 992 lines | 795 code | 115 blank | 82 comment | 81 complexity | 722d8edee50b75fccf02fca18365745a MD5 | raw file
  1. <?php
  2. // ini_set('display_errors','1');
  3. function nzshpcrt_getcategoryform($catid)
  4. {
  5. global $wpdb,$nzshpcrt_imagesize_info;
  6. $product = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `id`=$catid LIMIT 1",ARRAY_A);
  7. $output = '';
  8. $output .= "<div class='editing_this_group form_table'>";
  9. $output .= "<p>".str_replace("[categorisation]", htmlentities(stripslashes($product['name'])), __('You are editing the &quot;[categorisation]&quot; Category', 'wpsc'))."</p>\n\r";
  10. $output .= "<p><a href='' onclick='return showaddform()' class='add_category_link'><span>".str_replace("&quot;[categorisation]&quot;", "current", __('+ Add new category to the &quot;[categorisation]&quot; Group', 'wpsc'))."</span></a></p>";
  11. $output .="<dl>\n\r";
  12. $output .=" <dt>Display Category Shortcode: </dt>\n\r";
  13. $output .=" <dd> [wpsc_products category_url_name='{$product['nice-name']}']</dd>\n\r";
  14. $output .=" <dt>Display Category Template Tag: </dt>\n\r";
  15. $output .=" <dd> &lt;?php echo wpsc_display_products_page(array('category_url_name'=>'{$product['nice-name']}')); ?&gt;</dd>\n\r";
  16. $output .="</dl>\n\r";
  17. //$output .= " [ <a href='#' onclick='return showedit_categorisation_form()'>".__('Edit This Group', 'wpsc')."</a> ]";
  18. $output .= "</div>";
  19. $output .= " <table class='category_forms'>\n\r";
  20. $output .= " <tr>\n\r";
  21. $output .= " <td>\n\r";
  22. $output .= __('Name', 'wpsc').": ";
  23. $output .= " </td>\n\r";
  24. $output .= " <td>\n\r";
  25. $output .= "<input type='text' class='text' name='title' value='".htmlentities(stripslashes($product['name']), ENT_QUOTES, 'UTF-8')."' />";
  26. $output .= " </td>\n\r";
  27. $output .= " </tr>\n\r";
  28. $output .= " <tr>\n\r";
  29. $output .= " <td>\n\r";
  30. $output .= __('Description', 'wpsc').": ";
  31. $output .= " </td>\n\r";
  32. $output .= " <td>\n\r";
  33. $output .= "<textarea name='description' cols='40' rows='8' >".stripslashes($product['description'])."</textarea>";
  34. $output .= " </td>\n\r";
  35. $output .= " </tr>\n\r";
  36. $output .= " </tr>\n\r";
  37. $output .= " <tr>\n\r";
  38. $output .= " <td>\n\r";
  39. $output .= __('Category Parent', 'wpsc').": ";
  40. $output .= " </td>\n\r";
  41. $output .= " <td>\n\r";
  42. $output .= wpsc_parent_category_list($product['group_id'], $product['id'], $product['category_parent']);
  43. $output .= " </td>\n\r";
  44. $output .= " </tr>\n\r";
  45. $output .= " </tr>\n\r";
  46. if ($product['display_type'] == 'grid') {
  47. $display_type1="selected='selected'";
  48. } else if ($product['display_type'] == 'default') {
  49. $display_type2="selected='selected'";
  50. }
  51. switch($product['display_type']) {
  52. case "default":
  53. $product_view1 = "selected ='selected'";
  54. break;
  55. case "grid":
  56. if(function_exists('product_display_grid')) {
  57. $product_view3 = "selected ='selected'";
  58. break;
  59. }
  60. case "list":
  61. if(function_exists('product_display_list')) {
  62. $product_view2 = "selected ='selected'";
  63. break;
  64. }
  65. default:
  66. $product_view0 = "selected ='selected'";
  67. break;
  68. }
  69. $output .= " <tr>\n\r";
  70. $output .= " <td>\n\r";
  71. $output .= __('Category&nbsp;Image', 'wpsc').": ";
  72. $output .= " </td>\n\r";
  73. $output .= " <td>\n\r";
  74. $output .= "<input type='file' name='image' value='' />";
  75. $output .= " </td>\n\r";
  76. $output .= " </tr>\n\r";
  77. $output .= " </tr>\n\r";
  78. if(function_exists("getimagesize")) {
  79. if($product['image'] != '') {
  80. $imagepath = WPSC_CATEGORY_DIR . $product['image'];
  81. $imagetype = @getimagesize($imagepath); //previously exif_imagetype()
  82. $output .= " <tr>\n\r";
  83. $output .= " <td>\n\r";
  84. $output .= " </td>\n\r";
  85. $output .= " <td>\n\r";
  86. $output .= __('Height', 'wpsc').":<input type='text' size='6' name='height' value='".$imagetype[1]."' /> ".__('Width', 'wpsc').":<input type='text' size='6' name='width' value='".$imagetype[0]."' /><br /><span class='wpscsmall description'>$nzshpcrt_imagesize_info</span><br />\n\r";
  87. $output .= "<span class='wpscsmall description'>".__('You can upload thumbnail images for each group. To display Group details in your shop you must configure these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc')."</span>\n\r";
  88. $output .= " </td>\n\r";
  89. $output .= " </tr>\n\r";
  90. } else {
  91. $output .= " <tr>\n\r";
  92. $output .= " <td>\n\r";
  93. $output .= " </td>\n\r";
  94. $output .= " <td>\n\r";
  95. $output .= __('Height', 'wpsc').":<input type='text' size='6' name='height' value='".get_option('product_image_height')."' /> ".__('Width', 'wpsc').":<input type='text' size='6' name='width' value='".get_option('product_image_width')."' /><br /><span class='wpscsmall description'>$nzshpcrt_imagesize_info</span><br />\n\r";
  96. $output .= "<span class='wpscsmall description'>".__('You can upload thumbnail images for each group. To display Group details in your shop you must configure these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc')."</span>\n\r";
  97. $output .= " </td>\n\r";
  98. $output .= " </tr>\n\r";
  99. }
  100. }
  101. $output .= " <tr>\n\r";
  102. $output .= " <td>\n\r";
  103. $output .= __('Delete Image', 'wpsc').": ";
  104. $output .= " </td>\n\r";
  105. $output .= " <td>\n\r";
  106. $output .= "<input type='checkbox' name='deleteimage' value='1' />";
  107. $output .= " </td>\n\r";
  108. $output .= " </tr>\n\r";
  109. $output .= " </tr>\n\r";
  110. /* START OF TARGET MARKET SELECTION */
  111. $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A);
  112. $selectedCountries = $wpdb->get_col("SELECT countryid FROM `".WPSC_TABLE_CATEGORY_TM."` WHERE categoryid=".$product['id']." AND visible= 1");
  113. // exit('<pre>'.print_r($countrylist,true).'</pre><br /><pre>'.print_r($selectedCountries,true).'</pre>');
  114. $output .= " <tr>\n\r";
  115. $output .= " <td colspan='2'><h4>Target Market Restrictions</h4></td></tr><tr><td>&nbsp;</td></tr><tr>\n\r";
  116. $output .= " <td>\n\r";
  117. $output .= __('Target Markets', 'wpsc').":\n\r";
  118. $output .= " </td>\n\r";
  119. $output .= " <td>\n\r";
  120. if(@extension_loaded('suhosin')) {
  121. $output .= "<em>".__("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.
  122. ",'wpsc')."</em>";
  123. } else {
  124. $output .= "<span>Select: <a href='' class='wpsc_select_all'>All</a>&nbsp; <a href='' class='wpsc_select_none'>None</a></span><br />";
  125. $output .= " <div id='resizeable' class='ui-widget-content multiple-select'>\n\r";
  126. foreach($countrylist as $country){
  127. if(in_array($country['id'], $selectedCountries))
  128. /* if($country['visible'] == 1) */{
  129. $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' checked='".$country['visible']."' />".$country['country']."<br />\n\r";
  130. }else{
  131. $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' />".$country['country']."<br />\n\r";
  132. }
  133. }
  134. $output .= " </div><br /><br />";
  135. $output .= " <span class='wpscsmall description'>Select the markets you are selling this category to.<span>\n\r";
  136. }
  137. $output .= " </td>\n\r";
  138. $output .= " </tr>\n\r";
  139. ////////
  140. $output .= " <tr>\n\r";
  141. $output .= " <td colspan='2' class='category_presentation_settings'>\n\r";
  142. $output .= " <h4>".__('Presentation Settings', 'wpsc')."</h4>\n\r";
  143. $output .= " <span class='small'>".__('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc')."</span>\n\r";
  144. $output .= " </td>\n\r";
  145. $output .= " </tr>\n\r";
  146. $output .= " <tr>\n\r";
  147. $output .= " <td>\n\r";
  148. $output .= " ". __('Catalog View', 'wpsc').":\n\r";
  149. $output .= " </td>\n\r";
  150. $output .= " <td>\n\r";
  151. $output .= " <select name='display_type'>\n\r";
  152. $output .= " <option value='' $product_view0 >".__('Please select', 'wpsc')."</option>\n\r";
  153. $output .= " <option value='default' $product_view1 >".__('Default View', 'wpsc')."</option>\n\r";
  154. if(function_exists('product_display_list')) {
  155. $output .= " <option value='list' ". $product_view2.">". __('List View', 'wpsc')."</option>\n\r";
  156. } else {
  157. $output .= " <option value='list' disabled='disabled' ". $product_view2.">". __('List View', 'wpsc')."</option>\n\r";
  158. }
  159. if(function_exists('product_display_grid')) {
  160. $output .= " <option value='grid' ". $product_view3.">". __('Grid View', 'wpsc')."</option>\n\r";
  161. } else {
  162. $output .= " <option value='grid' disabled='disabled' ". $product_view3.">". __('Grid View', 'wpsc')."</option>\n\r";
  163. }
  164. $output .= " </select>\n\r";
  165. $output .= " </td>\n\r";
  166. $output .= " </tr>\n\r";
  167. if(function_exists("getimagesize")) {
  168. $output .= " <tr>\n\r";
  169. $output .= " <td>\n\r";
  170. $output .= __('Thumbnail&nbsp;Size', 'wpsc').": ";
  171. $output .= " </td>\n\r";
  172. $output .= " <td>\n\r";
  173. $output .= __('Height', 'wpsc').": <input type='text' value='".$product['image_height']."' name='product_height' size='6'/> ";
  174. $output .= __('Width', 'wpsc').": <input type='text' value='".$product['image_width']."' name='product_width' size='6'/> <br/>";
  175. $output .= " </td>\n\r";
  176. $output .= " </tr>\n\r";
  177. }
  178. $output .= " <tr>\n\r";
  179. $output .= " <td colspan='2' class='category_presentation_settings'>\n\r";
  180. $output .= " <h4>".__('Checkout Settings', 'wpsc')."</h4>\n\r";
  181. //$output .= " <span class='small'>".__('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc')."</span>\n\r";
  182. $output .= " </td>\n\r";
  183. $output .= " </tr>\n\r";
  184. $used_additonal_form_set = wpsc_get_categorymeta($product['id'], 'use_additonal_form_set');
  185. $output .= " <tr>\n\r";
  186. $output .= " <td>\n\r";
  187. $output .= __("This category requires additional checkout form fields",'wpsc').": ";
  188. $output .= " </td>\n\r";
  189. $output .= " <td>\n\r";
  190. $output .= " <select name='use_additonal_form_set'>\n\r";
  191. $output .= " <option value=''>".__("None",'wpsc')."</option>\n\r";
  192. $checkout_sets = get_option('wpsc_checkout_form_sets');
  193. unset($checkout_sets[0]);
  194. foreach((array)$checkout_sets as $key => $value) {
  195. $selected_state = "";
  196. if($used_additonal_form_set == $key) {
  197. $selected_state = "selected='selected'";
  198. }
  199. $output .= " <option {$selected_state} value='{$key}'>".stripslashes($value)."</option>\n\r";
  200. }
  201. $output .= " </select>\n\r";
  202. //$output .= " <label><input type='radio' value='1' name='uses_additonal_forms' ".(($uses_additional_forms == true) ? "checked='checked'" : "")." />".__("Yes",'wpsc')."</label>";
  203. //$output .= " <label><input type='radio' value='0' name='uses_additonal_forms' ".(($uses_additional_forms != true) ? "checked='checked'" : "")." />".__("No",'wpsc')."</label>";
  204. $output .= " </td>\n\r";
  205. $output .= " </tr>\n\r";
  206. $output .= " <tr>";
  207. $output .= " <td colspan='2'> </td>";
  208. $output .= " </tr>";
  209. $uses_billing_address = (bool)wpsc_get_categorymeta($product['id'], 'uses_billing_address');
  210. $output .= " <tr>\n\r";
  211. $output .= " <td>\n\r";
  212. $output .= __("Products in this category use the billing address to calculate shipping",'wpsc').": ";
  213. $output .= " </td>\n\r";
  214. $output .= " <td>\n\r";
  215. $output .= " <label><input type='radio' value='1' name='uses_billing_address' ".(($uses_billing_address == true) ? "checked='checked'" : "")." />".__("Yes",'wpsc')."</label>";
  216. $output .= " <label><input type='radio' value='0' name='uses_billing_address' ".(($uses_billing_address != true) ? "checked='checked'" : "")." />".__("No",'wpsc')."</label>";
  217. $output .= " </td>\n\r";
  218. $output .= " </tr>\n\r";
  219. $output .= " <tr>\n\r";
  220. $output .= " <td>\n\r";
  221. $output .= " </td>\n\r";
  222. $output .= " <td class='last_row'>\n\r";
  223. $output .= "<input type='hidden' name='prodid' value='".$product['id']."' />";
  224. $output .= "<input type='hidden' name='submit_action' value='edit' />";
  225. $output .= "<input class='button-primary' style='float:left;' type='submit' name='submit' value='".__('Update Category', 'wpsc')."' />";
  226. $output .= "<a class='delete_button' href='".add_query_arg('deleteid', $product['id'], 'admin.php?page=wpsc-edit-groups')."' onclick=\"return conf();\" >".__('Delete', 'wpsc')."</a>";
  227. $output .= " </td>\n\r";
  228. $output .= " </tr>\n\r";
  229. $output .= " </table>\n\r";
  230. return $output;
  231. }
  232. function nzshpcrt_getvariationform($variation_id)
  233. {
  234. global $wpdb,$nzshpcrt_imagesize_info;
  235. $variation_sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."` WHERE `id`='$variation_id' LIMIT 1";
  236. $variation_data = $wpdb->get_results($variation_sql,ARRAY_A) ;
  237. $variation = $variation_data[0];
  238. $output .= " <table class='category_forms' >\n\r";
  239. $output .= " <tr>\n\r";
  240. $output .= " <td>\n\r";
  241. $output .= __('Name', 'wpsc').": ";
  242. $output .= " </td>\n\r";
  243. $output .= " <td>\n\r";
  244. $output .= "<input type='text' class='text' name='title' value='".htmlentities(stripslashes($variation['name']), ENT_QUOTES, 'UTF-8')."' />";
  245. $output .= " </td>\n\r";
  246. $output .= " </tr>\n\r";
  247. $output .= " <tr>\n\r";
  248. $output .= " <td>\n\r";
  249. $output .= __('Variation Values', 'wpsc').": ";
  250. $output .= " </td>\n\r";
  251. $output .= " <td>\n\r";
  252. $variation_values_sql = "SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `variation_id`='$variation_id' ORDER BY `id` ASC";
  253. $variation_values = $wpdb->get_results($variation_values_sql,ARRAY_A);
  254. $variation_value_count = count($variation_values);
  255. $output .= "<div id='edit_variation_values'>";
  256. $num = 0;
  257. foreach($variation_values as $variation_value) {
  258. $output .= "<span class='variation_value'>";
  259. $output .= "<input type='text' class='text' name='variation_values[".$variation_value['id']."]' value='".htmlentities(stripslashes($variation_value['name']), ENT_QUOTES, 'UTF-8')."' />";
  260. if($variation_value_count > 1) {
  261. $output .= " <a class='image_link' onclick='return remove_variation_value(this,".$variation_value['id'].")' href='#'><img src='".WPSC_URL."/images/trash.gif' alt='".__('Delete', 'wpsc')."' title='".__('Delete', 'wpsc')."' /></a>";
  262. }
  263. $output .= "<br />";
  264. $output .= "</span>";
  265. $num++;
  266. }
  267. $output .= "</div>";
  268. $output .= "<a href='#' onclick='return add_variation_value(\"edit\")'>".__('Add', 'wpsc')."</a>";
  269. $output .= " </td>\n\r";
  270. $output .= " </tr>\n\r";
  271. $output .= " </tr>\n\r";
  272. $output .= " <tr>\n\r";
  273. $output .= " <td>\n\r";
  274. $output .= " </td>\n\r";
  275. $output .= " <td>\n\r";
  276. $output .= "<input type='hidden' name='prodid' value='".$variation['id']."' />";
  277. $output .= "<input type='hidden' name='submit_action' value='edit' />";
  278. $output .= "<input class='button' style='float:left;' type='submit' name='submit' value='".__('Edit', 'wpsc')."' />";
  279. $output .= "<a class='button delete_button' href='admin.php?page=".WPSC_DIR_NAME."/display_variations.php&amp;deleteid=".$variation['id']."' onclick=\"return conf();\" >".__('Delete', 'wpsc')."</a>";
  280. $output .= " </td>\n\r";
  281. $output .= " </tr>\n\r";
  282. $output .= " </table>\n\r";
  283. return $output;
  284. }
  285. function coupon_edit_form($coupon) {
  286. $conditions = unserialize($coupon['condition']);
  287. //exit('<pre>'.print_r($coupon, true).'</pre>');
  288. $start_timestamp = strtotime($coupon['start']);
  289. $end_timestamp = strtotime($coupon['expiry']);
  290. $id = $coupon['id'];
  291. $output = '';
  292. $output .= "<form class='displaynone' name='edit_coupon' id='".$coupon['coupon_code']."' method='post' action=''>\n\r";
  293. $output .= " <input type='hidden' value='true' name='is_edit_coupon' />\n\r";
  294. $output .= "<table class='add-coupon'>\n\r";
  295. $output .= " <tr>\n\r";
  296. $output .= " <th>".__('Coupon Code', 'wpsc')."</th>\n\r";
  297. $output .= " <th>".__('Discount', 'wpsc')."</th>\n\r";
  298. $output .= " <th>".__('Start', 'wpsc')."</th>\n\r";
  299. $output .= " <th>".__('Expiry', 'wpsc')."</th>\n\r";
  300. $output .= " <th>".__('Use Once', 'wpsc')."</th>\n\r";
  301. $output .= " <th>".__('Active', 'wpsc')."</th>\n\r";
  302. $output .= " <th>".__('Apply On All Products', 'wpsc')."</th>\n\r";
  303. $output .= " <th></th>\n\r";
  304. $output .= " </tr>\n\r";
  305. $output .= " <tr>\n\r";
  306. $output .= " <td>\n\r";
  307. $output .= " <input type='text' size='8' value='".$coupon['coupon_code']."' name='edit_coupon[".$id."][coupon_code]' />\n\r";
  308. $output .= " </td>\n\r";
  309. $output .= " <td>\n\r";
  310. $output .= " <input type='text' style='width:28px;' value='".$coupon['value']."' name=edit_coupon[".$id."][value]' />";
  311. $output .= " <select style='width:20px;' name='edit_coupon[".$id."][is-percentage]'>";
  312. $output .= " <option value='0' ".(($coupon['is-percentage'] == 0) ? "selected='true'" : '')." >$</option>\n\r";//
  313. $output .= " <option value='1' ".(($coupon['is-percentage'] == 1) ? "selected='true'" : '')." >%</option>\n\r";
  314. $output .= " <option value='2' ".(($coupon['is-percentage'] == 2) ? "selected='true'" : '')." >Free shipping</option>\n\r";
  315. $output .= " </select>\n\r";
  316. $output .= " </td>\n\r";
  317. $output .= " <td>\n\r";
  318. $coupon_start = explode(" ",$coupon['start']);
  319. $output .= "<input type='text' class='pickdate' size='8' name='edit_coupon[".$id."][start]' value='{$coupon_start[0]}'>";
  320. /* $output .= " <select name='edit_coupon[".$id."][start][day]'>\n\r";
  321. for($i = 1; $i <=31; ++$i) {
  322. $selected = '';
  323. if($i == date("d", $start_timestamp)) { $selected = "selected='true'"; }
  324. $output .= " <option $selected value='$i'>$i</option>";
  325. }
  326. $output .= " </select>\n\r";
  327. $output .= " <select name='edit_coupon[".$id."][start][month]'>\n\r";
  328. for($i = 1; $i <=12; ++$i) {
  329. $selected = '';
  330. if($i == (int)date("m", $start_timestamp)) { $selected = "selected='true'"; }
  331. $output .= " <option $selected value='$i'>".date("M",mktime(0, 0, 0, $i, 1, date("Y")))."</option>";
  332. }
  333. $output .= " </select>\n\r";
  334. $output .= " <select name='edit_coupon[".$id."][start][year]'>\n\r";
  335. for($i = date("Y"); $i <= (date("Y") +12); ++$i) {
  336. $selected = '';
  337. if($i == date("Y", $start_timestamp)) { $selected = "selected='true'"; }
  338. $output .= " <option $selected value='$i'>".$i."</option>";
  339. }
  340. $output .= " </select>\n\r";*/
  341. $output .= " </td>\n\r";
  342. $output .= " <td>\n\r";
  343. $coupon_expiry = explode(" ",$coupon['expiry']);
  344. $output .= "<input type='text' class='pickdate' size='8' name='edit_coupon[".$id."][expiry]' value='{$coupon_expiry[0]}'>";
  345. /*$output .= " <select name='edit_coupon[".$id."][expiry][day]'>\n\r";
  346. for($i = 1; $i <=31; ++$i) {
  347. $selected = '';
  348. if($i == date("d", $end_timestamp)) { $selected = "selected='true'"; }
  349. $output .= " <option $selected value='$i'>$i</option>";
  350. }
  351. $output .= " </select>\n\r";
  352. $output .= " <select name='edit_coupon[".$id."][expiry][month]'>\n\r";
  353. for($i = 1; $i <=12; ++$i) {
  354. $selected = '';
  355. if($i == (int)date("m", $end_timestamp)) { $selected = "selected='true'"; }
  356. $output .= " <option $selected value='$i'>".date("M",mktime(0, 0, 0, $i, 1, date("Y")))."</option>";
  357. }
  358. $output .= " </select>\n\r";
  359. $output .= " <select name='edit_coupon[".$id."][expiry][year]'>\n\r";
  360. for($i = date("Y"); $i <= (date("Y") +12); ++$i) {
  361. $selected = '';
  362. if($i == (date("Y", $end_timestamp))) { $selected = "selected='true'"; }
  363. $output .= " <option $selected value='$i'>".$i."</option>\n\r";
  364. }
  365. $output .= " </select>\n\r";*/
  366. $output .= " </td>\n\r";
  367. $output .= " <td>\n\r";
  368. $output .= " <input type='hidden' value='0' name='edit_coupon[".$id."][use-once]' />\n\r";
  369. $output .= " <input type='checkbox' value='1' ".(($coupon['use-once'] == 1) ? "checked='checked'" : '')." name='edit_coupon[".$id."][use-once]' />\n\r";
  370. $output .= " </td>\n\r";
  371. $output .= " <td>\n\r";
  372. $output .= " <input type='hidden' value='0' name='edit_coupon[".$id."][active]' />\n\r";
  373. $output .= " <input type='checkbox' value='1' ".(($coupon['active'] == 1) ? "checked='checked'" : '')." name='edit_coupon[".$id."][active]' />\n\r";
  374. $output .= " </td>\n\r";
  375. $output .= " <td>\n\r";
  376. $output .= " <input type='hidden' value='0' name='edit_coupon[".$id."][every_product]' />\n\r";
  377. $output .= " <input type='checkbox' value='1' ".(($coupon['every_product'] == 1) ? "checked='checked'" : '')." name='edit_coupon[".$id."][every_product]' />\n\r";
  378. $output .= " </td>\n\r";
  379. $output .= " <td>\n\r";
  380. $output .= " <input type='hidden' value='".$id."' name='edit_coupon[".$id."][id]' />\n\r";
  381. //$output .= " <input type='hidden' value='false' name='add_coupon' />\n\r";
  382. /*
  383. $output .= " <input type='submit' value='".__('Update Coupon', 'wpsc')."' name='edit_coupon[".$id."][submit_coupon]' />\n\r";
  384. $output .= " <input type='submit' value='".__('Delete Coupon', 'wpsc')."' name='edit_coupon[".$id."][delete_coupon]' />\n\r";
  385. */
  386. $output .= " </td>\n\r";
  387. $output .= " </tr>\n\r";
  388. if($conditions != null){
  389. $output .= "<tr>";
  390. $output .= "<th>";
  391. $output .= "Conditions";
  392. $output .= "</th>";
  393. $output .= "</tr>";
  394. $output .= "<th>";
  395. $output .= "Delete";
  396. $output .= "</th>";
  397. $output .= "<th>";
  398. $output .= "Property";
  399. $output .= "</th>";
  400. $output .= "<th>";
  401. $output .= "Logic";
  402. $output .= "</th>";
  403. $output .= "<th>";
  404. $output .= "Value";
  405. $output .= "</th>";
  406. $output .= " </tr>\n\r";
  407. $i=0;
  408. foreach ($conditions as $condition){
  409. $output .= "<tr>";
  410. $output .= "<td>";
  411. $output .= "<input type='hidden' name='coupon_id' value='".$id."' />";
  412. $output .= "<input type='submit' id='delete_condition".$i."' style='display:none;' value='".$i."' name='delete_condition' />";
  413. $output .= "<span style='cursor:pointer;' class='delete_button' onclick='jQuery(\"#delete_condition".$i."\").click()'>Delete</span>";
  414. $output .= "</td>";
  415. $output .= "<td>";
  416. $output .= $condition['property'];
  417. $output .= "</td>";
  418. $output .= "<td>";
  419. $output .= $condition['logic'];
  420. $output .= "</td>";
  421. $output .= "<td>";
  422. $output .= $condition['value'];
  423. $output .= "</td>";
  424. $output .= "</tr>";
  425. $i++;
  426. }
  427. $output .= wpsc_coupons_conditions( $id);
  428. }elseif($conditions == null){
  429. $output .= wpsc_coupons_conditions( $id);
  430. }
  431. ?>
  432. <!--
  433. <tr><td colspan="8">
  434. <div class="coupon_condition">
  435. <div><img height="16" width="16" class="delete" alt="Delete" src="<?=WPSC_URL?>/images/cross.png"/></button>
  436. <select class="ruleprops" name="rules[property][]">
  437. <option value="item_name" rel="order">Item name</option>
  438. <option value="item_quantity" rel="order">Item quantity</option>
  439. <option value="total_quantity" rel="order">Total quantity</option>
  440. <option value="subtotal_amount" rel="order">Subtotal amount</option>
  441. </select>
  442. <select name="rules[logic][]">
  443. <option value="equal">Is equal to</option>
  444. <option value="greater">Is greater than</option>
  445. <option value="less">Is less than</option>
  446. <option value="contains">Contains</option>
  447. <option value="not_contain">Does not contain</option>
  448. <option value="begins">Begins with</option>
  449. <option value="ends">Ends with</option>
  450. </select>
  451. <span>
  452. <input type="text" name="rules[value][]"/>
  453. </span>
  454. <span>
  455. <button class="add" type="button">
  456. <img height="16" width="16" alt="Add" src="<?php //WPSC_URL?>/images/add.png"/>
  457. </button>
  458. </span>
  459. </div>
  460. </div>
  461. </tr>
  462. -->
  463. <?php
  464. $output .= "</table>\n\r";
  465. $output .= "</form>\n\r";
  466. echo $output;
  467. return $output;
  468. }
  469. function wpsc_coupons_conditions($id){
  470. ?>
  471. <?php
  472. $output ='
  473. <input type="hidden" name="coupon_id" value="'.$id.'" />
  474. <tr><td colspan="3"><b>Add Conditions</b></td></tr>
  475. <tr><td colspan="6">
  476. <div class="coupon_condition">
  477. <div>
  478. <select class="ruleprops" name="rules[property][]">
  479. <option value="item_name" rel="order">Item name</option>
  480. <option value="item_quantity" rel="order">Item quantity</option>
  481. <option value="total_quantity" rel="order">Total quantity</option>
  482. <option value="subtotal_amount" rel="order">Subtotal amount</option>
  483. ' . apply_filters( 'wpsc_coupon_rule_property_options', '' ) . '
  484. </select>
  485. <select name="rules[logic][]">
  486. <option value="equal">Is equal to</option>
  487. <option value="greater">Is greater than</option>
  488. <option value="less">Is less than</option>
  489. <option value="contains">Contains</option>
  490. <option value="not_contain">Does not contain</option>
  491. <option value="begins">Begins with</option>
  492. <option value="ends">Ends with</option>
  493. </select>
  494. <span>
  495. <input type="text" name="rules[value][]"/>
  496. </span>
  497. </div>
  498. </div>
  499. </td>
  500. <td colspan="3">
  501. <input type="submit" value="'.__("Update Coupon", "wpsc").'" name="edit_coupon['.$id.'][submit_coupon]" />
  502. <input type="submit" value="'.__("Delete Coupon", "wpsc").'" name="edit_coupon['.$id.'][delete_coupon]" />
  503. </td>
  504. </tr>
  505. ';
  506. return $output;
  507. }
  508. function setting_button(){
  509. $next_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']."?page=wpsc-edit-products";
  510. // $output.="<div><img src='".get_option('siteurl')."/wp-content/plugins/".WPSC_DIR_NAME."/images/settings_button.jpg' onclick='display_settings_button()'>";
  511. $output.="<div style='float: right; margin-top: 0px; position: relative;'> | <a href='#' onclick='display_settings_button(); return false;' style='text-decoration: underline;'>".__('Settings', 'wpsc')." &raquo;</a>";
  512. $output.="<span id='settings_button' style='width:180px;background-color:#f1f1f1;position:absolute; right: 10px; border:1px solid black; display:none;'>";
  513. $output.="<ul class='settings_button'>";
  514. $output.="<li><a href='admin.php?page=wpsc-settings'>".__('Shop Settings', 'wpsc')."</a></li>";
  515. $output.="<li><a href='admin.php?page=wpsc-settings&amp;tab=gateway'>".__('Money and Payment', 'wpsc')."</a></li>";
  516. $output.="<li><a href='admin.php?page=wpsc-settings&amp;tab=checkout'>".__('Checkout Page Settings', 'wpsc')."</a></li>";
  517. //$output.="<li><a href='?page=".WPSC_DIR_NAME."/instructions.php'>Help/Upgrade</a></li>";
  518. $output.="</ul>";
  519. // $output.="<div>Checkout Settings</div>";
  520. $output.="</span>&emsp;&emsp;</div>";
  521. return $output;
  522. }
  523. function wpsc_right_now($hidden = '') {
  524. global $wpdb,$nzshpcrt_imagesize_info;
  525. $year = date("Y");
  526. $month = date("m");
  527. $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
  528. $end_timestamp = mktime(0, 0, 0, ($month+1), 0, $year);
  529. $replace_values[":productcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `active` IN ('1')");
  530. $product_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `active` IN ('1')");
  531. $replace_values[":productcount:"] .= " ".(($replace_values[":productcount:"] == 1) ? __('product', 'wpsc') : __('products', 'wpsc'));
  532. $product_unit = (($replace_values[":productcount:"] == 1) ? __('product', 'wpsc') : __('products', 'wpsc'));
  533. $replace_values[":groupcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1')");
  534. $group_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1')");
  535. $replace_values[":groupcount:"] .= " ".(($replace_values[":groupcount:"] == 1) ? __('group', 'wpsc') : __('groups', 'wpsc'));
  536. $group_unit = (($replace_values[":groupcount:"] == 1) ? __('group', 'wpsc') : __('groups', 'wpsc'));
  537. $replace_values[":salecount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '".$start_timestamp."' AND '".$end_timestamp."'");
  538. $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '".$start_timestamp."' AND '".$end_timestamp."'");
  539. $replace_values[":salecount:"] .= " ".(($replace_values[":salecount:"] == 1) ? __('sale', 'wpsc') : __('sales', 'wpsc'));
  540. $sales_unit = (($replace_values[":salecount:"] == 1) ? __('sale', 'wpsc') : __('sales', 'wpsc'));
  541. $replace_values[":monthtotal:"] = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1);
  542. $replace_values[":overaltotal:"] = nzshpcrt_currency_display(admin_display_total_price(),1);
  543. $variation_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."`");
  544. $variation_unit = (($variation_count == 1) ? __('variation', 'wpsc') : __('variations', 'wpsc'));
  545. $replace_values[":pendingcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN ('1')");
  546. $pending_sales = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN ('1')");
  547. $replace_values[":pendingcount:"] .= " " . (($replace_values[":pendingcount:"] == 1) ? __('transaction', 'wpsc') : __('transactions', 'wpsc'));
  548. $pending_sales_unit = (($replace_values[":pendingcount:"] == 1) ? __('transaction', 'wpsc') : __('transactions', 'wpsc'));
  549. $accept_sales = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN ('2' ,'3', '4')");
  550. $accept_sales_unit = (($accept_sales == 1) ? __('transaction', 'wpsc') : __('transactions', 'wpsc'));
  551. $replace_values[":theme:"] = get_option('wpsc_selected_theme');
  552. $replace_values[":versionnumber:"] = WPSC_PRESENTABLE_VERSION;
  553. if (function_exists('add_object_page')) {
  554. $output="";
  555. $output.="<div id='dashboard_right_now' class='postbox ".((array_search('dashboard_right_now', $hidden) !== false) ? 'closed' : '')."'>";
  556. $output.=" <h3 class='hndle'>";
  557. $output.=" <span>".__('Current Month', 'wpsc')."</span>";
  558. $output.=" <br class='clear'/>";
  559. $output.=" </h3>";
  560. $output .= "<div class='inside'>";
  561. $output .= "<p class='sub'>".__('At a Glance', 'wpsc')."</p>";
  562. //$output.="<p class='youhave'>".__('You have <a href='admin.php?page=wpsc-edit-products'>:productcount:</a>, contained within <a href='admin.php?page=wpsc-edit-groups'>:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc')."</p>";
  563. $output .= "<div class='table'>";
  564. $output .= "<table>";
  565. $output .= "<tr class='first'>";
  566. $output .= "<td class='first b'>";
  567. $output .= "<a href='?page=wpsc-edit-products'>".$product_count."</a>";
  568. $output .= "</td>";
  569. $output .= "<td class='t'>";
  570. $output .= ucfirst($product_unit);
  571. $output .= "</td>";
  572. $output .= "<td class='b'>";
  573. $output .= "<a href='?page=wpsc-sales-logs'>".$sales_count."</a>";
  574. $output .= "</td>";
  575. $output .= "<td class='last'>";
  576. $output .= ucfirst($sales_unit);
  577. $output .= "</td>";
  578. $output .= "</tr>";
  579. $output .= "<tr>";
  580. $output .= "<td class='first b'>";
  581. $output .= "<a href='?page=wpsc-edit-groups'>".$group_count."</a>";
  582. $output .= "</td>";
  583. $output .= "<td class='t'>";
  584. $output .= ucfirst($group_unit);
  585. $output .= "</td>";
  586. $output .= "<td class='b'>";
  587. $output .= "<a href='?page=wpsc-sales-logs'>".$pending_sales."</a>";
  588. $output .= "</td>";
  589. $output .= "<td class='last t waiting'>".__('Pending', 'wpsc')." ";
  590. $output .= ucfirst($pending_sales_unit);
  591. $output .= "</td>";
  592. $output .= "</tr>";
  593. $output .= "<tr>";
  594. $output .= "<td class='first b'>";
  595. $output .= "<a href='?page=wpsc-edit-variations'>".$variation_count."</a>";
  596. $output .= "</td>";
  597. $output .= "<td class='t'>";
  598. $output .= ucfirst($variation_unit);
  599. $output .= "</td>";
  600. $output .= "<td class='b'>";
  601. $output .= "<a href='?page=wpsc-sales-logs'>".$accept_sales."</a>";
  602. $output .= "</td>";
  603. $output .= "<td class='last t approved'>".__('Closed', 'wpsc')." ";
  604. $output .= ucfirst($accept_sales_unit);
  605. $output .= "</td>";
  606. $output .= "</tr>";
  607. $output .= "</table>";
  608. $output .= "</div>";
  609. $output .= "<div class='versions'>";
  610. $output .= "<p><a class='button rbutton' href='admin.php?page=wpsc-edit-products'><strong>".__('Add New Product', 'wpsc')."</strong></a>".__('Here you can add products, groups or variations', 'wpsc')."</p>";
  611. $output .= "</div>";
  612. $output .= "</div>";
  613. $output.="</div>";
  614. } else {
  615. $output="";
  616. $output.="<div id='rightnow'>\n\r";
  617. $output.=" <h3 class='reallynow'>\n\r";
  618. $output.=" <a class='rbutton' href='admin.php?page=wpsc-edit-products'><strong>".__('Add New Product', 'wpsc')."</strong></a>\n\r";
  619. $output.=" <span>"._('Right Now')."</span>\n\r";
  620. //$output.=" <br class='clear'/>\n\r";
  621. $output.=" </h3>\n\r";
  622. $output.="<p class='youhave'>".__('You have <a href="admin.php?page=wpsc-edit-products">:productcount:</a>, contained within <a href="admin.php?page=wpsc-edit-groups">:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc')."</p>\n\r";
  623. $output.=" <p class='youare'>\n\r";
  624. $output.=" ".__('You are using the :theme: style. This is WP e-Commerce :versionnumber:.', 'wpsc')."\n\r";
  625. //$output.=" <a class='rbutton' href='themes.php'>Change Theme</a>\n\r";
  626. //$output.="<span id='wp-version-message'>This is WordPress version 2.6. <a class='rbutton' href='http://wordpress.org/download/'>Update to 2.6.1</a></span>\n\r";
  627. $output.=" </p>\n\r";
  628. $output.="</div>\n\r";
  629. $output.="<br />\n\r";
  630. $output = str_replace(array_keys($replace_values), array_values($replace_values),$output);
  631. }
  632. return $output;
  633. }
  634. function wpsc_packing_slip($purchase_id) {
  635. global $wpdb, $purchlogitem, $wpsc_cart,$purchlog;
  636. if(isset($_REQUEST['purchaselog_id'])){
  637. $purchlogitem = new wpsc_purchaselogs_items((int)$_REQUEST['purchaselog_id']);
  638. }
  639. $purch_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='".$purchase_id."'";
  640. $purch_data = $wpdb->get_row($purch_sql,ARRAY_A) ;
  641. //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
  642. $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_id."";
  643. $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ;
  644. $j = 0;
  645. if($cart_log != null) {
  646. echo "<div class='packing_slip'>\n\r";
  647. echo "<h2>".__('Packing Slip', 'wpsc')."</h2>\n\r";
  648. echo "<strong>".__('Order', 'wpsc')." #</strong> ".$purchase_id."<br /><br />\n\r";
  649. echo "<table>\n\r";
  650. /*
  651. $form_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".(int)$purchase_id."'";
  652. $input_data = $wpdb->get_results($form_sql,ARRAY_A);
  653. */
  654. echo "<tr><td colspan='2'><strong>Billing Info</strong></td></tr>";
  655. foreach((array)$purchlogitem->userinfo as $userinfo){
  656. if($userinfo['unique_name'] != 'billingcountry'){
  657. echo "<tr><td>".$userinfo['name'].": </td><td>".$userinfo['value']."</td></tr>";
  658. }else{
  659. $userinfo['value'] = maybe_unserialize($userinfo['value']);
  660. if(is_array($userinfo['value'] )){
  661. if(!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])){
  662. echo "<tr><td>State: </td><td>".$userinfo['value'][1]."</td></tr>";
  663. }elseif(is_numeric($userinfo['value'][1])){
  664. echo "<tr><td>State: </td><td>".wpsc_get_state_by_id($userinfo['value'][1],'name')."</td></tr>";
  665. }
  666. if(!empty($userinfo['value'][0])){
  667. echo "<tr><td>Country: </td><td>".$userinfo['value'][0]."</td></tr>";
  668. }
  669. }else{
  670. echo "<tr><td>".$userinfo['name'].": </td><td>".$userinfo['value']."</td></tr>";
  671. }
  672. }
  673. }
  674. echo "<tr><td colspan='2'><strong>Shipping Info</strong></td></tr>";
  675. foreach((array)$purchlogitem->shippinginfo as $userinfo){
  676. if($userinfo['unique_name'] != 'shippingcountry' && $userinfo['unique_name'] != 'shippingstate'){
  677. echo "<tr><td>".$userinfo['name'].": </td><td>".$userinfo['value']."</td></tr>";
  678. }elseif($userinfo['unique_name'] == 'shippingcountry'){
  679. $userinfo['value'] = maybe_unserialize($userinfo['value']);
  680. if(is_array($userinfo['value'] )){
  681. if(!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])){
  682. echo "<tr><td>State: </td><td>".$userinfo['value'][1]."</td></tr>";
  683. }elseif(is_numeric($userinfo['value'][1])){
  684. echo "<tr><td>State: </td><td>".wpsc_get_state_by_id($userinfo['value'][1],'name')."</td></tr>";
  685. }
  686. if(!empty($userinfo['value'][0])){
  687. echo "<tr><td>Country: </td><td>".$userinfo['value'][0]."</td></tr>";
  688. }
  689. }else{
  690. echo "<tr><td>".$userinfo['name'].": </td><td>".$userinfo['value']."</td></tr>";
  691. }
  692. }elseif($userinfo['unique_name'] == 'shippingstate'){
  693. if(!empty($userinfo['value']) && !is_numeric($userinfo['value'])){
  694. echo "<tr><td>".$userinfo['name'].": </td><td>".$userinfo['value']."</td</tr>>";
  695. }elseif(is_numeric($userinfo['value'])){
  696. echo "<tr><td>State: </td><td>".wpsc_get_state_by_id($userinfo['value'],'name')."</td></tr>";
  697. }
  698. }
  699. }
  700. // echo('<pre>'.print_r($purchlogitem,true).'</pre>');
  701. /*
  702. foreach($input_data as $input_row) {
  703. $rekeyed_input[$input_row['form_id']] = $input_row;
  704. }
  705. if($input_data != null) {
  706. $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A);
  707. // exit('<pre>'.print_r($purch_data, true).'</pre>');
  708. foreach($form_data as $form_field) {
  709. switch($form_field['type']) {
  710. case 'country':
  711. $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('".$wpdb->escape( $purch_data['billing_country'])."')");
  712. if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0)) {
  713. echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
  714. }
  715. echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_country($purch_data['billing_country'])."</td></tr>\n\r";
  716. break;
  717. case 'delivery_country':
  718. echo " <tr><td>".$form_field['name'].":</td><td>".wpsc_get_country($purch_data['shipping_country'])."</td></tr>\n\r";
  719. break;
  720. case 'heading':
  721. echo " <tr><td colspan='2'><strong>".wp_kses($form_field['name'], array()).":</strong></td></tr>\n\r";
  722. break;
  723. default:
  724. if($form_field['unique_name'] == 'shippingstate'){
  725. echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_region($purch_data['shipping_region'])."</td></tr>\n\r";
  726. }else{
  727. echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES,'UTF-8')."</td></tr>\n\r";
  728. }
  729. break;
  730. }
  731. }
  732. } else {
  733. echo " <tr><td>".__('Name', 'wpsc').":</td><td>".$purch_data['firstname']." ".$purch_data['lastname']."</td></tr>\n\r";
  734. echo " <tr><td>".__('Address', 'wpsc').":</td><td>".$purch_data['address']."</td></tr>\n\r";
  735. echo " <tr><td>".__('Phone', 'wpsc').":</td><td>".$purch_data['phone']."</td></tr>\n\r";
  736. echo " <tr><td>".__('Email', 'wpsc').":</td><td>".$purch_data['email']."</td></tr>\n\r";
  737. }
  738. */
  739. if(get_option('payment_method') == 2) {
  740. $gateway_name = '';
  741. foreach($GLOBALS['nzshpcrt_gateways'] as $gateway) {
  742. if($purch_data['gateway'] != 'testmode') {
  743. if($gateway['internalname'] == $purch_data['gateway'] ) {
  744. $gateway_name = $gateway['name'];
  745. }
  746. } else {
  747. $gateway_name = "Manual Payment";
  748. }
  749. }
  750. }
  751. // echo " <tr><td colspan='2'></td></tr>\n\r";
  752. // echo " <tr><td>".__('Payment Method', 'wpsc').":</td><td>".$gateway_name."</td></tr>\n\r";
  753. // //echo " <tr><td>".__('Purchase No.', 'wpsc').":</td><td>".$purch_data['id']."</td></tr>\n\r";
  754. // echo " <tr><td>".__('How The Customer Found Us', 'wpsc').":</td><td>".$purch_data['find_us']."</td></tr>\n\r";
  755. // $engrave_line = explode(",",$purch_data['engravetext']);
  756. // echo " <tr><td>".__('Engrave text', 'wpsc')."</td><td></td></tr>\n\r";
  757. // echo " <tr><td>".__('Line 1', 'wpsc').":</td><td>".$engrave_line[0]."</td></tr>\n\r";
  758. // echo " <tr><td>".__('Line 2', 'wpsc').":</td><td>".$engrave_line[1]."</td></tr>\n\r";
  759. // if($purch_data['transactid'] != '') {
  760. // echo " <tr><td>".__('Transaction Id', 'wpsc').":</td><td>".$purch_data['transactid']."</td></tr>\n\r";
  761. // }
  762. echo "</table>\n\r";
  763. echo "<table class='packing_slip'>";
  764. echo "<tr>";
  765. echo " <th>".__('Quantity', 'wpsc')." </th>";
  766. echo " <th>".__('Name', 'wpsc')."</th>";
  767. echo " <th>".__('Price', 'wpsc')." </th>";
  768. echo " <th>".__('Shipping', 'wpsc')." </th>";
  769. echo "<th>".wpsc_display_tax_label(false)."</th>";
  770. echo '</tr>';
  771. $endtotal = 0;
  772. $all_donations = true;
  773. $all_no_shipping = true;
  774. $file_link_list = array();
  775. // exit('<pre>'.print_r($cart_log,true).'</pre>');
  776. foreach($cart_log as $cart_row) {
  777. $purchlogitem->the_purch_item();
  778. // exit('<pre>'.print_r, true).'</pre>');
  779. $alternate = "";
  780. $j++;
  781. if(($j % 2) != 0) {
  782. $alternate = "class='alt'";
  783. }
  784. $productsql= "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=".$cart_row['prodid']."";
  785. $product_data = $wpdb->get_results($productsql,ARRAY_A);
  786. $variation_sql = "SELECT * FROM `".WPSC_TABLE_CART_ITEM_VARIATIONS."` WHERE `cart_id`='".$cart_row['id']."'";
  787. $variation_data = $wpdb->get_results($variation_sql,ARRAY_A);
  788. $variation_count = count($variation_data);
  789. if($variation_count > 1) {
  790. $variation_list = " (";
  791. $i = 0;
  792. foreach($variation_data as $variation) {
  793. if($i > 0) {
  794. $variation_list .= ", ";
  795. }
  796. $value_id = $variation['value_id'];
  797. $value_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id`='".$value_id."' LIMIT 1",ARRAY_A);
  798. $variation_list .= $value_data[0]['name'];
  799. $i++;
  800. }
  801. $variation_list .= ")";
  802. } else if($variation_count == 1) {
  803. $value_id = $variation_data[0]['value_id'];
  804. $value_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id`='".$value_id."' LIMIT 1",ARRAY_A);
  805. $variation_list = " (".$value_data[0]['name'].")";
  806. } else {
  807. $variation_list = '';
  808. }
  809. if($cart_row['donation'] != 1) {
  810. $all_donations = false;
  811. }
  812. if($cart_row['no_shipping'] != 1) {
  813. $shipping = $cart_row['pnp'] * $cart_row['quantity'];
  814. $total_shipping += $shipping;
  815. $all_no_shipping = false;
  816. } else {
  817. $shipping = 0;
  818. }
  819. $price = $cart_row['price'] * $cart_row['quantity'];
  820. $gst = $price - ($price / (1+($cart_row['gst'] / 100)));
  821. if($gst > 0) {
  822. $tax_per_item = $gst / $cart_row['quantity'];
  823. }
  824. echo "<tr $alternate>";
  825. echo " <td>";
  826. echo $cart_row['quantity'];
  827. echo " </td>";
  828. echo " <td>";
  829. echo $product_data[0]['name'];
  830. echo stripslashes($variation_list);
  831. echo " </td>";
  832. echo " <td>";
  833. echo nzshpcrt_currency_display( $price, 1);
  834. echo " </td>";
  835. echo " <td>";
  836. echo nzshpcrt_currency_display($shipping, 1);
  837. echo " </td>";
  838. echo '<td>';
  839. if(wpsc_tax_isincluded()){
  840. echo (wpsc_purchaselog_details_tax());
  841. }else{
  842. echo nzshpcrt_currency_display($cart_row['tax_charged'],1);
  843. }
  844. echo '<td>';
  845. echo '</tr>';
  846. }
  847. echo "</table>";
  848. echo '<table class="packing-slip-totals">';
  849. echo '<tr><th>Base Shipping</th><td>' . nzshpcrt_currency_display( $purch_data['base_shipping'], 1 ) . '</td></tr>';
  850. echo '<tr><th>Total Shipping</th><td>' . nzshpcrt_currency_display( $purch_data['base_shipping'] + $total_shipping, 1 ) . '</td></tr>';
  851. echo '<tr><th>Total Price</th><td>' . nzshpcrt_currency_display( $purch_data['totalprice'], 1 ) . '</td></tr>';
  852. echo '</table>';
  853. echo "</div>\n\r";
  854. } else {
  855. echo "<br />".__('This users cart was empty', 'wpsc');
  856. }
  857. }
  858. function wpsc_product_item_row() {
  859. }
  860. ?>