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

/wp-content/plugins/wp-e-commerce/wpsc-admin/includes/display-items-functions.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 1164 lines | 980 code | 141 blank | 43 comment | 126 complexity | 9506641a363684df5099ada54e82adf8 MD5 | raw file
  1. <?php
  2. /**
  3. * WPSC Product form generation functions
  4. *
  5. * @package wp-e-commerce
  6. * @since 3.7
  7. */
  8. //$closed_postboxes = (array)get_usermeta( $current_user->ID, 'editproduct');
  9. $variations_processor = new nzshpcrt_variations;
  10. $wpsc_product_defaults =array (
  11. 'id' => '0',
  12. 'name' => '',
  13. 'description' => '',
  14. 'additional_description' => '',
  15. 'price' => '0.00',
  16. 'weight' => '0',
  17. 'weight_unit' => 'pound',
  18. 'pnp' => '0.00',
  19. 'international_pnp' => '0.00',
  20. 'file' => '0',
  21. 'image' => '',
  22. 'category' => '0',
  23. 'brand' => '0',
  24. 'quantity_limited' => '0',
  25. 'quantity' => '0',
  26. 'special' => '0',
  27. 'special_price' => '',
  28. 'display_frontpage' => '0',
  29. 'notax' => '0',
  30. 'publish' => '1',
  31. 'active' => '1',
  32. 'donation' => '0',
  33. 'no_shipping' => '0',
  34. 'thumbnail_image' => '',
  35. 'thumbnail_state' => '1',
  36. 'meta' =>
  37. array (
  38. 'external_link' => NULL,
  39. 'merchant_notes' => NULL,
  40. 'sku' => NULL,
  41. 'engrave' => '0',
  42. 'can_have_uploaded_image' => '0',
  43. 'table_rate_price' =>
  44. array (
  45. 'quantity' =>
  46. array (
  47. 0 => '',
  48. ),
  49. 'table_price' =>
  50. array (
  51. 0 => '',
  52. ),
  53. ),
  54. ),
  55. );
  56. function wpsc_display_product_form ($product_id = 0) {
  57. global $wpdb, $wpsc_product_defaults;
  58. $product_id = absint($product_id);
  59. //$variations_processor = new nzshpcrt_variations;
  60. if($product_id > 0) {
  61. $product_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='{$product_id}' LIMIT 1",ARRAY_A);
  62. $product_data['meta']['dimensions'] = get_product_meta($product_id, 'dimensions',true);
  63. $product_data['meta']['external_link'] = get_product_meta($product_id,'external_link',true);
  64. $product_data['meta']['merchant_notes'] = get_product_meta($product_id,'merchant_notes',true);
  65. $product_data['meta']['sku'] = get_product_meta($product_id,'sku',true);
  66. $product_data['meta']['engrave'] = get_product_meta($product_id,'engraved',true);
  67. $product_data['meta']['can_have_uploaded_image'] = get_product_meta($product_id,'can_have_uploaded_image',true);
  68. $product_data['meta']['table_rate_price'] = get_product_meta($product_id,'table_rate_price',true);
  69. $sql ="SELECT `meta_key`, `meta_value` FROM ".WPSC_TABLE_PRODUCTMETA." WHERE `meta_key` LIKE 'currency%' AND `product_id`=".$product_id;
  70. $product_data['newCurr']= $wpdb->get_results($sql, ARRAY_A);
  71. //echo "<pre>".print_r($product_data,true)."</pre>";
  72. if(function_exists('wp_insert_term')) {
  73. $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_id}'", ARRAY_A);
  74. foreach ((array)$term_relationships as $term_relationship) {
  75. $tt_ids[] = $term_relationship['term_taxonomy_id'];
  76. }
  77. foreach ((array)$tt_ids as $tt_id) {
  78. $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1");
  79. }
  80. foreach ((array)$term_ids as $term_id ) {
  81. if ($term_id != NULL){
  82. $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1");
  83. }
  84. }
  85. if ($tags != NULL){
  86. $imtags = implode(',', $tags);
  87. }
  88. }
  89. //exit('got called<pre>'.print_r($imtags,true).'</pre>');
  90. $check_variation_value_count = $wpdb->get_var("SELECT COUNT(*) as `count` FROM `".WPSC_TABLE_VARIATION_VALUES_ASSOC."` WHERE `product_id` = '{$product_id}'");
  91. } else {
  92. if(isset($_SESSION['wpsc_failed_product_post_data']) && (count($_SESSION['wpsc_failed_product_post_data']) > 0 )) {
  93. $product_data = array_merge($wpsc_product_defaults, $_SESSION['wpsc_failed_product_post_data']);
  94. $_SESSION['wpsc_failed_product_post_data'] = null;
  95. } else {
  96. $product_data = $wpsc_product_defaults;
  97. }
  98. }
  99. $product_data = apply_filters('wpsc_display_product_form_get', $product_data);
  100. $current_user = wp_get_current_user();
  101. // we put the closed postboxes array into the product data to propagate it to each form without having it global.
  102. $product_data['closed_postboxes'] = (array)get_usermeta( $current_user->ID, 'closedpostboxes_store_page_wpsc-edit-products');
  103. $product_data['hidden_postboxes'] = (array)get_usermeta( $current_user->ID, 'metaboxhidden_store_page_wpsc-edit-products');
  104. if(count($product_data) > 0) {
  105. wpsc_product_basic_details_form($product_data);
  106. }
  107. }
  108. function wpsc_product_basic_details_form(&$product_data) {
  109. global $wpdb,$nzshpcrt_imagesize_info;
  110. /*<h3 class='hndle'><?php echo __('Product Details', 'wpsc'); ?> <?php echo __('(enter in your product details here)', 'wpsc'); ?></h3>*/
  111. ?>
  112. <h3 class='form_heading'>
  113. <?php
  114. if($product_data['id'] > 0) {
  115. echo __('Edit Product', 'wpsc')." <span>(<a href='".add_query_arg('page','wpsc-edit-products', remove_query_arg('product_id', 'admin.php'))."'>".__('Add Product', 'wpsc')."</a>)</span>";
  116. } else {
  117. echo __('Add Product', 'wpsc');
  118. }
  119. ?>
  120. </h3>
  121. <div>
  122. <table class='product_editform' >
  123. <tr>
  124. <td colspan='2' class='itemfirstcol'>
  125. <div style='width:470px'>
  126. <label for="wpsc_product_name"><?php echo __('Product Name', 'wpsc')?></label>
  127. <div class='admin_product_name'>
  128. <input id='wpsc_product_name' class='wpsc_product_name text' size='15' type='text' name='title' value='<?php echo htmlentities(stripslashes($product_data['name']), ENT_QUOTES, 'UTF-8'); ?>' />
  129. <a href='#' class='shorttag_toggle'></a>
  130. </div>
  131. <div class='admin_product_shorttags'>
  132. <h4>Shortcodes</h4>
  133. <dl>
  134. <dt><?php echo __('Display Product Shortcode', 'wpsc'); ?>: </dt><dd>[wpsc_products product_id='<?php echo $product_data['id'];?>']</dd>
  135. <dt><?php echo __('Buy Now Shortcode', 'wpsc'); ?>: </dt><dd>[buy_now_button=<?php echo $product_data['id'];?>]</dd>
  136. <dt><?php echo __('Add to Cart Shortcode', 'wpsc'); ?>: </dt><dd>[add_to_cart=<?php echo $product_data['id'];?>]</dd>
  137. </dl>
  138. <h4>Template Tags</h4>
  139. <dl>
  140. <dt><?php echo __('Display Product Template Tag', 'wpsc'); ?>: </dt><dd> &lt;?php echo wpsc_display_products('product_id=<?php echo $product_data['id'];?>'); ?&gt;</dd>
  141. <dt><?php echo __('Buy Now PHP', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_buy_now_button(<?php echo $product_data['id'];?>); ?&gt;</dd>
  142. <dt><?php echo __('Add to Cart PHP', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_add_to_cart_button(<?php echo $product_data['id'];?>); ?&gt;</dd>
  143. <dt><?php echo __('Display Product SKU', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_product_sku(<?php echo $product_data['id'];?>); ?&gt;</dd>
  144. </dl>
  145. <?php if ( $product_data['id'] > 0 ) { ?>
  146. <p><a href="<?php echo wpsc_product_url( $product_data['id'] ); ?>" target="_blank" class="button">View product</a></p>
  147. <?php } ?>
  148. </div>
  149. </div>
  150. <div style='clear:both; height: 0px; margin-bottom: 15px;'></div>
  151. </td>
  152. </tr>
  153. <tr>
  154. <td colspan='3' class='skuandprice'>
  155. <div class='wpsc_floatleft'>
  156. <?php echo __('Stock Keeping Unit', 'wpsc'); ?> :<br />
  157. <input size='17' type='text' class='text' name='productmeta_values[sku]' value='<?php echo htmlentities(stripslashes($product_data['meta']['sku']), ENT_QUOTES, 'UTF-8'); ?>' />
  158. </div>
  159. <div class='wpsc_floatleft'>
  160. <?php echo __('Price', 'wpsc'); ?> :<br />
  161. <input type='text' class='text' size='17' name='price' value='<?php echo $product_data['price']; ?>' />
  162. </div>
  163. <div class='wpsc_floatleft'>
  164. <label for='add_form_special'><?php echo __('Sale Price :', 'wpsc'); ?></label>
  165. <div style='display:<?php if(($product_data['special'] == 1) ? 'block' : 'none'); ?>' id='add_special'>
  166. <?php
  167. if(is_numeric($product_data['special_price'])) {
  168. $special_price = number_format(($product_data['price'] - $product_data['special_price']), 2);
  169. }
  170. /*
  171. if(0 == $product_data['special_price']){
  172. $special_price = number_format(( $product_data['special_price']), 2);
  173. }
  174. */
  175. ?>
  176. <input type='text' size='17' value='<?php echo $special_price; ?>' name='special_price'/>
  177. </div>
  178. </div>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td ><a href='' class='wpsc_add_new_currency'>+ <?php echo __('New Currency', 'wpsc');?></a></td>
  183. </tr>
  184. <tr class='new_layer'>
  185. <td>
  186. <label for='newCurrency[]'><?php echo __('Currency type', 'wpsc');?>:</label><br />
  187. <select name='newCurrency[]' class='newCurrency'>
  188. <?php
  189. $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
  190. foreach((array)$currency_data as $currency) {
  191. if($isocode == $currency['isocode']) {
  192. $selected = "selected='selected'";
  193. } else {
  194. $selected = "";
  195. } ?>
  196. <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
  197. <?php }
  198. $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
  199. if($currency_data['symbol'] != '') {
  200. $currency_sign = $currency_data['symbol_html'];
  201. } else {
  202. $currency_sign = $currency_data['code'];
  203. }
  204. ?>
  205. </select>
  206. </td>
  207. <td>
  208. <?php echo __('Price', 'wpsc');?> :<br />
  209. <input type='text' class='text' size='15' name='newCurrPrice[]' value='0.00' />
  210. <a href='' class='deletelayer' rel='<?php echo $isocode; ?>'><?php echo __('Delete Currency', 'wpsc');?></a>
  211. </td>
  212. </tr>
  213. <?php if(count($product_data['newCurr']) > 0) :
  214. $i = 0;
  215. foreach($product_data['newCurr'] as $newCurr){
  216. $i++;
  217. $isocode = str_replace("currency[", "", $newCurr['meta_key']);
  218. $isocode = str_replace("]", "", $isocode);
  219. // exit('ere<pre>'.print_r($isocode, true).'</pre>');
  220. ?>
  221. <tr>
  222. <td>
  223. <label for='newCurrency[]'><?php echo __('Currency type', 'wpsc');?>:</label><br />
  224. <select name='newCurrency[]' class='newCurrency'>
  225. <?php
  226. $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
  227. foreach($currency_data as $currency) {
  228. if($isocode == $currency['isocode']) {
  229. $selected = "selected='selected'";
  230. } else {
  231. $selected = "";
  232. } ?>
  233. <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
  234. <?php }
  235. $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
  236. if($currency_data['symbol'] != '') {
  237. $currency_sign = $currency_data['symbol_html'];
  238. } else {
  239. $currency_sign = $currency_data['code'];
  240. }
  241. ?>
  242. </select>
  243. </td>
  244. <td>
  245. Price<?php //echo __('Price', 'wpsc'); ?> :<br />
  246. <input type='text' class='text' size='15' name='newCurrPrice[]' value='<?php echo $newCurr['meta_value']; ?>' />
  247. <a href='' class='wpsc_delete_currency_layer' rel='<?php echo $isocode; ?>'><?php echo __('Delete Currency', 'wpsc');?></a>
  248. </td>
  249. </tr>
  250. <?php } ?>
  251. <?php endif; ?>
  252. <tr>
  253. <td colspan='2'>
  254. <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea" >
  255. <?php
  256. wpsc_the_editor($product_data['description'], 'content', false, false);
  257. ?>
  258. </div>
  259. </td>
  260. </tr>
  261. <tr>
  262. <td class='itemfirstcol' colspan='2'>
  263. <strong ><?php echo __('Additional Description', 'wpsc'); ?> :</strong><br />
  264. <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes($product_data['additional_description']); ?></textarea>
  265. </td>
  266. </tr>
  267. </table>
  268. </div>
  269. <div class='meta-box-sortables'>
  270. <?php
  271. $default_order=array(
  272. "wpsc_product_category_and_tag_forms",
  273. "wpsc_product_price_and_stock_forms",
  274. "wpsc_product_shipping_forms",
  275. "wpsc_product_variation_forms",
  276. "wpsc_product_advanced_forms",
  277. "wpsc_product_image_forms",
  278. "wpsc_product_download_forms"
  279. );
  280. $order = apply_filters( 'wpsc_products_page_forms', get_option('wpsc_product_page_order'));
  281. //echo "<pre>".print_r($order,true)."</pre>";
  282. if (($order == '') || (count($order ) < 6)){
  283. $order = $default_order;
  284. }
  285. $check_missing_items = array_diff($default_order, $order);
  286. if(count($check_missing_items) > 0) {
  287. $order = array_merge($check_missing_items, $order);
  288. }
  289. update_option('wpsc_product_page_order', $order);
  290. foreach((array)$order as $key => $box_function_name) {
  291. if(function_exists($box_function_name)) {
  292. echo call_user_func(apply_filters('wpsc_product_page_order_form_name', $box_function_name),$product_data);
  293. }
  294. }
  295. ?>
  296. </div>
  297. <input type='hidden' name='product_id' id='product_id' value='<?php echo $product_data['id']; ?>' />
  298. <input type='hidden' name='wpsc_admin_action' value='edit_product' />
  299. <?php wp_nonce_field('edit-product', 'wpsc-edit-product'); ?>
  300. <input type='hidden' name='submit_action' value='edit' />
  301. <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
  302. <input class='button-primary' style='float:left;' type='submit' name='submit' value='<?php if($product_data['id'] > 0) { _e('Update Product', 'wpsc'); } else { _e('Add New Product', 'wpsc'); } ?>' />&nbsp;
  303. <a class='submitdelete delete_button' title='<?php echo attribute_escape(__('Delete this product')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=delete_product&amp;product={$product_data['id']}", 'delete_product_' . $product_data['id']); ?>' onclick="if ( confirm(' <?php echo js_escape(sprintf( __("You are about to delete this product '%s'\n 'Cancel' to stop, 'OK' to delete."), $product_data['name'] )) ?>') ) { return true;}return false;"><?php _e('Delete') ?></a>
  304. <?php
  305. }
  306. function wpsc_product_category_and_tag_forms($product_data=''){
  307. global $closed_postboxes, $wpdb, $variations_processor;
  308. $output = '';
  309. if ($product_data == 'empty') {
  310. $display = "style='visibility:hidden;'";
  311. }
  312. $output .= "<div id='wpsc_product_category_and_tag_forms' class=' postbox ".((array_search('wpsc_product_category_and_tag_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_category_and_tag_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '')." >";
  313. if (IS_WP27) {
  314. $output .= "<h3 class='hndle'>";
  315. } else {
  316. $output .= "<h3>
  317. <a class='togbox'>+</a>";
  318. }
  319. $output .= __('Categories and Tags', 'wpsc');
  320. if ($product_data != '') {
  321. if(function_exists('wp_insert_term')) {
  322. $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A);
  323. //exit('HERE><pre>'.print_r($term_relationships,true).'</pre>');
  324. foreach ((array)$term_relationships as $term_relationship) {
  325. $tt_ids[] = $term_relationship['term_taxonomy_id'];
  326. }
  327. foreach ((array)$tt_ids as $tt_id) {
  328. $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1");
  329. }
  330. foreach ((array)$term_ids as $term_id ) {
  331. if ($term_id != NULL){
  332. $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1");
  333. }
  334. }
  335. $imtags = '';
  336. if ($tags != NULL){
  337. $imtags = implode(',', $tags);
  338. }
  339. //exit('HERE<pre>'.print_r($imtags,true).'</pre>');
  340. }
  341. }
  342. $output .= "
  343. </h3>
  344. <div class='inside'>
  345. <table>";
  346. $output .= "
  347. <tr>
  348. <td class='itemfirstcol'>
  349. <span class='howto'>".__('Categories', 'wpsc')." </span>
  350. <div id='categorydiv' >";
  351. $search_sql = apply_filters('wpsc_product_category_and_tag_forms_group_search_sql', '');
  352. $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')".$search_sql, ARRAY_A);
  353. //exit('<pre>'.print_r($categorisation_groups, true).'</pre>');
  354. foreach((array)$categorisation_groups as $categorisation_group){
  355. $category_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('{$categorisation_group['id']}')");
  356. if($category_count > 0) {
  357. $output .= "<p>";
  358. $category_group_name = str_replace("[categorisation]", $categorisation_group['name'], __('Select &quot;[categorisation]&quot;', 'wpsc'));
  359. $output .= "".$category_group_name.":<br />";
  360. $output .= "</p>";
  361. if ($product_data == '')
  362. $output .= wpsc_category_list($categorisation_group['id'], false, 'add_', null, 0, 'name' );
  363. else
  364. $output .= wpsc_category_list($categorisation_group['id'], $product_data['id'], 'edit_', null, 0, 'name' );
  365. }
  366. }
  367. $output .= "
  368. </div>
  369. </td>
  370. <td class='itemfirstcol product_tags'>
  371. <span class='howto'> ".__('Product Tags', 'wpsc')."</span><br />
  372. <p id='jaxtag'>
  373. <label for='tags-input' class='hidden'>".__('Product Tags', 'wpsc')."</label>
  374. <input type='text' value='".$imtags."' tabindex='3' size='20' id='tags-input' class='tags-input' name='product_tags'/>
  375. <span class='howto'>".__('Separate tags with commas')."</span>
  376. </p>
  377. <div id='tagchecklist' onload='tag_update_quickclicks();'></div>
  378. </td>
  379. </tr>";
  380. // <p class='hide-if-no-js' id='tagcloud-link'><a href='#'>Choose from the most popular tags</a></p>
  381. //
  382. // <input type='text' class='text wpsc_tag greytext' value='Add new tag' name='product_tags' id='product_tag'>
  383. // <input class='button' type='submit' value='Add' name='wpsc_add_new_tag' />
  384. // <br /><span class='small_italic greytext'>".__("Separate tags with commas")."</span><br />
  385. //
  386. // <p>".$imtags."</p>
  387. // <input type='hidden' value='".$imtags."' name='wpsc_existing_tags' />
  388. $output .= "
  389. </table>
  390. </div>
  391. </div>";
  392. $output = apply_filters('wpsc_product_category_and_tag_forms_output', $output);
  393. return $output;
  394. }
  395. function wpsc_product_price_and_stock_forms($product_data=''){
  396. global $closed_postboxes, $wpdb, $variations_processor;
  397. $table_rate_price = get_product_meta($product_data['id'], 'table_rate_price');
  398. $custom_tax = get_product_meta($product_data['id'], 'custom_tax');
  399. if ($product_data == 'empty') {
  400. $display = "style='visibility:hidden;'";
  401. }
  402. echo "<div id='wpsc_product_price_and_stock_forms' class='wpsc_product_price_and_stock_forms postbox ".((array_search('wpsc_product_price_and_stock_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_price_and_stock_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '')." >";
  403. echo "<h3 class='hndle'>";
  404. echo __('Price and Stock Control', 'wpsc');
  405. echo "
  406. </h3>
  407. <div class='inside'>
  408. <table>
  409. ";
  410. echo "
  411. <tr>
  412. <td>
  413. <input id='add_form_tax' type='checkbox' name='notax' value='yes' ".(($product_data['notax'] == 1) ? 'checked="checked"' : '')."/>&nbsp;<label for='add_form_tax'>".sprintf(__('Do not include tax (tax is set in <a href="%s"/wp-admin/admin.php?page=wpsc-settings">shop config</a>)', 'wpsc'), get_option("siteurl"))."</label>
  414. </td>
  415. </tr>";
  416. echo "
  417. <tr>
  418. <td>
  419. <input id='add_form_donation' type='checkbox' name='donation' value='yes' ".(($product_data['donation'] == 1) ? 'checked="checked"' : '')." />&nbsp;<label for='add_form_donation'>".__('This is a donation, checking this box populates the donations widget.', 'wpsc')."</label>
  420. </td>
  421. </tr>";
  422. ?>
  423. <tr>
  424. <td>
  425. <input type='checkbox' value='1' name='table_rate_price' id='table_rate_price' <?php echo ((count($table_rate_price['quantity']) > 0) ? 'checked=\'checked\'' : ''); ?> <?php echo ((wpsc_product_has_variations($product_data['id'])) ? 'disabled=\'disabled\'' : ''); ?> />
  426. <label for='table_rate_price'><?php echo __('Table Rate Price', 'wpsc'); ?></label>
  427. <div style='display:<?php echo ((($table_rate_price != '') && !wpsc_product_has_variations($product_data['id'])) ? 'block' : 'none'); ?>;' id='table_rate'>
  428. <a class='add_level' style='cursor:pointer;'>+ Add level</a><br />
  429. <table>
  430. <tr>
  431. <td><?php echo __('Quantity In Cart', 'wpsc'); ?></td>
  432. <td><?php echo __('Discounted Price', 'wpsc'); ?></td>
  433. </tr>
  434. <?php
  435. if(count($table_rate_price) > 0 ) {
  436. foreach((array)$table_rate_price['quantity'] as $key => $qty) {
  437. if($qty != '') {
  438. ?>
  439. <tr>
  440. <td>
  441. <input type="text" size="10" value="<?php echo $qty; ?>" name="productmeta_values[table_rate_price][quantity][]"/> and above
  442. </td>
  443. <td>
  444. <input type="text" size="10" value="<?php echo $table_rate_price['table_price'][$key]; ?>" name="productmeta_values[table_rate_price][table_price][]" />
  445. </td>
  446. <td><img src="<?php echo WPSC_URL; ?>/images/cross.png" class="remove_line" /></td>
  447. </tr>
  448. <?php
  449. }
  450. }
  451. }
  452. ?>
  453. <tr>
  454. <td><input type='text' size='10' value='' name='productmeta_values[table_rate_price][quantity][]'/> and above</td>
  455. <td><input type='text' size='10' value='' name='productmeta_values[table_rate_price][table_price][]'/></td>
  456. </tr>
  457. </table>
  458. </div>
  459. </td>
  460. </tr>
  461. <tr>
  462. <td>
  463. <input type='checkbox' value='1' name='custom_tax' id='custom_tax_checkbox' <?php echo ((is_numeric($custom_tax) > 0) ? 'checked=\'checked\'' : ''); ?> />
  464. <label for='custom_tax_checkbox'><?php echo _e("Custom Tax Rate",'wpsc'); ?></label>
  465. <div style='display:<?php echo ((is_numeric($custom_tax)) ? 'block' : 'none'); ?>;' id='custom_tax'>
  466. <input type='text' size='10' value='<?php echo $custom_tax; ?>' name='productmeta_values[custom_tax]'/>
  467. </div>
  468. </td>
  469. </tr>
  470. <?php
  471. echo "
  472. <tr>
  473. <td style='width:430px;'>
  474. <input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' ".(($product_data['quantity_limited'] == 1) ? 'checked="checked"' : '')." name='quantity_limited'/>"; //onclick='hideelement(\"add_stock\")'
  475. echo "&nbsp;<label for='add_form_quantity_limited' class='small'>".__('I have a limited number of this item in stock. If the stock runs out, this product will not be available on the shop unless you untick this box or add more stock.', 'wpsc')."</label>";
  476. if ($product_data['id'] > 0){
  477. $variations_output = $variations_processor->variations_grid_view($product_data['id']);
  478. if(wpsc_product_has_variations($product_data['id'])) {
  479. switch($product_data['quantity_limited']) {
  480. case 1:
  481. echo " <div class='edit_stock' style='display: block;'>\n\r";
  482. break;
  483. default:
  484. echo " <div class='edit_stock' style='display: none;'>\n\r";
  485. break;
  486. }
  487. echo "<input class='stock_limit_quantity' name='quantity' style='display:none;' value='".$product_data['quantity']."' />";
  488. echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' " . $unpublish_oos . " class='inform_when_oos' name='inform_when_oos' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
  489. echo "</div>\n\r";
  490. } else {
  491. switch($product_data['quantity_limited']) {
  492. case 1:
  493. echo " <div class='edit_stock' style='display: block;'>\n\r";
  494. break;
  495. default:
  496. echo " <div class='edit_stock' style='display: none;'>\n\r";
  497. break;
  498. }
  499. echo __('Stock Qty', 'wpsc') . " <input type='text' class='stock_limit_quantity' name='quantity' size='10' value='".$product_data['quantity']."' />";
  500. echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' " . $unpublish_oos . " class='inform_when_oos' name='inform_when_oos' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
  501. echo " </div>\n\r";
  502. }
  503. } else {
  504. echo "
  505. <div style='display: none;' class='edit_stock'>
  506. " .__('Stock Qty', 'wpsc') . " <input type='text' name='quantity' value='0' size='10' />";
  507. echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' class='inform_when_oos' name='inform_when_oos' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
  508. echo "</div>";
  509. }
  510. echo "
  511. </td>
  512. </tr>";
  513. echo "
  514. </table>
  515. </div>
  516. </div>";
  517. //return $output;
  518. }
  519. function wpsc_product_variation_forms($product_data=''){
  520. global $closed_postboxes, $variations_processor;
  521. $siteurl = get_option('siteurl');
  522. $output='';
  523. if ($product_data == 'empty') {
  524. $display = "style='display:none;'";
  525. }
  526. ?>
  527. <div id='wpsc_product_variation_forms' class='postbox <?php echo ((array_search('wpsc_product_variation_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search('wpsc_product_variation_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : ''); ?>>
  528. <h3 class='hndle'><?php echo __('Variation Control', 'wpsc'); ?></h3>
  529. <div class='inside'>
  530. <strong><?php echo __('Add Variation Set', 'wpsc'); ?></strong>
  531. <h4 class='product_action_link'><a target='_blank' href='admin.php?page=wpsc-edit-variations'><?php echo __('+ Add New Variations', 'wpsc'); ?></a></h4>
  532. <br />
  533. <?php
  534. if ($product_data['id'] > 0) { ?>
  535. <div id='edit_product_variations'>
  536. <?php echo $variations_processor->list_variations($product_data['id']); ?>
  537. </div>
  538. <div id='edit_variations_container'>
  539. <?php echo $variations_processor->variations_grid_view($product_data['id']); ?>
  540. </div>
  541. <?php } else { ?>
  542. <div id='add_product_variations'>
  543. <?php echo $variations_processor->list_variations($product_data['id']); ?>
  544. </div>
  545. <div id='edit_variations_container'>
  546. </div>
  547. <?php
  548. } ?>
  549. </div>
  550. </div>
  551. <?php
  552. }
  553. function wpsc_product_shipping_forms($product_data=''){
  554. global $closed_postboxes;
  555. if ($product_data == 'empty') {
  556. $display = "style='display:none;'";
  557. }
  558. $output .= "<div class='postbox ".((array_search('wpsc_product_shipping_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_shipping_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '')." id='wpsc_product_shipping_forms'>";
  559. if (IS_WP27) {
  560. $output .= "<h3 class='hndle'>";
  561. } else {
  562. $output .= "<h3>
  563. <a class='togbox'>+</a>";
  564. }
  565. $output .= __('Shipping Details', 'wpsc');
  566. $output .= "
  567. </h3>
  568. <div class='inside'>
  569. <table>
  570. <!--USPS shipping changes-->
  571. <tr>
  572. <td>
  573. ".__('Weight', 'wpsc')."
  574. </td>
  575. <td>
  576. <input type='text' size='5' name='weight' value='".$product_data['weight']."' />
  577. <select name='weight_unit'>
  578. <option value='pound' ". (($product_data['weight_unit'] == 'pound') ? 'selected="selected"' : '') .">Pounds</option>
  579. <option value='ounce' ". ((preg_match("/o(u)?nce/",$product_data['weight_unit'])) ? 'selected="selected"' : '') .">Ounces</option>
  580. <option value='gram' ". (($product_data['weight_unit'] == 'gram') ? 'selected="selected"' : '') .">Grams</option>
  581. <option value='kilogram' ". (($product_data['weight_unit'] == 'kilogram') ? 'selected="selected"' : '') .">Kilograms</option>
  582. </select>
  583. </td>
  584. </tr>
  585. <!--dimension-->
  586. <tr>
  587. <td>
  588. ".__('Height', 'wpsc')."
  589. </td>
  590. <td>
  591. <input type='text' size='5' name='productmeta_values[dimensions][height]' value='".$product_data['meta']['dimensions']['height']."'>
  592. <select name='productmeta_values[dimensions][height_unit]'>
  593. <option value='in' ". (($product_data['meta']['dimensions']['height_unit'] == 'in') ? 'selected' : '') .">inches</option>
  594. <option value='cm' ". (($product_data['meta']['dimensions']['height_unit'] == 'cm') ? 'selected' : '') .">cm</option>
  595. <option value='meter' ". (($product_data['meta']['dimensions']['height_unit'] == 'meter') ? 'selected' : '') .">meter</option> </select>
  596. </td>
  597. </tr>
  598. <tr>
  599. <td>
  600. ".__('Width', 'wpsc')."
  601. </td>
  602. <td>
  603. <input type='text' size='5' name='productmeta_values[dimensions][width]' value='".$product_data['meta']['dimensions']['width']."'>
  604. <select name='productmeta_values[dimensions][width_unit]'>
  605. <option value='in' ". (($product_data['meta']['dimensions']['width_unit'] == 'in') ? 'selected' : '') .">inches</option>
  606. <option value='cm' ". (($product_data['meta']['dimensions']['width_unit'] == 'cm') ? 'selected' : '') .">cm</option>
  607. <option value='meter' ". (($product_data['meta']['dimensions']['width_unit'] == 'meter') ? 'selected' : '') .">meter</option>
  608. </select>
  609. </td>
  610. </tr>
  611. <tr>
  612. <td>
  613. ".__('Length', 'wpsc')."
  614. </td>
  615. <td>
  616. <input type='text' size='5' name='productmeta_values[dimensions][length]' value='".$product_data['meta']['dimensions']['length']."'>
  617. <select name='productmeta_values[dimensions][length_unit]'>
  618. <option value='in' ". (($product_data['meta']['dimensions']['length_unit'] == 'in') ? 'selected' : '') .">inches</option>
  619. <option value='cm' ". (($product_data['meta']['dimensions']['length_unit'] == 'cm') ? 'selected' : '') .">cm</option>
  620. <option value='meter' ". (($product_data['meta']['dimensions']['length_unit'] == 'meter') ? 'selected' : '') .">meter</option>
  621. </select>
  622. </td>
  623. </tr>
  624. <!--//dimension-->
  625. <!--USPS shipping changes ends-->
  626. <!--USPS shipping changes ends-->
  627. <tr>
  628. <td colspan='2'>
  629. <strong>".__('Flat Rate Settings', 'wpsc')."</strong>
  630. </td>
  631. </tr>
  632. <tr>
  633. <td>
  634. ".__('Local Shipping Fee', 'wpsc')."
  635. </td>
  636. <td>
  637. <input type='text' size='10' name='pnp' value='".$product_data['pnp']."' />
  638. </td>
  639. </tr>
  640. <tr>
  641. <td>
  642. ".__('International Shipping Fee', 'wpsc')."
  643. </td>
  644. <td>
  645. <input type='text' size='10' name='international_pnp' value='".$product_data['international_pnp']."' />
  646. </td>
  647. </tr>
  648. <tr>
  649. <td>
  650. <br />
  651. <input id='add_form_no_shipping' type='checkbox' name='no_shipping' value='yes' ".(($product_data['no_shipping'] == 1) ? 'checked="checked"' : '')."/>&nbsp;<label for='add_form_no_shipping'>".__('Disregard Shipping for this product', 'wpsc')."</label>
  652. </td>
  653. </tr>
  654. </table></div></div>";
  655. return $output;
  656. }
  657. function wpsc_product_advanced_forms($product_data='') {
  658. global $closed_postboxes,$wpdb;
  659. //exit('<pre>'.print_r($product_data, true).'</pre>');
  660. $merchant_note = $product_data['meta']['merchant_notes'];
  661. $engraved_text = $product_data['meta']['engrave'];
  662. $can_have_uploaded_image = $product_data['meta']['can_have_uploaded_image'];
  663. $external_link = $product_data['meta']['external_link'];
  664. $enable_comments = $product_data['meta']['enable_comments'];
  665. $output ='';
  666. $custom_fields = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` IN('{$product_data['id']}') AND `custom` IN('1') ",ARRAY_A);
  667. if ($product_data == 'empty') {
  668. $display = "style='display:none;'";
  669. }
  670. $output .= "<div id='wpsc_product_advanced_forms' class='postbox ".((array_search('wpsc_product_advanced_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_advanced_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '').">";
  671. $output .= "<h3 class='hndle'>";
  672. $output .= __('Advanced Options', 'wpsc');
  673. $output .= "
  674. </h3>
  675. <div class='inside'>
  676. <table>";
  677. $output .= "
  678. <tr>
  679. <td colspan='2' class='itemfirstcol'>
  680. <strong>".__('Custom Meta', 'wpsc').":</strong><br />
  681. <a href='#' class='add_more_meta' onclick='return add_more_meta(this)'> + ".__('Add Custom Meta', 'wpsc')."</a><br /><br />
  682. ";
  683. foreach((array)$custom_fields as $custom_field) {
  684. $i = $custom_field['id'];
  685. // for editing, the container needs an id, I can find no other tidyish method of passing a way to target this object through an ajax request
  686. $output .= "
  687. <div class='product_custom_meta' id='custom_meta_$i'>
  688. ".__('Name', 'wpsc')."
  689. <input type='text' class='text' value='{$custom_field['meta_key']}' name='custom_meta[$i][name]' id='custom_meta_name_$i'>
  690. ".__('Value', 'wpsc')."
  691. <textarea class='text' name='custom_meta[$i][value]' id='custom_meta_value_$i'>{$custom_field['meta_value']}</textarea>
  692. <a href='#' class='remove_meta' onclick='return remove_meta(this, $i)'>".__('Delete')."</a>
  693. <br />
  694. </div>
  695. ";
  696. }
  697. $output .= "<div class='product_custom_meta'>
  698. ".__('Name', 'wpsc').": <br />
  699. <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
  700. ".__('Description', 'wpsc').": <br />
  701. <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
  702. <br /></div></td></tr>";
  703. $output .= "<tr>
  704. <td class='itemfirstcol' colspan='2'><br /> <strong>". __('Merchant Notes', 'wpsc') .":</strong><br />
  705. <textarea cols='40' rows='3' name='productmeta_values[merchant_notes]' id='merchant_notes'>".stripslashes($merchant_note)."</textarea>
  706. <small>".__('These notes are only available here.', 'wpsc')."</small>
  707. </td>
  708. </tr>";
  709. /* Insert Publish /No Publish Option on Product Edit (1bigidea)
  710. */
  711. $output .= '
  712. <tr>
  713. <td colspan="2" class="itemfirstcol"><br />
  714. <strong>'.__("Publish").': </strong> <label for="publish_yes">'.__("Yes").'
  715. </label><input name="publish" id="publish_yes" type="radio" value="1" '.((!is_array($product_data) || $product_data['publish']) ? 'checked="checked" ' : '' ).' />
  716. <label for="publish_no">'.__("No").'
  717. </label><input name="publish" id="publish_no" type="radio" value="0" '.((is_array($product_data) && !$product_data['publish']) ? 'checked="checked" ' : '' ).' />
  718. </td>
  719. </tr>';
  720. /* End Publish /No Publish Fields
  721. */
  722. $output .="
  723. <tr>
  724. <td class='itemfirstcol' colspan='2'><br />
  725. <strong>". __('Personalisation Options', 'wpsc') .":</strong><br />
  726. <input type='hidden' name='productmeta_values[engraved]' value='0' />
  727. <input type='checkbox' name='productmeta_values[engraved]' ".(($engraved_text == 'on') ? 'checked="checked"' : '')." id='add_engrave_text' />
  728. <label for='add_engrave_text'> ".__('Users can personalize this product by leaving a message on single product page', 'wpsc')."</label>
  729. <br />
  730. </td>
  731. </tr>
  732. <tr>
  733. <td class='itemfirstcol' colspan='2'>
  734. <input type='hidden' name='productmeta_values[can_have_uploaded_image]' value='0' />
  735. <input type='checkbox' name='productmeta_values[can_have_uploaded_image]' ".(($can_have_uploaded_image == 'on') ? 'checked="checked"' : '')." id='can_have_uploaded_image' />
  736. <label for='can_have_uploaded_image'> ".__('Users can upload images on single product page to purchase logs.', 'wpsc')."</label>
  737. <br />
  738. </td>
  739. </tr>";
  740. if(get_option('payment_gateway') == 'google') {
  741. $output .= "<tr>
  742. <td class='itemfirstcol' colspan='2'>
  743. <input type='checkbox' name='productmeta_values[google_prohibited]' id='add_google_prohibited' /> <label for='add_google_prohibited'>
  744. ".__('Prohibited', 'wpsc')."
  745. <a href='http://checkout.google.com/support/sell/bin/answer.py?answer=75724'>by Google?</a></label><br />
  746. </td>
  747. </tr>";
  748. }
  749. ob_start();
  750. do_action('wpsc_add_advanced_options', $product_data['id']);
  751. $output .= ob_get_contents();
  752. ob_end_clean();
  753. $output .= "
  754. <tr>
  755. <td class='itemfirstcol' colspan='2'><br />
  756. <strong>".__('Off Site Product Link', 'wpsc').":</strong><br />
  757. <small>".__('If this product is for sale on another website enter the link here. For instance if your product is an MP3 file for sale on itunes you could put the link here. This option over rides the buy now and add to cart links and takes you to the site linked here.', 'wpsc')."</small><br /><br />
  758. <label for='external_link'>".__('External Link', 'wpsc')."</label>:<br />
  759. <input type='text' class='text' name='productmeta_values[external_link]' value='".$external_link."' id='external_link' size='40' />
  760. </td>
  761. </tr>";
  762. if (get_option('wpsc_enable_comments') == 1) {
  763. $output .= "
  764. <tr>
  765. <td class='itemfirstcol' colspan='2'><br />
  766. <strong>".__('Enable IntenseDebate Comments', 'wpsc').":</strong><br />
  767. <select name='productmeta_values[enable_comments]'>
  768. <option value='' ". (($enable_comments == '') ? 'selected' : '') .">Use Default</option>
  769. <option value='yes' ". (($enable_comments == 'yes') ? 'selected' : '') .">Yes</option>
  770. <option value='no' ". (($enable_comments == 'no') ? 'selected' : '') .">No</option>
  771. </select>
  772. <br/>".__('Allow users to comment on this product.', 'wpsc')."
  773. </td>
  774. </tr>";
  775. }
  776. $output .= "
  777. </table></div></div>";
  778. return $output;
  779. }
  780. function wpsc_product_image_forms($product_data='') {
  781. global $closed_postboxes;
  782. if ($product_data == 'empty') {
  783. $display = "style='display:none;'";
  784. }
  785. //echo "<pre>".print_r($product_data,true)."</pre>";
  786. //As in WordPress, If Mac and mod_security, no Flash
  787. $flash = true;
  788. if ( (false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac')) && apache_mod_loaded('mod_security') ) {
  789. $flash = false;
  790. }
  791. $flash_action_url = admin_url('async-upload.php');
  792. $flash = apply_filters('flash_uploader', $flash);
  793. ?>
  794. <div id='wpsc_product_image_forms' class='postbox <?php echo ((array_search('wpsc_product_image_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search('wpsc_product_image_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : ''); ?> >
  795. <h3 class='hndle'> <?php echo __('Product Images', 'wpsc'); ?></h3>
  796. <div class='inside'>
  797. <?php if ( $flash ) : ?>
  798. <script type="text/javascript" >
  799. /* <![CDATA[ */
  800. jQuery("span#spanButtonPlaceholder").livequery(function() {
  801. swfu = new SWFUpload({
  802. button_text: '<span class="button"><?php _e('Select Files'); ?></span>',
  803. button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif; }',
  804. button_height: "24",
  805. button_width: "132",
  806. button_image_url: '<?php echo includes_url('images/upload.png'); ?>',
  807. button_placeholder_id: "spanButtonPlaceholder",
  808. upload_url : "<?php echo attribute_escape( $flash_action_url ); ?>",
  809. flash_url : "<?php echo includes_url('js/swfupload/swfupload.swf'); ?>",
  810. file_post_name: "async-upload",
  811. file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
  812. post_params : {
  813. "product_id" : parseInt(jQuery('#product_id').val()),
  814. "auth_cookie" : "<?php if ( is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>",
  815. "_wpnonce" : "<?php echo wp_create_nonce('product-swfupload'); ?>",
  816. "wpsc_admin_action" : "wpsc_add_image"
  817. },
  818. file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
  819. file_dialog_start_handler : wpsc_fileDialogStart,
  820. file_queued_handler : wpsc_fileQueued,
  821. upload_start_handler : wpsc_uploadStart,
  822. upload_progress_handler : wpsc_uploadProgress,
  823. upload_error_handler : wpsc_uploadError,
  824. upload_success_handler : wpsc_uploadSuccess,
  825. upload_complete_handler : wpsc_uploadComplete,
  826. file_queue_error_handler : wpsc_fileQueueError,
  827. file_dialog_complete_handler : wpsc_fileDialogComplete,
  828. swfupload_pre_load_handler: wpsc_swfuploadPreLoad,
  829. swfupload_load_failed_handler: wpsc_swfuploadLoadFailed,
  830. custom_settings : {
  831. degraded_element_id : "browser-image-uploader", // id of the element displayed when swfupload is unavailable
  832. swfupload_element_id : "flash-image-uploader" // id of the element displayed when swfupload is available
  833. },
  834. <?php
  835. if(defined('WPSC_ADD_DEBUG_PAGE') && (constant('WPSC_ADD_DEBUG_PAGE') == true)) {
  836. ?>
  837. debug: true
  838. <?php
  839. } else {
  840. ?>
  841. debug: false
  842. <?php
  843. }
  844. ?>
  845. });
  846. });
  847. /* ]]> */
  848. </script>
  849. <?php endif; ?>
  850. <div class='flash-image-uploader'>
  851. <span id='spanButtonPlaceholder'></span><br />
  852. <div id='media-items'> </div>
  853. <p><?php echo wpsc_check_memory_limit(); ?></p>
  854. <p><?php echo __('You are using the Flash uploader. Problems? Try the <a class="wpsc_upload_switcher" onclick=\'wpsc_upload_switcher("browser")\'>Browser uploader</a> instead.', 'wpsc'); ?></p>
  855. <?php
  856. if(! function_exists('gold_shpcrt_display_gallery') ) {
  857. ?>
  858. <p><?php _e('To upload multiple product thumbnails you must <a href="http://www.instinct.co.nz/shop/">install the premium upgrade</a>'); ?></p>
  859. <?php
  860. }
  861. ?>
  862. </div>
  863. <div class='browser-image-uploader'>
  864. <h4><?php _e("Select an image to upload:"); ?></h4>
  865. <ul>
  866. <li>
  867. <input type="file" value="" name="image" />
  868. <input type="hidden" value="1" name="image_resize" />
  869. </li>
  870. <li>
  871. <?php echo wpsc_check_memory_limit(); ?>
  872. </li>
  873. </ul>
  874. <p><?php echo __('You are using the Browser uploader. Problems? Try the <a class="wpsc_upload_switcher" onclick=\'wpsc_upload_switcher("flash")\'>Flash uploader</a> instead.', 'wpsc'); ?></p>
  875. <br />
  876. </div>
  877. <p><strong <?php echo $display; ?>><?php echo __('Manage your thumbnails', 'wpsc');?></strong></p>
  878. <?php
  879. edit_multiple_image_gallery($product_data);
  880. ?>
  881. </div>
  882. <div style='clear:both'></div>
  883. </div>
  884. <?php
  885. return $output;
  886. }
  887. function wpsc_product_download_forms($product_data='') {
  888. global $wpdb, $closed_postboxes;
  889. if ($product_data == 'empty') {
  890. $display = "style='display:none;'";
  891. }
  892. $output ='';
  893. $upload_max = wpsc_get_max_upload_size();
  894. $output .= "<div id='wpsc_product_download_forms' class='postbox ".((array_search('wpsc_product_download_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_download_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '').">";
  895. $output .= "<h3 class='hndle'>".__('Product Download', 'wpsc')."</h3>";
  896. $output .= "<div class='inside'>";
  897. $output .= "<h4>".__('Upload File', 'wpsc').":</h4>";
  898. $output .= "<input type='file' name='file' value='' /><br />".__('Max Upload Size', 'wpsc')." : <span>".$upload_max."</span><br /><br />";
  899. $output .= wpsc_select_product_file($product_data['id'])."<br />";
  900. if($product_data['file'] > 0) {
  901. $output .= __('Preview File', 'wpsc').": ";
  902. $output .= "<a class='admin_download' href='index.php?admin_preview=true&product_id=".$product_data['id']."' ><img align='absmiddle' src='".WPSC_URL."/images/download.gif' alt='' title='' /><span>".__('Click to download', 'wpsc')."</span></a>";
  903. $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data['file']."' LIMIT 1",ARRAY_A);
  904. if(($file_data != null) && (function_exists('listen_button'))) {
  905. $output .= "".listen_button($file_data['idhash'], $file_data['id'])."<br style='clear: both;' /><br />";
  906. }
  907. }
  908. if(function_exists("make_mp3_preview") || function_exists("wpsc_media_player")) {
  909. $output .="<h4>".__("Select an MP3 file to upload as a preview")."</h4>";
  910. $output .= "<input type='file' name='preview_file' value='' /><br />";
  911. $output .= "<br />";
  912. }
  913. $output .="</div></div>";
  914. return $output;
  915. }
  916. function wpsc_product_label_forms() {
  917. global $closed_postboxes;
  918. ?>
  919. <div id='wpsc_product_label_forms' class='postbox <?php echo ((array_search('wpsc_product_label_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : ''); ?>'>
  920. <?php
  921. if (function_exists('add_object_page')) {
  922. echo "<h3 class='hndle'>";
  923. } else {
  924. echo "<h3>
  925. <a class='togbox'>+</a>";
  926. }
  927. ?>
  928. <?php echo __('Label Control', 'wpsc'); ?>
  929. </h3>
  930. <div class='inside'>
  931. <table>
  932. <tr>
  933. <td colspan='2'>
  934. <?php echo __('Add Label', 'wpsc'); ?> :
  935. <a id='add_label'><?php echo __('Add Label', 'wpsc'); ?></a>
  936. </td>
  937. </tr>
  938. <tr>
  939. <td colspan='2'>
  940. <div id="labels">
  941. <table>
  942. <tr>
  943. <td><?=__('Label', 'wpsc')?> :</td>
  944. <td><input type="text" name="productmeta_values[labels][]"></td>
  945. </tr>
  946. <tr>
  947. <td><?=__('Label Description', 'wpsc')?> :</td>
  948. <td><textarea name="productmeta_values[labels_desc][]"></textarea></td>
  949. </tr>
  950. <tr>
  951. <td><?=__('Life Number', 'wpsc')?> :</td>
  952. <td><input type="text" name="productmeta_values[life_number][]"></td>
  953. </tr>
  954. <tr>
  955. <td><?=__('Item Number', 'wpsc')?> :</td>
  956. <td><input type="text" name="productmeta_values[item_number][]"></td>
  957. </tr>
  958. <tr>
  959. <td><?=__('Product Code', 'wpsc')?> :</td>
  960. <td><input type="text" name="productmeta_values[product_code][]"></td>
  961. </tr>
  962. <tr>
  963. <td><?=__('PDF', 'wpsc')?> :</td>
  964. <td><input type="file" name="pdf[]"></td>
  965. </tr>
  966. </table>
  967. </div>
  968. </td>
  969. </tr>
  970. </table></div></div>
  971. <?php
  972. }
  973. function edit_multiple_image_gallery($product_data) {
  974. global $wpdb;
  975. $siteurl = get_option('siteurl');
  976. if($product_data['id'] > 0) {
  977. $main_image = $wpdb->get_row("SELECT `images`.* FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product` ON `product`.`image` = `images`.`id` WHERE `product`.`id` = '{$product_data['id']}' LIMIT 1", ARRAY_A);
  978. }
  979. $timestamp = time();
  980. ?>
  981. <ul id="gallery_list" class="ui-sortable" style="position: relative;">
  982. <li class='first gallery_image' id='product_image_<?php echo $main_image['id']; ?>'>
  983. <input type='hidden' name='gallery_product_id[]' class='image-id' value='<?php echo $main_image['id']; ?>' />
  984. <div class='previewimage' id='gallery_image_<?php echo $main_image['id']; ?>'>
  985. <?php if ($main_image['image'] != '') { ?>
  986. <?php
  987. $image_data = getimagesize(WPSC_THUMBNAIL_DIR.$main_image['image']);
  988. ?>
  989. <a id='extra_preview_link_0' href='' title='' rel='product_extra_image_0' >
  990. <img class='previewimage' onclick='return false;' src='<?php echo WPSC_THUMBNAIL_URL.$main_image['image']; ?>' alt='<?php echo __('Preview', 'wpsc'); ?>' title='<?php echo __('Preview', 'wpsc'); ?>' />
  991. </a>
  992. <?php } ?>
  993. <?php
  994. echo wpsc_main_product_image_menu($product_data['id']);
  995. ?>
  996. </div>
  997. </li>
  998. <?php
  999. $num = 0;
  1000. if(function_exists('gold_shpcrt_display_gallery') && ($product_data['id'] > 0)) {
  1001. $values = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` = '{$product_data['id']}' AND `id` NOT IN ('{$main_image['id']}') ORDER BY image_order ASC",ARRAY_A);
  1002. //echo "<pre>".print_r($values,true)."</pre>";
  1003. if($values != null) {
  1004. foreach($values as $image) {
  1005. if(function_exists("getimagesize")) {
  1006. if($image['image'] != '') {
  1007. $num++;
  1008. $imagepath = WPSC_IMAGE_DIR . $image['image'];
  1009. $image_data = @getimagesize(WPSC_IMAGE_DIR.$image['image']);
  1010. ?>
  1011. <li id="product_image_<?php echo $image['id']; ?>" class='gallery_image'>
  1012. <input type='hidden' class='image-id' name='gallery_image_id[]' value='<?php echo $image['id']; ?>' />
  1013. <div class='previewimage' id='gallery_image_<?php echo $image['id']; ?>'>
  1014. <a id='extra_preview_link_<?php echo $image['id']; ?>' onclick='return false;' href='' rel='product_extra_image_<?php echo $image['id']; ?>' >
  1015. <img class='previewimage' src='<?php echo WPSC_IMAGE_URL.$image['image']; ?>' alt='<?php echo __('Preview', 'wpsc'); ?>' title='<?php echo __('Preview', 'wpsc'); ?>' />
  1016. </a>
  1017. <img alt='-' class='deleteButton' src='<?php echo WPSC_URL; ?>/images/cross.png' />
  1018. </div>
  1019. </li>
  1020. <?php
  1021. }
  1022. }