/** * generates row of table rate fields */ private function output_row($key = '', $shipping = '') { $currency = wpsc_get_currency_symbol(); $class = $this->alt ? 'class="alternate"' : ''; $this->alt = !$this->alt; ?> <tr> <td <?php echo $class; ?> > <div class="cell-wrapper"> <small><?php echo esc_html($currency); ?> </small> <input type="text" name="wpsc_shipping_tablerate_layer[]" value="<?php echo esc_attr($key); ?> " size="4" /> <small><?php _e(' and above', 'wpsc'); ?> </small> </div> </td> <td <?php echo $class; ?> > <div class="cell-wrapper"> <small><?php echo esc_html($currency); ?> </small> <input type="text" name="wpsc_shipping_tablerate_shipping[]" value="<?php echo esc_attr($shipping); ?> " size="4" /> <span class="actions"> <a tabindex="-1" title="<?php _e('Delete Layer', 'wpsc'); ?> " class="button-secondary wpsc-button-round wpsc-button-minus" href="#"><?php echo _x('–', 'delete item', 'wpsc'); ?> </a> <a tabindex="-1" title="<?php _e('Add Layer', 'wpsc'); ?> " class="button-secondary wpsc-button-round wpsc-button-plus" href="#"><?php echo _x('+', 'add item', 'wpsc'); ?> </a> </span> </div> </td> </tr> <?php }
/** * Create shipping price field * * @return string HTML snippet, a <tr> with two columns. */ function settings_form_shipping_price_field($id, $label, $value) { $output = "<tr><td>" . $label . "</td>"; $output .= "<td>"; $output .= esc_attr(wpsc_get_currency_symbol()); $output .= "<input size='4' type='text' name='shipping[" . esc_attr($id) . "]' value='" . esc_attr($value) . "'>"; $output .= "</td></tr>"; return $output; }
private function output_row($key = '', $shipping = '') { $currency = wpsc_get_currency_symbol(); $class = $this->alt ? ' class="alternate"' : ''; $this->alt = !$this->alt; ?> <tr> <td<?php echo $class; ?> > <div class="cell-wrapper"> <input type="text" name="wpsc_shipping_weightrate_layer[]" value="<?php echo esc_attr($key); ?> " size="4" /> <small><?php _e(' lbs and above', 'wpsc'); ?> </small> </div> </td> <td<?php echo $class; ?> > <div class="cell-wrapper"> <small><?php echo esc_html($currency); ?> </small> <input type="text" name="wpsc_shipping_weightrate_shipping[]" value="<?php echo esc_attr($shipping); ?> " size="4" /> <div class="actions"> <a tabindex="-1" title="<?php _e('Add Layer', 'wpsc'); ?> " class="action add" href="#"><?php _e('Add', 'wpsc'); ?> </a> <a tabindex="-1" title="<?php _e('Delete Layer', 'wpsc'); ?> " class="action delete" href="#"><?php _e('Delete', 'wpsc'); ?> </a> </div> </div> </td> </tr> <?php }
/** * * * @return unknown */ function getForm() { $output = ""; $output .= "<tr><th>" . __('Total Price', 'wpsc') . "</th><th>" . __('Shipping Price', 'wpsc') . "</th></tr>"; $layers = get_option("table_rate_layers"); if ($layers != '') { foreach ($layers as $key => $shipping) { $output .= "<tr class='rate_row'>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<i style='color: grey;'>" . __('If price is ', 'wpsc') . "</i>\n\t\t\t\t\t\t\t\t<input type='text' name='layer[]' value='{$key}' size='4' />\n\t\t\t\t\t\t\t\t<i style='color: grey;'> " . __(' and above', 'wpsc') . "</i>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t" . wpsc_get_currency_symbol() . "\n\t\t\t\t\t\t\t\t<input type='text' value='{$shipping}' name='shipping[]'\tsize='4'>\n\t\t\t\t\t\t\t\t <a href='#' class='delete_button' >" . __('Delete', 'wpsc') . "</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>"; } } $output .= "<input type='hidden' name='checkpage' value='table'>"; $output .= "<tr class='addlayer'><td colspan='2'>Layers: <a href='' style='cursor:pointer;' id='addlayer' >" . __('Add Layer', 'wpsc') . "</a></td></tr>"; return $output; }
function getForm() { // $output.="<table>"; $output .= "<tr><th>" . TXT_WPSC_TOTALPRICE . "</th><th>" . TXT_WPSC_SHIPPING_PRICE . "</th></tr>"; $layers = get_option("table_rate_layers"); if ($layers != '') { foreach ($layers as $key => $shipping) { $output .= "<tr class='rate_row'>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<i style='color: grey;'>" . TXT_WPSC_IF_PRICE_IS . "</i>\n\t\t\t\t\t\t\t\t<input type='text' name='layer[]' value='{$key}' size='4' />\n\t\t\t\t\t\t\t\t<i style='color: grey;'> " . TXT_WPSC_AND_ABOVE . "</i>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t" . wpsc_get_currency_symbol() . "\n\t\t\t\t\t\t\t\t<input type='text' value='{$shipping}' name='shipping[]' size='4'>\n\t\t\t\t\t\t\t\t <a href='#' class='delete_button' >" . TXT_WPSC_DELETE . "</a>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>"; } } $output .= "<input type='hidden' name='checkpage' value='table'>"; $output .= "<tr class='addlayer'><td colspan='2'>Layers: <a href='' style='cursor:pointer;' id='addlayer' >Add Layer</a></td></tr>"; // $output.="</table>"; return $output; }
/** * * * @return unknown */ function getForm() { $output = ""; $output .= "<tr><th>" . __('Total weight <br />(<abbr alt="You must enter the weight here in pounds, regardless of what you used on your products" title="You must enter the weight here in pounds, regardless of what you used on your products">in pounds</abbr>)', 'wpsc') . "</th><th>" . __('Shipping Price', 'wpsc') . "</th></tr>"; $layers = get_option("weight_rate_layers"); if ($layers != '') { foreach ($layers as $key => $shipping) { $output .= "<tr class='rate_row'><td >"; $output .= "<i style='color: grey;'>" . __('If weight is ', 'wpsc') . "</i><input type='text' value='{$key}' name='weight_layer[]'size='4'><i style='color: grey;'>" . __(' and above', 'wpsc') . "</i></td><td>" . wpsc_get_currency_symbol() . "<input type='text' value='" . esc_attr($shipping) . "' name='weight_shipping[]' size='4'> <a href='#' class='delete_button' >" . __('Delete', 'wpsc') . "</a></td></tr>"; } } $output .= "<input type='hidden' name='checkpage' value='weight'>"; $output .= "<tr class='addlayer'><td colspan='2'>Layers: <a style='cursor:pointer;' id='addweightlayer' >Add Layer</a></td></tr>"; return $output; }
function wpsc_quarterly_dashboard_widget() { if (get_option('wpsc_business_year_start') == false) { ?> <form action='' method='post'> <label for='date_start'><?php _e('Financial Year End', 'wpsc'); ?> : </label> <input id='date_start' type='text' class='pickdate' size='11' value='<?php echo get_option('wpsc_last_date'); ?> ' name='add_start' /> <!--<select name='add_start[day]'> <?php for ($i = 1; $i <= 31; ++$i) { $selected = ''; if ($i == date("d")) { $selected = "selected='selected'"; } echo "<option {$selected} value='{$i}'>{$i}</option>"; } ?> </select> <select name='add_start[month]'> <?php for ($i = 1; $i <= 12; ++$i) { $selected = ''; if ($i == (int) date("m")) { $selected = "selected='selected'"; } echo "<option {$selected} value='{$i}'>" . date("M", mktime(0, 0, 0, $i, 1, date("Y"))) . "</option>"; } ?> </select> <select name='add_start[year]'> <?php for ($i = date("Y"); $i <= date("Y") + 12; ++$i) { $selected = ''; if ($i == date("Y")) { $selected = "selected='true'"; } echo "<option {$selected} value='{$i}'>" . $i . "</option>"; } ?> </select>--> <input type='hidden' name='wpsc_admin_action' value='wpsc_quarterly' /> <input type='submit' class='button primary' value='Submit' name='wpsc_submit' /> </form> <?php if (get_option('wpsc_first_quart') != '') { $firstquarter = get_option('wpsc_first_quart'); $secondquarter = get_option('wpsc_second_quart'); $thirdquarter = get_option('wpsc_third_quart'); $fourthquarter = get_option('wpsc_fourth_quart'); $finalquarter = get_option('wpsc_final_quart'); $revenue = wpsc_get_quarterly_summary(); $currsymbol = wpsc_get_currency_symbol(); foreach ($revenue as $rev) { if ($rev == '') { $totals[] = '0.00'; } else { $totals[] = $rev; } } ?> <div id='box'> <p class='atglance'> <span class='wpsc_quart_left'><?php _e('At a Glance', 'wpsc'); ?> </span> <span class='wpsc_quart_right'><?php _e('Revenue', 'wpsc'); ?> </span> </p> <div style='clear:both'></div> <p class='quarterly'> <span class='wpsc_quart_left'><strong>01</strong> (<?php echo date('M Y', $thirdquarter) . ' - ' . date('M Y', $fourthquarter); ?> )</span> <span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[0]; ?> </span></p> <p class='quarterly'> <span class='wpsc_quart_left'><strong>02</strong> (<?php echo date('M Y', $secondquarter) . ' - ' . date('M Y', $thirdquarter); ?> )</span> <span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[1]; ?> </span></p> <p class='quarterly'> <span class='wpsc_quart_left'><strong>03</strong> (<?php echo date('M Y', $firstquarter) . ' - ' . date('M Y', $secondquarter); ?> )</span> <span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[2]; ?> </span></p> <p class='quarterly'> <span class='wpsc_quart_left'><strong>04</strong> (<?php echo date('M Y', $finalquarter) . ' - ' . date('M Y', $firstquarter); ?> )</span> <span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[3]; ?> </span> </p> <div style='clear:both'></div> </div> <?php } } }
function wpsc_dashboard_4months_widget() { global $wpdb; $this_year = date("Y"); //get current year and month $this_month = date("n"); $months[] = mktime(0, 0, 0, $this_month - 3, 1, $this_year); //generate unix time stamps fo 4 last months $months[] = mktime(0, 0, 0, $this_month - 2, 1, $this_year); $months[] = mktime(0, 0, 0, $this_month - 1, 1, $this_year); $months[] = mktime(0, 0, 0, $this_month, 1, $this_year); $prodsql = "SELECT `" . WPSC_TABLE_CART_CONTENTS . "`.`prodid` FROM `" . WPSC_TABLE_CART_CONTENTS . "` INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` ON `" . WPSC_TABLE_CART_CONTENTS . "`.`purchaseid` = `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id` WHERE `" . WPSC_TABLE_PURCHASE_LOGS . "`.`processed` >= 2 AND `" . WPSC_TABLE_PURCHASE_LOGS . "`.`date` >= " . $months[0] . " GROUP BY `" . WPSC_TABLE_CART_CONTENTS . "`.`prodid` ORDER BY SUM(`" . WPSC_TABLE_CART_CONTENTS . "`.`price` * `" . WPSC_TABLE_CART_CONTENTS . "`.`quantity`) DESC LIMIT 4"; $products = $wpdb->get_results($prodsql, ARRAY_A); //get 4 products with top income in 4 last months. $timeranges[0]["start"] = mktime(0, 0, 0, $this_month - 3, 1, $this_year); //make array of time ranges $timeranges[0]["end"] = mktime(0, 0, 0, $this_month - 2, 1, $this_year); $timeranges[1]["start"] = mktime(0, 0, 0, $this_month - 2, 1, $this_year); $timeranges[1]["end"] = mktime(0, 0, 0, $this_month - 1, 1, $this_year); $timeranges[2]["start"] = mktime(0, 0, 0, $this_month - 1, 1, $this_year); $timeranges[2]["end"] = mktime(0, 0, 0, $this_month, 1, $this_year); $timeranges[3]["start"] = mktime(0, 0, 0, $this_month, 1, $this_year); $timeranges[3]["end"] = mktime(); foreach ((array) $products as $product) { //run trough products and get each product income amounts and name foreach ($timeranges as $timerange) { //run trough time ranges of product, and get its income over each time range $prodsql = "SELECT SUM(`" . WPSC_TABLE_CART_CONTENTS . "`.`price` * `" . WPSC_TABLE_CART_CONTENTS . "`.`quantity`) AS sum FROM `" . WPSC_TABLE_CART_CONTENTS . "` INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` ON `" . WPSC_TABLE_CART_CONTENTS . "`.`purchaseid` = `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id` WHERE `" . WPSC_TABLE_PURCHASE_LOGS . "`.`processed` >= 2 AND `" . WPSC_TABLE_PURCHASE_LOGS . "`.`date` >= " . $timerange["start"] . " AND `" . WPSC_TABLE_PURCHASE_LOGS . "`.`date` < " . $timerange["end"] . " AND `" . WPSC_TABLE_CART_CONTENTS . "`.`prodid` = " . $product['prodid'] . " GROUP BY `" . WPSC_TABLE_CART_CONTENTS . "`.`prodid` LIMIT 1"; //get the amount of income that current product has generaterd over current time range $sum = $wpdb->get_results($prodsql, ARRAY_A); $sums[] = $sum[0]["sum"]; //push amount to array } $namesql = "SELECT `" . WPSC_TABLE_PRODUCT_LIST . "`.`name` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `" . WPSC_TABLE_PRODUCT_LIST . "`.`id` = " . $product['prodid']; $name = $wpdb->get_results($namesql, ARRAY_A); $prod_data[] = array($sums, $name[0]["name"]); //result: array of 2: $prod_data[0] = array(income) $sums = array(); //reset array //$prod_data[1] = product name } $tablerow = 1; $output .= '<div style="padding-bottom:15px; ">Last four months of sales on a per product basis:</div> <table style="width:100%" border="0" cellspacing="0"> <tr style="font-style:italic; color:#666;" height="20"> <td colspan="2" style=" font-family:\'Times New Roman\', Times, serif; font-size:15px; border-bottom:solid 1px #000;">At a Glance</td>'; foreach ($months as $mnth) { $output .= '<td align="center" style=" font-family:\'Times New Roman\'; font-size:15px; border-bottom:solid 1px #000;">' . date("M", $mnth) . '</td>'; } $output .= '</tr>'; foreach ((array) $prod_data as $product) { $output .= '<tr height="20"> <td width="20" style="font-weight:bold; color:#008080; border-bottom:solid 1px #000;">' . $tablerow . '</td> <td style="border-bottom:solid 1px #000;width:60px">' . $product[1] . '</td>'; $currsymbol = wpsc_get_currency_symbol(); $tablerow++; foreach ($product[0] as $amount) { $output .= '<td align="center" style="border-bottom:solid 1px #000;">' . $currsymbol . number_format(absint($amount), 2) . '</td>'; } $output .= '</tr>'; } $output .= '</table>'; echo $output; }