Example #1
0
 public function buy_product($id, $amount, $product, $user_id, $user_money)
 {
     //Market Update
     $this->db->set('amount', 'amount -' . $amount, FALSE);
     $this->db->where('id', $id);
     $this->db->update('market');
     //Company Update
     $this->db->select('money');
     $query = $this->db->get_where('companies', array('id' => $product->company_id), 1);
     if ($query->num_rows() === 1) {
         foreach ($query->result() as $company) {
         }
     } else {
         $return = NULL;
         log_message('error', 'function buy_product() in /megapublik/models/market_m.php has received bad data for $product->company_id.');
     }
     $company_money = unserialize($company->money);
     $currency_money = money($company_money, $product->currency);
     $new_money[$product->currency] = round($currency_money + $amount * $product->price, 2);
     $company_money = array_merge($company_money, $new_money);
     $this->db->set('money', serialize($company_money));
     $this->db->where('id', $product->company_id);
     $this->db->update('companies');
     //User Update
     $currency_money = money($user_money, $product->currency);
     $new_money[$product->currency] = round($currency_money - $amount * $product->price, 2);
     $user_money = array_merge($user_money, $new_money);
     $this->db->set('money', serialize($user_money));
     $this->db->where('id', $user_id);
     $this->db->update('users');
     log_message('debug', number_format($amount, 0, '.', ',') . ' products bought with type "' . $product->type . '" and price "' . number_format($product->price, 2, '.', ',') . ' ' . $product->currency . '" by user with ID "' . $user_id . '"');
     return TRUE;
 }
Example #2
0
function save_meta_box ($Customer) {
?>
<div id="misc-publishing-actions">
<p><strong><a href="<?php echo esc_url(add_query_arg(array('page'=>'ecart-orders','customer'=>$Customer->id),admin_url('admin.php'))); ?>"><?php _e('Orders','Ecart'); ?></a>: </strong><?php echo $Customer->orders; ?> &mdash; <strong><?php echo money($Customer->total); ?></strong></p>
<p><strong><a href="<?php echo esc_url( add_query_arg(array('page'=>'ecart-customers','range'=>'custom','start'=>date('n/j/Y',$Customer->created),'end'=>date('n/j/Y',$Customer->created)),admin_url('admin.php'))); ?>"><?php _e('Joined','Ecart'); ?></a>: </strong><?php echo date(get_option('date_format'),$Customer->created); ?></p>
<?php do_action('ecart_customer_editor_info',$Customer); ?>
</div>
<div id="major-publishing-actions">
	<input type="submit" class="button-primary" name="save" value="<?php _e('Save Changes','Ecart'); ?>" />
</div>
<?php
}
function money($boekhouding)
{
    if ($boekhouding["jaar"] <= $boekhouding["tijd"]) {
        $extra = floor($boekhouding["rente"] / 100 * $boekhouding["bigspending"]);
        $boekhouding["bigspending"] += $extra;
        $boekhouding["bkhdn"][$boekhouding["jaar"]] = "bedrag = " . $boekhouding["bigspending"] . "€ waaruit " . $extra . "€ de rente is";
        $boekhouding["jaar"]++;
        return money($boekhouding);
    } else {
        return $boekhouding;
    }
}
function money($spending, $rente, $tijd)
{
    static $jaar = 1;
    static $boekhouding = array();
    //anders werkt het ni, static nog eens nachecken!
    if ($jaar <= $tijd) {
        $extra = floor($rente / 100 * $spending);
        $bigspending = $spending + $extra;
        $boekhouding[$jaar] = "bedrag = " . $bigspending . "€ waaruit " . $extra . "€ de rente is";
        $jaar++;
        //niet met tijd-- want dan hebt ge maar 50% vd antwoorden
        return money($bigspending, $rente, $tijd);
    } else {
        return $boekhouding;
    }
}
Example #5
0
 public function setComparisonInfo($numItems, $cost)
 {
     global $overviewSavedDisplay;
     if ($this->numItems > $numItems) {
         throw new GetchabooksError("PriceSet::setComparisonInfo called with" . "inconsistent \$numItems.");
     } else {
         if ($this->numItems == $numItems) {
             $this->isComplete = true;
         } else {
             $this->isComplete = false;
         }
     }
     if ($cost) {
         $this->amountSaved = max(0, $cost - $this->total);
         $this->percentSaved = round(100 * $this->amountSaved / $cost, 0);
         if ($overviewSavedDisplay == 'percent') {
             $this->saved = $this->percentSaved . '%';
         } else {
             $this->saved = '$' . money($this->amountSaved);
         }
     } else {
         $this->saved = '';
     }
 }
Example #6
0
	/**
	 * Provides support for the ecart('cartitem') tags
	 * 
	 * @since 1.1
	 *
	 * @return mixed
	 **/
	function tag ($id,$property,$options=array()) {
		global $Ecart;

		// Return strings with no options
		switch ($property) {
			case "id": return $id;
			case "product": return $this->product;
			case "name": return $this->name;
			case "type": return $this->type;
			case "link":
			case "url":
				return ecarturl(ECART_PRETTYURLS?$this->slug:array('ecart_pid'=>$this->product));
			case "sku": return $this->sku;
		}

		$taxes = isset($options['taxes'])?value_is_true($options['taxes']):null;
		if (in_array($property,array('price','newprice','unitprice','total','tax','options')))
			$taxes = ecart_taxrate($taxes,$this->taxable,$this) > 0?true:false;

		// Handle currency values
		$result = "";
		switch ($property) {
			case "discount": $result = (float)$this->discount; break;
			case "unitprice": $result = (float)$this->unitprice+($taxes?$this->unittax:0); break;
			case "unittax": $result = (float)$this->unittax; break;
			case "discounts": $result = (float)$this->discounts; break;
			case "tax": $result = (float)$this->tax; break;
			case "total": $result = (float)$this->total+($taxes?($this->unittax*$this->quantity):0); break;
		}
		if (is_float($result)) {
			if (isset($options['currency']) && !value_is_true($options['currency'])) return $result;
			else return money($result);
		}

		// Handle values with complex options
		switch ($property) {
			case "taxrate": return percentage($this->taxrate*100,array('precision' => 1)); break;
			case "quantity":
				$result = $this->quantity;
				if ($this->type == "Donation" && $this->donation['var'] == "on") return $result;
				if (isset($options['input']) && $options['input'] == "menu") {
					if (!isset($options['value'])) $options['value'] = $this->quantity;
					if (!isset($options['options']))
						$values = "1-15,20,25,30,35,40,45,50,60,70,80,90,100";
					else $values = $options['options'];

					if (strpos($values,",") !== false) $values = explode(",",$values);
					else $values = array($values);
					$qtys = array();
					foreach ($values as $value) {
						if (strpos($value,"-") !== false) {
							$value = explode("-",$value);
							if ($value[0] >= $value[1]) $qtys[] = $value[0];
							else for ($i = $value[0]; $i < $value[1]+1; $i++) $qtys[] = $i;
						} else $qtys[] = $value;
					}
					$result = '<select name="items['.$id.']['.$property.']">';
					foreach ($qtys as $qty)
						$result .= '<option'.(($qty == $this->quantity)?' selected="selected"':'').' value="'.$qty.'">'.$qty.'</option>';
					$result .= '</select>';
				} elseif (isset($options['input']) && valid_input($options['input'])) {
					if (!isset($options['size'])) $options['size'] = 5;
					if (!isset($options['value'])) $options['value'] = $this->quantity;
					$result = '<input type="'.$options['input'].'" name="items['.$id.']['.$property.']" id="items-'.$id.'-'.$property.'" '.inputattrs($options).'/>';
				} else $result = $this->quantity;
				break;
			case "remove":
				$label = __("Remove");
				if (isset($options['label'])) $label = $options['label'];
				if (isset($options['class'])) $class = ' class="'.$options['class'].'"';
				else $class = ' class="remove"';
				if (isset($options['input'])) {
					switch ($options['input']) {
						case "button":
							$result = '<button type="submit" name="remove['.$id.']" value="'.$id.'"'.$class.' tabindex="">'.$label.'</button>'; break;
						case "checkbox":
						    $result = '<input type="checkbox" name="remove['.$id.']" value="'.$id.'"'.$class.' tabindex="" title="'.$label.'"/>'; break;
					}
				} else {
					$result = '<a href="'.href_add_query_arg(array('cart'=>'update','item'=>$id,'quantity'=>0),ecarturl(false,'cart')).'"'.$class.'>'.$label.'</a>';
				}
				break;
			case "optionlabel": $result = $this->option->label; break;
			case "options":
				$class = "";
				if (!isset($options['before'])) $options['before'] = '';
				if (!isset($options['after'])) $options['after'] = '';
				if (isset($options['show']) &&
					strtolower($options['show']) == "selected")
					return (!empty($this->option->label))?
						$options['before'].$this->option->label.$options['after']:'';

				if (isset($options['class'])) $class = ' class="'.$options['class'].'" ';
				if (count($this->variations) > 1) {
					$result .= $options['before'];
					$result .= '<input type="hidden" name="items['.$id.'][product]" value="'.$this->product.'"/>';
					$result .= ' <select name="items['.$id.'][price]" id="items-'.$id.'-price"'.$class.'>';
					$result .= $this->options($this->priceline);
					$result .= '</select>';
					$result .= $options['after'];
				}
				break;
			case "addons-list":
			case "addonslist":
				if (empty($this->addons)) return false;
				$defaults = array(
					'before' => '',
					'after' => '',
					'class' => '',
					'exclude' => '',
					'prices' => true,

				);
				$options = array_merge($defaults,$options);
				extract($options);

				$classes = !empty($class)?' class="'.join(' ',$class).'"':'';
				$excludes = explode(',',$exclude);
				$prices = value_is_true($prices);

				$result .= $before.'<ul'.$classes.'>';
				foreach ($this->addons as $id => $addon) {
					if (in_array($addon->label,$excludes)) continue;

					$price = ($addon->onsale?$addon->promoprice:$addon->price);
					if ($this->taxrate > 0) $price = $price+($price*$this->taxrate);

					if ($prices) $pricing = " (".($addon->unitprice < 0?'-':'+').money($price).")";
					$result .= '<li>'.$addon->label.$pricing.'</li>';
				}
				$result .= '</ul>'.$after;
				return $result;
				break;
			case "hasinputs":
			case "has-inputs": return (count($this->data) > 0); break;
			case "inputs":
				if (!isset($this->_data_loop)) {
					reset($this->data);
					$this->_data_loop = true;
				} else next($this->data);

				if (current($this->data) !== false) return true;
				else {
					unset($this->_data_loop);
					reset($this->data);
					return false;
				}
				break;
			case "input":
				$data = current($this->data);
				$name = key($this->data);
				if (isset($options['name'])) return $name;
				return $data;
				break;
			case "inputs-list":
			case "inputslist":
				if (empty($this->data)) return false;
				$before = ""; $after = ""; $classes = ""; $excludes = array();
				if (!empty($options['class'])) $classes = ' class="'.$options['class'].'"';
				if (!empty($options['exclude'])) $excludes = explode(",",$options['exclude']);
				if (!empty($options['before'])) $before = $options['before'];
				if (!empty($options['after'])) $after = $options['after'];

				$result .= $before.'<ul'.$classes.'>';
				foreach ($this->data as $name => $data) {
					if (in_array($name,$excludes)) continue;
					$result .= '<li><strong>'.$name.'</strong>: '.$data.'</li>';
				}
				$result .= '</ul>'.$after;
				return $result;
				break;
			case "coverimage":
			case "thumbnail":
				$defaults = array(
					'class' => '',
					'width' => 48,
					'height' => 48,
					'size' => false,
					'fit' => false,
					'sharpen' => false,
					'quality' => false,
					'bg' => false,
					'alt' => false,
					'title' => false
				);

				$options = array_merge($defaults,$options);
				extract($options);

				if ($this->image !== false) {
					$img = $this->image;

					if ($size !== false) $width = $height = $size;
					$scale = (!$fit)?false:esc_attr(array_search($fit,$img->_scaling));
					$sharpen = (!$sharpen)?false:esc_attr(min($sharpen,$img->_sharpen));
					$quality = (!$quality)?false:esc_attr(min($quality,$img->_quality));
					$fill = (!$bg)?false:esc_attr(hexdec(ltrim($bg,'#')));
					$scaled = $img->scaled($width,$height,$scale);

					$alt = empty($alt)?$img->alt:$alt;
					$title = empty($title)?$img->title:$title;
					$title = empty($title)?'':' title="'.esc_attr($title).'"';
					$class = !empty($class)?' class="'.esc_attr($class).'"':'';

					if (!empty($options['title'])) $title = ' title="'.esc_attr($options['title']).'"';
					$alt = esc_attr(!empty($img->alt)?$img->alt:$this->name);
					return '<img src="'.add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),ecarturl($img->id,'images')).'"'.$title.' alt="'.$alt.'" width="'.$scaled['width'].'" height="'.$scaled['height'].'"'.$class.' />';
				}
				break;

		}
		if (!empty($result)) return $result;

		return false;
	}
Example #7
0
                 }
             }
         }
     }
 } else {
     if ($action == 'changesex') {
         if (!$config['chars_changesex_enable']) {
             output_message('alert', 'Смена пола персонажей запрещена!' . '<meta http-equiv=refresh content="2;url=index.php?n=account&sub=chars">');
         } else {
             if ($timediffh < $config['chars_changesex_hdiff'] and !$isadmin) {
                 $timenext = $timeaction + 3600 * $config['chars_changesex_hdiff'];
                 $timenextf = date('Y-m-d H:i:s', $timenext);
                 output_message('alert', 'Слишком часто меняете пол! <br /> Следующая смена возможна: ' . $timenextf . '<meta http-equiv=refresh content="2;url=index.php?n=account&sub=chars">');
             } else {
                 if ($my_char->money < $config['chars_changesex_cost'] and !$isadmin) {
                     output_message('alert', 'Недостаточно средств для смены пола персонажа!<br />Есть: ' . money($my_char->money) . '<br />Нужно: ' . money($config['chars_rename_cost']) . '<meta http-equiv=refresh content="2;url=index.php?n=account&sub=chars">');
                 } else {
                     $WSDB->query("INSERT INTO `mwfe3_character_actions` \n                                (`guid`, `account`, `action`, `timeaction`, `data`) \n                                VALUES\n                                (?d,?d,?,?,?);", $my_char->guid, $user['id'], $action, $timecurrf, $my_char->sqlinfo['data']);
                     $my_char->ChangeGender($mangos_field, $char_models);
                     $my_char->MoneyAdd(-$config['chars_changesex_cost'], $mangos_field);
                     $WSDB->query("UPDATE `characters` SET ?a WHERE account=?d and `guid`=?d LIMIT 1", $my_char->sqlinfo, $user['id'], $my_char->guid);
                     output_message('notice', 'Операция по смене пола прошла успешно!' . '<meta http-equiv=refresh content="2;url=index.php?n=account&sub=chars">');
                 }
             }
         }
     } else {
         if ($action == 'changesexfix') {
             $WSDB->query("INSERT INTO `mwfe3_character_actions` \n                      (`guid`, `account`, `action`, `timeaction`, `data`) \n                        VALUES\n                      (?d,?d,?,?,?);", $my_char->guid, $user['id'], $action, $timecurrf, $my_char->sqlinfo['data']);
             $my_char->ChangeGenderFix($mangos_field, $char_models);
             $WSDB->query("UPDATE `characters` SET `data`=?a WHERE account=?d and `guid`=?d LIMIT 1", $my_char->sqlinfo, $user['id'], $my_char->guid);
             output_message('notice', 'Фикс после смены пола персонажа выполнен успешно!' . '<meta http-equiv=refresh content="2;url=index.php?n=account&sub=chars">');
Example #8
0
            $debt = array();
            $debt['amount_to_pay'] = money($row['DebtInfo']['attr']['amountToPay']);
            $debt['debt'] = money($row['DebtInfo']['attr']['debt']);
            $debt['service_name'] = isset($row['ServiceName']['value']) ? $row['ServiceName']['value'] : '';
            $debt['service_code'] = isset($row['attr']['serviceCode']) ? $row['attr']['serviceCode'] : '';
            $debt['service_price'] = isset($row['attr']['metersGlobalTarif']) ? money($row['attr']['metersGlobalTarif']) : '';
            $debt['destination'] = isset($row['Destination']['value']) ? $row['Destination']['value'] : '';
            $debt['num'] = $row['PayerInfo']['attr']['ls'];
            $debt['year'] = $row['DebtInfo']['Year']['value'];
            $debt['month'] = $row['DebtInfo']['Month']['value'];
            $debt['charge'] = money($row['DebtInfo']['Charge']['value']);
            $debt['balance'] = money($row['DebtInfo']['Balance']['value']);
            $debt['recalc'] = money($row['DebtInfo']['Recalc']['value']);
            $debt['subsidies'] = money($row['DebtInfo']['Subsidies']['value']);
            $debt['remission'] = money($row['DebtInfo']['Remission']['value']);
            $debt['lastPaying'] = money($row['DebtInfo']['LastPaying']['value']);
            $debt['company_name'] = $row['CompanyInfo']['CompanyName']['value'];
            $debt['company_mfo'] = isset($row['CompanyInfo']['attr']['mfo']) ? $row['CompanyInfo']['attr']['mfo'] : '';
            $debt['company_okpo'] = isset($row['CompanyInfo']['attr']['okpo']) ? $row['CompanyInfo']['attr']['okpo'] : '';
            $debt['company_accnt'] = isset($row['CompanyInfo']['attr']['account']) ? $row['CompanyInfo']['attr']['account'] : '';
            $debts[] = $debt;
            $services[$debt['service_code']] = $debt;
        }
        $_SESSION['services'] = $services;
        $smarty->assign('debts', $debts);
        $smarty->assign('payer_info', $payerInfo);
    }
}
$gs = isset($_GET['search']) ? $_GET['search'] : '';
$smarty->assign('error_msg', $errorMessage);
$smarty->assign('search', $search);
Example #9
0
    ?>
</td>
                        <td><?php 
    echo cny($v->normal_return_profit_volume);
    ?>
</td>
                        <td><?php 
    echo cny($v->invite_return_profit_volume);
    ?>
</td>
                        <!--<td><?php 
    //=cny($v->delay_return_profit_volume);
    ?>
</td>-->
                        <td>¥<?php 
    echo bcadd(bcadd(money($v->normal_return_profit_volume), 0, 2), money($v->invite_return_profit_volume), 2);
    ?>
</td>
                        <td><?php 
    echo $v->order_quantity;
    ?>
</td>
                    </tr>
                <?php 
}
?>
            </table>
            <div class="page"><?php 
echo $page;
?>
</div>
        $location .= $Customer->state;
        if (!empty($location) && !empty($Customer->country)) {
            $location .= ' &mdash; ';
        }
        $location .= $Customer->country;
        echo $location;
        ?>
</td>
			<td class="total column-total<?php 
        echo in_array('total', $hidden) ? ' hidden' : '';
        ?>
"><?php 
        echo $Customer->orders;
        ?>
 &mdash; <?php 
        echo money($Customer->total);
        ?>
</td>
			<td class="date column-date<?php 
        echo in_array('date', $hidden) ? ' hidden' : '';
        ?>
"><?php 
        echo date("Y/m/d", mktimestamp($Customer->created));
        ?>
</td>
		</tr>
		<?php 
    }
    ?>
		</tbody>
	<?php 
Example #11
0
 /**
  * Displays all of the product addons for the cart item in an unordered list
  *
  * @api `shopp('cartitem.addons-list')`
  * @since 1.1
  *
  * @param string        $result  The output
  * @param array         $options The options
  * - **before**: ` ` Markup to add before the list
  * - **after**: ` ` Markup to add after the list
  * - **class**: The class attribute specifies one or more class-names for the list
  * - **exclude**: Used to specify addon labels to exclude from the list. Multiple addons can be excluded by separating them with a comma: `Addon Label 1,Addon Label 2...`
  * - **separator**: `: ` The separator to use between the menu name and the addon options
  * - **prices**: `on` (on, off) Shows or hides prices with the addon label
  * - **taxes**: `on` (on, off) Include taxes in the addon option price shown when `prices=on`
  * @param ShoppCartItem $O       The working object
  * @return string The addon list markup
  **/
 public static function addons_list($result, $options, $O)
 {
     if (empty($O->addons)) {
         return false;
     }
     $defaults = array('before' => '', 'after' => '', 'class' => '', 'exclude' => '', 'separator' => ': ', 'prices' => true, 'taxes' => shopp_setting('tax_inclusive'));
     $options = array_merge($defaults, $options);
     extract($options);
     $classes = !empty($class) ? ' class="' . esc_attr($class) . '"' : '';
     $excludes = explode(',', $exclude);
     $prices = Shopp::str_true($prices);
     $taxes = Shopp::str_true($taxes);
     // Get the menu labels list and addon options to menus map
     list($menus, $menumap) = self::_addon_menus();
     $result .= $before . '<ul' . $classes . '>';
     foreach ($O->addons as $id => $addon) {
         if (in_array($addon->label, $excludes)) {
             continue;
         }
         $menu = isset($menumap[$addon->options]) ? $menus[$menumap[$addon->options]] . $separator : false;
         $price = Shopp::str_true($addon->sale) ? $addon->promoprice : $addon->price;
         if ($taxes && $O->taxrate > 0) {
             $price = $price + $price * $O->taxrate;
         }
         if ($prices) {
             $pricing = " (" . ($addon->price < 0 ? '-' : '+') . money($price) . ')';
         }
         $result .= '<li>' . $menu . $addon->label . $pricing . '</li>';
     }
     $result .= '</ul>' . $after;
     return $result;
 }
Example #12
0
	function tag ($property,$options=array()) {
		global $Ecart;

		$select_attrs = array('title','required','class','disabled','required','size','tabindex','accesskey');
		$submit_attrs = array('title','class','value','disabled','tabindex','accesskey');

		switch ($property) {
			case "link":
			case "url":
				return ecarturl(ECART_PRETTYURLS?$this->slug:array('ecart_pid'=>$this->id));
				break;
			case "found":
				if (empty($this->id)) return false;
				$load = array('prices','images','specs','tags','categories');
				if (isset($options['load'])) $load = explode(",",$options['load']);
				$this->load_data($load);
				return true;
				break;
			case "relevance": return (string)$this->score; break;
			case "id": return $this->id; break;
			case "name": return apply_filters('ecart_product_name',$this->name); break;
			case "slug": return $this->slug; break;
			case "summary": return apply_filters('ecart_product_summary',$this->summary); break;
			case "description":
				return apply_filters('ecart_product_description',$this->description);
			case "isfeatured":
			case "is-featured":
				return ($this->featured == "on"); break;
			case "price":
			case "saleprice":
				if (empty($this->prices)) $this->load_data(array('prices'));
				$defaults = array(
					'taxes' => null,
					'starting' => ''
				);
				$options = array_merge($defaults,$options);
				extract($options);

				if (!is_null($taxes)) $taxes = value_is_true($taxes);

				$min = $this->min[$property];
				$mintax = $this->min[$property.'_tax'];

				$max = $this->max[$property];
				$maxtax = $this->max[$property.'_tax'];

				$taxrate = ecart_taxrate($taxes,$this->prices[0]->tax,$this);

				if ("saleprice" == $property) $pricetag = $this->prices[0]->promoprice;
				else $pricetag = $this->prices[0]->price;

				if (count($this->options) > 0) {
					$taxrate = ecart_taxrate($taxes,true,$this);
					$mintax = $mintax?$min*$taxrate:0;
					$maxtax = $maxtax?$max*$taxrate:0;

					if ($min == $max) return money($min+$mintax);
					else {
						if (!empty($starting)) return "$starting ".money($min+$mintax);
						return money($min+$mintax)." &mdash; ".money($max+$maxtax);
					}
				} else return money($pricetag+($pricetag*$taxrate));

				break;
			case "taxrate":
				return ecart_taxrate(null,true,$this);
				break;
			case "weight":
				if(empty($this->prices)) $this->load_data(array('prices'));
				$defaults = array(
					'unit' => $Ecart->Settings->get('weight_unit'),
					'min' => $this->min['weight'],
					'max' => $this->max['weight'],
					'units' => true,
					'convert' => false
				);
				$options = array_merge($defaults,$options);
				extract($options);

				if(!isset($this->min['weight'])) return false;

				if ($convert !== false) {
					$min = convert_unit($min,$convert);
					$max = convert_unit($max,$convert);
					if (is_null($units)) $units = true;
					$unit = $convert;
				}

				$range = false;
				if ($min != $max) {
					$range = array($min,$max);
					sort($range);
				}

				$string = ($min == $max)?round($min,3):round($range[0],3)." - ".round($range[1],3);
				$string .= value_is_true($units) ? " $unit" : "";
				return $string;
				break;
			case "onsale":
				if (empty($this->prices)) $this->load_data(array('prices'));
				if (empty($this->prices)) return false;
				return $this->onsale;
				break;
			case "has-savings": return ($this->onsale && $this->min['saved'] > 0); break;
			case "savings":
				if (empty($this->prices)) $this->load_data(array('prices'));
				if (!isset($options['taxes'])) $options['taxes'] = null;

				$taxrate = ecart_taxrate($options['taxes']);
				$range = false;

				if (!isset($options['show'])) $options['show'] = '';
				if ($options['show'] == "%" || $options['show'] == "percent") {
					if ($this->options > 1) {
						if (round($this->min['savings']) != round($this->max['savings'])) {
							$range = array($this->min['savings'],$this->max['savings']);
							sort($range);
						}
						if (!$range) return percentage($this->min['savings'],array('precision' => 0)); // No price range
						else return percentage($range[0],array('precision' => 0))." &mdash; ".percentage($range[1],array('precision' => 0));
					} else return percentage($this->max['savings'],array('precision' => 0));
				} else {
					if ($this->options > 1) {
						if (round($this->min['saved']) != round($this->max['saved'])) {
							$range = array($this->min['saved'],$this->max['saved']);
							sort($range);
						}
						if (!$range) return money($this->min['saved']+($this->min['saved']*$taxrate)); // No price range
						else return money($range[0]+($range[0]*$taxrate))." &mdash; ".money($range[1]+($range[1]*$taxrate));
					} else return money($this->max['saved']+($this->max['saved']*$taxrate));
				}
				break;
			case "freeshipping":
				if (empty($this->prices)) $this->load_data(array('prices'));
				return $this->freeshipping;
			case "hasimages":
			case "has-images":
				if (empty($this->images)) $this->load_data(array('images'));
				return (!empty($this->images));
				break;
			case "images":
				if (!$this->images) return false;
				if (!isset($this->_images_loop)) {
					reset($this->images);
					$this->_images_loop = true;
				} else next($this->images);

				if (current($this->images) !== false) return true;
				else {
					unset($this->_images_loop);
					return false;
				}
				break;
			case "coverimage":
				// Force select the first loaded image
				unset($options['id']);
				$options['index'] = 0;
			case "thumbnail": // deprecated
			case "image":
				if (empty($this->images)) $this->load_data(array('images'));
				if (!(count($this->images) > 0)) return "";

				// Compatibility defaults
				$_size = 96;
				$_width = $Ecart->Settings->get('gallery_thumbnail_width');
				$_height = $Ecart->Settings->get('gallery_thumbnail_height');
				if (!$_width) $_width = $_size;
				if (!$_height) $_height = $_size;

				$defaults = array(
					'img' => false,
					'id' => false,
					'index' => false,
					'class' => '',
					'width' => false,
					'height' => false,
					'size' => false,
					'fit' => false,
					'sharpen' => false,
					'quality' => false,
					'bg' => false,
					'alt' => '',
					'title' => '',
					'zoom' => '',
					'zoomfx' => 'ecart-zoom',
					'property' => false
				);
				$options = array_merge($defaults,$options);
				extract($options);

				// Select image by database id
				if ($id !== false) {
					for ($i = 0; $i < count($this->images); $i++) {
						if ($img->id == $id) {
							$img = $this->images[$i]; break;
						}
					}
					if (!$img) return "";
				}

				// Select image by index position in the list
				if ($index !== false && isset($this->images[$index]))
					$img = $this->images[$index];

				// Use the current image pointer by default
				if (!$img) $img = current($this->images);

				if ($size !== false) $width = $height = $size;
				if (!$width) $width = $_width;
				if (!$height) $height = $_height;

				$scale = $fit?array_search($fit,$img->_scaling):false;
				$sharpen = $sharpen?min($sharpen,$img->_sharpen):false;
				$quality = $quality?min($quality,$img->_quality):false;
				$fill = $bg?hexdec(ltrim($bg,'#')):false;

				list($width_a,$height_a) = array_values($img->scaled($width,$height,$scale));
				if ($size == "original") {
					$width_a = $img->width;
					$height_a = $img->height;
				}
				if ($width_a === false) $width_a = $width;
				if ($height_a === false) $height_a = $height;

				$alt = esc_attr(empty($alt)?(empty($img->alt)?$img->name:$img->alt):$alt);
				$title = empty($title)?$img->title:$title;
				$titleattr = empty($title)?'':' title="'.esc_attr($title).'"';
				$classes = empty($class)?'':' class="'.esc_attr($class).'"';

				$src = ecarturl($img->id,'images');
				if (ECART_PERMALINKS) $src = trailingslashit($src).$img->filename;

				if ($size != "original")
					$src = add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),$src);

				switch (strtolower($property)) {
					case "id": return $img->id; break;
					case "url":
					case "src": return $src; break;
					case "title": return $title; break;
					case "alt": return $alt; break;
					case "width": return $width_a; break;
					case "height": return $height_a; break;
					case "class": return $class; break;
				}

				$imgtag = '<img src="'.$src.'"'.$titleattr.' alt="'.$alt.'" width="'.$width_a.'" height="'.$height_a.'" '.$classes.' />';

				if (value_is_true($zoom))
					return '<a href="'.ecarturl($img->id,'images').'/'.$img->filename.'" class="'.$zoomfx.'" rel="product-'.$this->id.'">'.$imgtag.'</a>';

				return $imgtag;
				break;
			case "gallery":
				if (empty($this->images)) $this->load_data(array('images'));
				if (empty($this->images)) return false;
				$styles = '';
				$_size = 240;
				$_width = $Ecart->Settings->get('gallery_small_width');
				$_height = $Ecart->Settings->get('gallery_small_height');

				if (!$_width) $_width = $_size;
				if (!$_height) $_height = $_size;

				$defaults = array(

					// Layout settings
					'margins' => 20,
					'rowthumbs' => false,
					// 'thumbpos' => 'after',

					// Preview image settings
					'p.size' => false,
					'p.width' => false,
					'p.height' => false,
					'p.fit' => false,
					'p.sharpen' => false,
					'p.quality' => false,
					'p.bg' => false,
					'p.link' => true,
					'rel' => '',

					// Thumbnail image settings
					'thumbsize' => false,
					'thumbwidth' => false,
					'thumbheight' => false,
					'thumbfit' => false,
					'thumbsharpen' => false,
					'thumbquality' => false,
					'thumbbg' => false,

					// Effects settings
					'zoomfx' => 'ecart-zoom',
					'preview' => 'click',
					'colorbox' => '{}'


				);
				$optionset = array_merge($defaults,$options);

				// Translate dot names
				$options = array();
				$keys = array_keys($optionset);
				foreach ($keys as $key)
					$options[str_replace('.','_',$key)] = $optionset[$key];
				extract($options);

				if ($p_size > 0)
					$_width = $_height = $p_size;

				$width = $p_width > 0?$p_width:$_width;
				$height = $p_height > 0?$p_height:$_height;

				$preview_width = $width;

				$previews = '<ul class="previews">';
				$firstPreview = true;

				// Find the max dimensions to use for the preview spacing image
				$maxwidth = $maxheight = 0;
				foreach ($this->images as $img) {
					$scale = $p_fit?false:array_search($p_fit,$img->_scaling);
					$scaled = $img->scaled($width,$height,$scale);
					$maxwidth = max($maxwidth,$scaled['width']);
					$maxheight = max($maxheight,$scaled['height']);
				}

				if ($maxwidth == 0) $maxwidth = $width;
				if ($maxheight == 0) $maxheight = $height;

				$p_link = value_is_true($p_link);

				foreach ($this->images as $img) {

					$scale = $p_fit?array_search($p_fit,$img->_scaling):false;
					$sharpen = $p_sharpen?min($p_sharpen,$img->_sharpen):false;
					$quality = $p_quality?min($p_quality,$img->_quality):false;
					$fill = $p_bg?hexdec(ltrim($p_bg,'#')):false;
					$scaled = $img->scaled($width,$height,$scale);

					if ($firstPreview) { // Adds "filler" image to reserve the dimensions in the DOM
						$href = ecarturl(ECART_PERMALINKS?trailingslashit('000'):'000','images');
						$previews .= '<li id="preview-fill"'.(($firstPreview)?' class="fill"':'').'>';
						$previews .= '<img src="'.add_query_string("$maxwidth,$maxheight",$href).'" alt=" " width="'.$maxwidth.'" height="'.$maxheight.'" />';
						$previews .= '</li>';
					}
					$title = !empty($img->title)?' title="'.esc_attr($img->title).'"':'';
					$alt = esc_attr(!empty($img->alt)?$img->alt:$img->filename);

					$previews .= '<li id="preview-'.$img->id.'"'.(($firstPreview)?' class="active"':'').'>';

					$href = ecarturl(ECART_PERMALINKS?trailingslashit($img->id).$img->filename:$img->id,'images');
					if ($p_link) $previews .= '<a href="'.$href.'" class="gallery product_'.$this->id.' '.$options['zoomfx'].'"'.(!empty($rel)?' rel="'.$rel.'"':'').'>';
					// else $previews .= '<a name="preview-'.$img->id.'">'; // If links are turned off, leave the <a> so we don't break layout
					$previews .= '<img src="'.add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),ecarturl($img->id,'images')).'"'.$title.' alt="'.$alt.'" width="'.$scaled['width'].'" height="'.$scaled['height'].'" />';
					if ($p_link) $previews .= '</a>';
					$previews .= '</li>';
					$firstPreview = false;
				}
				$previews .= '</ul>';

				$thumbs = "";
				$twidth = $preview_width+$margins;

				if (count($this->images) > 1) {
					$default_size = 64;
					$_thumbwidth = $Ecart->Settings->get('gallery_thumbnail_width');
					$_thumbheight = $Ecart->Settings->get('gallery_thumbnail_height');
					if (!$_thumbwidth) $_thumbwidth = $default_size;
					if (!$_thumbheight) $_thumbheight = $default_size;

					if ($thumbsize > 0) $thumbwidth = $thumbheight = $thumbsize;

					$width = $thumbwidth > 0?$thumbwidth:$_thumbwidth;
					$height = $thumbheight > 0?$thumbheight:$_thumbheight;

					$firstThumb = true;
					$thumbs = '<ul class="thumbnails">';
					foreach ($this->images as $img) {
						$scale = $thumbfit?array_search($thumbfit,$img->_scaling):false;
						$sharpen = $thumbsharpen?min($thumbsharpen,$img->_sharpen):false;
						$quality = $thumbquality?min($thumbquality,$img->_quality):false;
						$fill = $thumbbg?hexdec(ltrim($thumbbg,'#')):false;
						$scaled = $img->scaled($width,$height,$scale);

						$title = !empty($img->title)?' title="'.esc_attr($img->title).'"':'';
						$alt = esc_attr(!empty($img->alt)?$img->alt:$img->name);

						$thumbs .= '<li id="thumbnail-'.$img->id.'" class="preview-'.$img->id.(($firstThumb)?' first':'').'">';
						$thumbs .= '<img src="'.add_query_string($img->resizing($width,$height,$scale,$sharpen,$quality,$fill),ecarturl($img->id,'images')).'"'.$title.' alt="'.$alt.'" width="'.$scaled['width'].'" height="'.$scaled['height'].'" />';
						$thumbs .= '</li>'."\n";
						$firstThumb = false;
					}
					$thumbs .= '</ul>';

				}
				if ($rowthumbs > 0) $twidth = ($width+$margins+2)*(int)$rowthumbs;

				$result = '<div id="gallery-'.$this->id.'" class="gallery">'.$previews.$thumbs.'</div>';
				$script = "\t".'EcartGallery("#gallery-'.$this->id.'","'.$preview.'"'.($twidth?",$twidth":"").');';
				add_storefrontjs($script);

				return $result;

				break;
			case "has-categories":
				if (empty($this->categories)) $this->load_data(array('categories'));
				if (count($this->categories) > 0) return true; else return false; break;
			case "categories":
				if (!isset($this->_categories_loop)) {
					reset($this->categories);
					$this->_categories_loop = true;
				} else next($this->categories);

				if (current($this->categories) !== false) return true;
				else {
					unset($this->_categories_loop);
					return false;
				}
				break;
			case "in-category":
				if (empty($this->categories)) $this->load_data(array('categories'));
				if (isset($options['id'])) $field = "id";
				if (isset($options['name'])) $field = "name";
				if (isset($options['slug'])) $field = "slug";
				foreach ($this->categories as $category)
					if ($category->{$field} == $options[$field]) return true;
				return false;
			case "category":
				$category = current($this->categories);
				if (isset($options['show'])) {
					if ($options['show'] == "id") return $category->id;
					if ($options['show'] == "slug") return $category->slug;
				}
				return $category->name;
				break;
			case "hastags":
			case "has-tags":
				if (empty($this->tags)) $this->load_data(array('tags'));
				if (count($this->tags) > 0) return true; else return false; break;
			case "tags":
				if (!isset($this->_tags_loop)) {
					reset($this->tags);
					$this->_tags_loop = true;
				} else next($this->tags);

				if (current($this->tags) !== false) return true;
				else {
					unset($this->_tags_loop);
					return false;
				}
				break;
			case "tagged":
				if (empty($this->tags)) $this->load_data(array('tags'));
				if (isset($options['id'])) $field = "id";
				if (isset($options['name'])) $field = "name";
				foreach ($this->tags as $tag)
					if ($tag->{$field} == $options[$field]) return true;
				return false;
			case "tag":
				$tag = current($this->tags);
				if (isset($options['show'])) {
					if ($options['show'] == "id") return $tag->id;
				}
				return $tag->name;
				break;
			case "hasspecs":
			case "has-specs":
				if (empty($this->specs)) $this->load_data(array('specs'));
				if (count($this->specs) > 0) {
					$this->merge_specs();
					return true;
				} else return false; break;
			case "specs":
				if (!isset($this->_specs_loop)) {
					reset($this->specs);
					$this->_specs_loop = true;
				} else next($this->specs);

				if (current($this->specs) !== false) return true;
				else {
					unset($this->_specs_loop);
					return false;
				}
				break;
			case "spec":
				$string = "";
				$separator = ": ";
				$delimiter = ", ";
				if (isset($options['separator'])) $separator = $options['separator'];
				if (isset($options['delimiter'])) $separator = $options['delimiter'];

				$spec = current($this->specs);
				if (is_array($spec->value)) $spec->value = join($delimiter,$spec->value);

				if (isset($options['name'])
					&& !empty($options['name'])
					&& isset($this->specskey[$options['name']])) {
						$spec = $this->specskey[$options['name']];
						if (is_array($spec)) {
							if (isset($options['index'])) {
								foreach ($spec as $index => $entry)
									if ($index+1 == $options['index'])
										$content = $entry->value;
							} else {
								foreach ($spec as $entry) $contents[] = $entry->value;
								$content = join($delimiter,$contents);
							}
						} else $content = $spec->value;
					$string = apply_filters('ecart_product_spec',$content);
					return $string;
				}

				if (isset($options['name']) && isset($options['content']))
					$string = "{$spec->name}{$separator}".apply_filters('ecart_product_spec',$spec->value);
				elseif (isset($options['name'])) $string = $spec->name;
				elseif (isset($options['content'])) $string = apply_filters('ecart_product_spec',$spec->value);
				else $string = "{$spec->name}{$separator}".apply_filters('ecart_product_spec',$spec->value);
				return $string;
				break;
			case "has-variations":
				return ($this->variations == "on" && (!empty($this->options['v']) || !empty($this->options))); break;
			case "variations":

				$string = "";

				if (!isset($options['mode'])) {
					if (!isset($this->_prices_loop)) {
						reset($this->prices);
						$this->_prices_loop = true;
					} else next($this->prices);
					$price = current($this->prices);

					if ($price && ($price->type == 'N/A' || $price->context != 'variation'))
						next($this->prices);

					if (current($this->prices) !== false) return true;
					else {
						unset($this->_prices_loop);
						return false;
					}
					return true;
				}

				if ($this->outofstock) return false; // Completely out of stock, hide menus
				if (!isset($options['taxes'])) $options['taxes'] = null;

				$defaults = array(
					'defaults' => '',
					'disabled' => 'show',
					'pricetags' => 'show',
					'before_menu' => '',
					'after_menu' => '',
					'label' => 'on',
					'required' => __('You must select the options for this item before you can add it to your shopping cart.','Ecart')
					);
				$options = array_merge($defaults,$options);

				if ($options['mode'] == "single") {
					if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n";
					if (value_is_true($options['label'])) $string .= '<label for="product-options'.$this->id.'">'. __('Options').': </label> '."\n";

					$string .= '<select name="products['.$this->id.'][price]" id="product-options'.$this->id.'">';
					if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n";

					foreach ($this->prices as $pricetag) {
						if ($pricetag->context != "variation") continue;

						if (!isset($options['taxes']))
							$taxrate = ecart_taxrate(null,$pricetag->tax);
						else $taxrate = ecart_taxrate(value_is_true($options['taxes']),$pricetag->tax);
						$currently = ($pricetag->sale == "on")?$pricetag->promoprice:$pricetag->price;
						$disabled = ($pricetag->inventory == "on" && $pricetag->stock == 0)?' disabled="disabled"':'';

						$price = '  ('.money($currently).')';
						if ($pricetag->type != "N/A")
							$string .= '<option value="'.$pricetag->id.'"'.$disabled.'>'.$pricetag->label.$price.'</option>'."\n";
					}
					$string .= '</select>';
					if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n";

				} else {
					if (!isset($this->options)) return;

					$menuoptions = $this->options;
					if (!empty($this->options['v'])) $menuoptions = $this->options['v'];

					$baseop = $Ecart->Settings->get('base_operations');
					$precision = $baseop['currency']['format']['precision'];

					if (!isset($options['taxes']))
						$taxrate = ecart_taxrate(null,true,$this);
					else $taxrate = ecart_taxrate(value_is_true($options['taxes']),true,$this);

					$pricekeys = array();
					foreach ($this->pricekey as $key => $pricing) {
						$filter = array('');
						$_ = new StdClass();
						if ($pricing->type != "Donation")
							$_->p = ((isset($pricing->onsale)
										&& $pricing->onsale == "on")?
											(float)$pricing->promoprice:
											(float)$pricing->price);
						$_->i = ($pricing->inventory == "on");
						$_->s = ($pricing->inventory == "on")?$pricing->stock:false;
						$_->tax = ($pricing->tax == "on");
						$_->t = $pricing->type;
						$pricekeys[$key] = $_;
					}

					ob_start();
?><?php if (!empty($options['defaults'])): ?>
	sjss.opdef = true;
<?php endif; ?>
<?php if (!empty($options['required'])): ?>
	sjss.opreq = "<?php echo $options['required']; ?>";
<?php endif; ?>
	pricetags[<?php echo $this->id; ?>] = <?php echo json_encode($pricekeys); ?>;
	new ProductOptionsMenus('select<?php if (!empty($Ecart->Category->slug)) echo ".category-".$Ecart->Category->slug; ?>.product<?php echo $this->id; ?>.options',{<?php if ($options['disabled'] == "hide") echo "disabled:false,"; ?><?php if ($options['pricetags'] == "hide") echo "pricetags:false,"; ?><?php if (!empty($taxrate)) echo "taxrate:$taxrate,"?>prices:pricetags[<?php echo $this->id; ?>]});
<?php
					$script = ob_get_contents();
					ob_end_clean();

					add_storefrontjs($script);

					foreach ($menuoptions as $id => $menu) {
						if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n";
						if (value_is_true($options['label'])) $string .= '<label for="options-'.$menu['id'].'">'.$menu['name'].'</label> '."\n";
						$category_class = isset($Ecart->Category->slug)?'category-'.$Ecart->Category->slug:'';
						$string .= '<select name="products['.$this->id.'][options][]" class="'.$category_class.' product'.$this->id.' options" id="options-'.$menu['id'].'">';
						if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n";
						foreach ($menu['options'] as $key => $option)
							$string .= '<option value="'.$option['id'].'">'.$option['name'].'</option>'."\n";

						$string .= '</select>';
					}
					if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n";
				}

				return $string;
				break;
			case "variation":
				$variation = current($this->prices);

				if (!isset($options['taxes'])) $options['taxes'] = null;
				else $options['taxes'] = value_is_true($options['taxes']);
				$taxrate = ecart_taxrate($options['taxes'],$variation->tax,$this);

				$weightunit = (isset($options['units']) && !value_is_true($options['units']) ) ? false : $Ecart->Settings->get('weight_unit');

				$string = '';
				if (array_key_exists('id',$options)) $string .= $variation->id;
				if (array_key_exists('label',$options)) $string .= $variation->label;
				if (array_key_exists('type',$options)) $string .= $variation->type;
				if (array_key_exists('sku',$options)) $string .= $variation->sku;
				if (array_key_exists('price',$options)) $string .= money($variation->price+($variation->price*$taxrate));
				if (array_key_exists('saleprice',$options)) {
					if (isset($options['promos']) && !value_is_true($options['promos'])) {
						$string .= money($variation->saleprice+($variation->saleprice*$taxrate));
					} else $string .= money($variation->promoprice+($variation->promoprice*$taxrate));
				}
				if (array_key_exists('stock',$options)) $string .= $variation->stock;
				if (array_key_exists('weight',$options)) $string .= round($variation->weight, 3) . ($weightunit ? " $weightunit" : false);
				if (array_key_exists('shipfee',$options)) $string .= money(floatvalue($variation->shipfee));
				if (array_key_exists('sale',$options)) return ($variation->sale == "on");
				if (array_key_exists('shipping',$options)) return ($variation->shipping == "on");
				if (array_key_exists('tax',$options)) return ($variation->tax == "on");
				if (array_key_exists('inventory',$options)) return ($variation->inventory == "on");
				return $string;
				break;
			case "has-addons":
				return ($this->addons == "on" && !empty($this->options['a'])); break;
				break;
			case "addons":

				$string = "";

				if (!isset($options['mode'])) {
					if (!$this->priceloop) {
						reset($this->prices);
						$this->priceloop = true;
					} else next($this->prices);
					$thisprice = current($this->prices);

					if ($thisprice && $thisprice->type == "N/A")
						next($this->prices);

					if ($thisprice && $thisprice->context != "addon")
						next($this->prices);

					if (current($this->prices) !== false) return true;
					else {
						$this->priceloop = false;
						return false;
					}
					return true;
				}

				if ($this->outofstock) return false; // Completely out of stock, hide menus
				if (!isset($options['taxes'])) $options['taxes'] = null;

				$defaults = array(
					'defaults' => '',
					'disabled' => 'show',
					'before_menu' => '',
					'after_menu' => ''
					);

				$options = array_merge($defaults,$options);

				if (!isset($options['label'])) $options['label'] = "on";
				if (!isset($options['required'])) $options['required'] = __('You must select the options for this item before you can add it to your shopping cart.','Ecart');
				if ($options['mode'] == "single") {
					if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n";
					if (value_is_true($options['label'])) $string .= '<label for="product-options'.$this->id.'">'. __('Options').': </label> '."\n";

					$string .= '<select name="products['.$this->id.'][price]" id="product-options'.$this->id.'">';
					if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n";

					foreach ($this->prices as $pricetag) {
						if ($pricetag->context != "addon") continue;

						if (isset($options['taxes']))
							$taxrate = ecart_taxrate(value_is_true($options['taxes']),$pricetag->tax,$this);
						else $taxrate = ecart_taxrate(null,$pricetag->tax,$this);
						$currently = ($pricetag->sale == "on")?$pricetag->promoprice:$pricetag->price;
						$disabled = ($pricetag->inventory == "on" && $pricetag->stock == 0)?' disabled="disabled"':'';

						$price = '  ('.money($currently).')';
						if ($pricetag->type != "N/A")
							$string .= '<option value="'.$pricetag->id.'"'.$disabled.'>'.$pricetag->label.$price.'</option>'."\n";
					}

					$string .= '</select>';
					if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n";

				} else {
					if (!isset($this->options['a'])) return;

					$taxrate = ecart_taxrate($options['taxes'],true,$this);

					// Index addon prices by option
					$pricing = array();
					foreach ($this->prices as $pricetag) {
						if ($pricetag->context != "addon") continue;
						$pricing[$pricetag->options] = $pricetag;
					}

					foreach ($this->options['a'] as $id => $menu) {
						if (!empty($options['before_menu'])) $string .= $options['before_menu']."\n";
						if (value_is_true($options['label'])) $string .= '<label for="options-'.$menu['id'].'">'.$menu['name'].'</label> '."\n";
						$category_class = isset($Ecart->Category->slug)?'category-'.$Ecart->Category->slug:'';
						$string .= '<select name="products['.$this->id.'][addons][]" class="'.$category_class.' product'.$this->id.' addons" id="addons-'.$menu['id'].'">';
						if (!empty($options['defaults'])) $string .= '<option value="">'.$options['defaults'].'</option>'."\n";
						foreach ($menu['options'] as $key => $option) {

							$pricetag = $pricing[$option['id']];

							if (isset($options['taxes']))
								$taxrate = ecart_taxrate(value_is_true($options['taxes']),$pricetag->tax,$this);
							else $taxrate = ecart_taxrate(null,$pricetag->tax,$this);

							$currently = ($pricetag->sale == "on")?$pricetag->promoprice:$pricetag->price;
							if ($taxrate > 0) $currently = $currently+($currently*$taxrate);
							$string .= '<option value="'.$option['id'].'">'.$option['name'].' (+'.money($currently).')</option>'."\n";
						}

						$string .= '</select>';
					}
					if (!empty($options['after_menu'])) $string .= $options['after_menu']."\n";

				}

				return $string;
				break;

			case "donation":
			case "amount":
			case "quantity":
				if ($this->outofstock) return false;

				$inputs = array('text','menu');
				$defaults = array(
					'value' => 1,
					'input' => 'text', // accepts text,menu
					'labelpos' => 'before',
					'label' => '',
					'options' => '1-15,20,25,30,40,50,75,100',
					'size' => 3
				);
				$options = array_merge($defaults,$options);
				$_options = $options;
				extract($options);

				unset($_options['label']); // Interferes with the text input value when passed to inputattrs()
				$labeling = '<label for="quantity-'.$this->id.'">'.$label.'</label>';

				if (!isset($this->_prices_loop)) reset($this->prices);
				$variation = current($this->prices);
				$_ = array();

				if ("before" == $labelpos) $_[] = $labeling;
				if ("menu" == $input) {
					if ($this->inventory && $this->max['stock'] == 0) return "";

					if (strpos($options,",") !== false) $options = explode(",",$options);
					else $options = array($options);

					$qtys = array();
					foreach ((array)$options as $v) {
						if (strpos($v,"-") !== false) {
							$v = explode("-",$v);
							if ($v[0] >= $v[1]) $qtys[] = $v[0];
							else for ($i = $v[0]; $i < $v[1]+1; $i++) $qtys[] = $i;
						} else $qtys[] = $v;
					}
					$_[] = '<select name="products['.$this->id.'][quantity]" id="quantity-'.$this->id.'">';
					foreach ($qtys as $qty) {
						$amount = $qty;
						$selection = (isset($this->quantity))?$this->quantity:1;
						if ($variation->type == "Donation" && $variation->donation['var'] == "on") {
							if ($variation->donation['min'] == "on" && $amount < $variation->price) continue;
							$amount = money($amount);
							$selection = $variation->price;
						} else {
							if ($this->inventory && $amount > $this->max['stock']) continue;
						}
						$selected = ($qty==$selection)?' selected="selected"':'';
						$_[] = '<option'.$selected.' value="'.$qty.'">'.$amount.'</option>';
					}
					$_[] = '</select>';
				} elseif (valid_input($input)) {
					if ($variation->type == "Donation" && $variation->donation['var'] == "on") {
						if ($variation->donation['min']) $_options['value'] = $variation->price;
						$_options['class'] .= " currency";
					}
					$_[] = '<input type="'.$input.'" name="products['.$this->id.'][quantity]" id="quantity-'.$this->id.'"'.inputattrs($_options).' />';
				}

				if ("after" == $labelpos) $_[] = $labeling;
				return join("\n",$_);
				break;
			case "input":
				if (!isset($options['type']) ||
					($options['type'] != "menu" && $options['type'] != "textarea" && !valid_input($options['type']))) $options['type'] = "text";
				if (!isset($options['name'])) return "";
				if ($options['type'] == "menu") {
					$result = '<select name="products['.$this->id.'][data]['.$options['name'].']" id="data-'.$options['name'].'-'.$this->id.'"'.inputattrs($options,$select_attrs).'>';
					if (isset($options['options']))
						$menuoptions = preg_split('/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/',$options['options']);
					if (is_array($menuoptions)) {
						foreach($menuoptions as $option) {
							$selected = "";
							$option = trim($option,'"');
							if (isset($options['default']) && $options['default'] == $option)
								$selected = ' selected="selected"';
							$result .= '<option value="'.$option.'"'.$selected.'>'.$option.'</option>';
						}
					}
					$result .= '</select>';
				} elseif ($options['type'] == "textarea") {
					if (isset($options['cols'])) $cols = ' cols="'.$options['cols'].'"';
					if (isset($options['rows'])) $rows = ' rows="'.$options['rows'].'"';
					$result .= '<textarea name="products['.$this->id.'][data]['.$options['name'].']" id="data-'.$options['name'].'-'.$this->id.'"'.$cols.$rows.inputattrs($options).'>'.$options['value'].'</textarea>';
				} else {
					$result = '<input type="'.$options['type'].'" name="products['.$this->id.'][data]['.$options['name'].']" id="data-'.$options['name'].'-'.$this->id.'"'.inputattrs($options).' />';
				}

				return $result;
				break;
			case "outofstock":
				if ($this->outofstock) {
					$label = isset($options['label'])?$options['label']:$Ecart->Settings->get('outofstock_text');
					$string = '<span class="outofstock">'.$label.'</span>';
					return $string;
				} else return false;
				break;
			case "buynow":
				if (!isset($options['value'])) $options['value'] = __("Buy Now","Ecart");
			case "addtocart":

				if (!isset($options['class'])) $options['class'] = "addtocart";
				else $options['class'] .= " addtocart";
				if (!isset($options['value'])) $options['value'] = __("Add to Cart","Ecart");
				$string = "";

				if ($this->outofstock) {
					$string .= '<span class="outofstock">'.$Ecart->Settings->get('outofstock_text').'</span>';
					return $string;
				}
				if (isset($options['redirect']) && !isset($options['ajax']))
					$string .= '<input type="hidden" name="redirect" value="'.$options['redirect'].'" />';

				$string .= '<input type="hidden" name="products['.$this->id.'][product]" value="'.$this->id.'" />';

				if (!empty($this->prices[0]) && $this->prices[0]->type != "N/A")
					$string .= '<input type="hidden" name="products['.$this->id.'][price]" value="'.$this->prices[0]->id.'" />';

				if (!empty($Ecart->Category)) {
					if (ECART_PRETTYURLS)
						$string .= '<input type="hidden" name="products['.$this->id.'][category]" value="'.$Ecart->Category->uri.'" />';
					else
						$string .= '<input type="hidden" name="products['.$this->id.'][category]" value="'.((!empty($Ecart->Category->id))?$Ecart->Category->id:$Ecart->Category->slug).'" />';
				}

				$string .= '<input type="hidden" name="cart" value="add" />';
				if (isset($options['ajax'])) {
					if ($options['ajax'] == "html") $options['class'] .= ' ajax-html';
					else $options['class'] .= " ajax";
					$string .= '<input type="hidden" name="ajax" value="true" />';
					$string .= '<input type="button" name="addtocart" '.inputattrs($options).' />';
				} else {
					$string .= '<input type="submit" name="addtocart" '.inputattrs($options).' />';
				}

				return $string;
		}


	}
Example #13
0
 function getCashToPay()
 {
     $tariffPrice = $this->calculateTariffPrice();
     $cash = money($this->data['cash']);
     $cashToPay = $tariffPrice - $cash;
     return smoneyf($cashToPay);
 }
Example #14
0
 public function download_xls()
 {
     $report_type = $this->input->post('report_type');
     $date_from = $this->input->post('date_from');
     $date_to = $this->input->post('date_to');
     if ($report_type != '' && $date_from != '' && $date_to != '') {
         $this->load->library('PHPExcel');
         $objPHPExcel = new PHPExcel();
         $title = "untitled";
         switch ($report_type) {
             case 'day':
                 $title = "ERP 日报表 {$date_from} - {$date_to}";
                 $bills = $this->Mbill->objGetZentsBillsOfDay($date_from, $date_to);
                 break;
             case 'month':
                 $bills = $this->Mbill->objGetZentsBillsOfMonth($date_from, $date_to);
                 $date_from = date('Y-m', strtotime($date_from));
                 $date_to = date('Y-m', strtotime($date_to));
                 $title = "ERP 月报表 {$date_from} - {$date_to}";
                 break;
             case 'year':
                 $bills = $this->Mbill->objGetZentsBillsOfYear($date_from, $date_to);
                 $date_from = date('Y', strtotime($date_from));
                 $date_to = date('Y', strtotime($date_to));
                 $title = "ERP 年报表 {$date_from} - {$date_to}";
                 break;
             case 'products':
                 $bills = $this->Mbill->objGetProductBills($date_from, $date_to);
                 $title = "ERP 产品报表 {$date_from} - {$date_to}";
                 break;
             case 'users':
                 $bills = $this->Mbill->objGetUserBills($date_from, $date_to);
                 $title = "ERP 代理交易统计报表 {$date_from} - {$date_to}";
                 break;
             default:
                 break;
         }
         // Set document properties
         $objPHPExcel->getProperties()->setCreator("Princelo Lamkimcheung@gmail.com")->setLastModifiedBy("Princelo Lamkimcheung@gmail.com")->setTitle($title)->setSubject($title)->setDescription($title)->setKeywords("Princelo lamkimcheung@gmail.com")->setCategory($report_type);
         if ($report_type == 'products') {
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $title)->setCellValue('A2', '产品ID')->setCellValue('B2', '产品名称')->setCellValue('C2', '出货量')->setCellValue('D2', '总金额');
             foreach ($bills as $k => $v) {
                 $i = $k + 3;
                 $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", $v->product_id)->setCellValue("B{$i}", $v->title)->setCellValue("C{$i}", $v->total_quantity)->setCellValue("D{$i}", $v->amount);
             }
         } elseif ($report_type == 'users') {
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $title)->setCellValue('A2', '代理')->setCellValue('B2', '业绩增量')->setCellValue('C2', '自下级(下下级)收益增量(不含推荐)')->setCellValue('D2', '自下级推荐收益增量')->setCellValue('E2', '总收益增量')->setCellValue('F2', '至推荐人收益')->setCellValue('G2', '至推荐人推荐收益')->setCellValue('H2', '至推荐人总收益')->setCellValue('I2', '至跨界推荐人收益')->setCellValue('J2', '推荐人代理')->setCellValue('K2', '跨界推荐人代理');
             foreach ($bills as $k => $v) {
                 $i = $k + 3;
                 $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", $v->name . "(" . $v->username . "/" . $v->id . ")")->setCellValue("B{$i}", cny($v->turnover))->setCellValue("C{$i}", cny($v->normal_return_profit_sub2self))->setCellValue("D{$i}", cny($v->extra_return_profit_sub2self))->setCellValue("E{$i}", '¥' . bcadd(bcadd(money($v->normal_return_profit_sub2self), money($v->extra_return_profit_sub2self), 2), 0, 2))->setCellValue("F{$i}", cny($v->normal_return_profit_self2parent))->setCellValue("G{$i}", cny($v->extra_return_profit_self2parent))->setCellValue("H{$i}", "¥" . bcadd(money($v->normal_return_profit_self2parent), money($v->extra_return_profit_self2parent), 2))->setCellValue("I{$i}", cny($v->normal_return_profit_self2gparent));
                 if (intval($v->pid) > 0) {
                     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("J{$i}", $v->pname . "(" . $v->pusername . "/" . $v->pid . ")");
                 } else {
                     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("J{$i}", "无推荐人");
                 }
                 if (intval($v->gpid) > 0) {
                     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("K{$i}", $v->gpname . "(" . $v->gpusername . "/" . $v->gpid . ")");
                 } else {
                     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("K{$i}", "无跨界推荐人");
                 }
             }
         } else {
             // Add some data
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $title)->setCellValue('A2', '日期')->setCellValue('B2', '总金额(含运费)')->setCellValue('C2', '产品总金额')->setCellValue('D2', '运费总金额')->setCellValue('E2', '即时收益总量')->setCellValue('F2', '收益总量')->setCellValue('G2', '订单数');
             // Miscellaneous glyphs, UTF-8
             foreach ($bills as $k => $v) {
                 $i = $k + 3;
                 $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$i}", $v->date)->setCellValue("B{$i}", $v->total_volume)->setCellValue("C{$i}", $v->products_volume)->setCellValue("D{$i}", $v->post_fee)->setCellValue("E{$i}", $v->normal_return_profit_volume)->setCellValue("F{$i}", "¥" . bcadd(money($v->normal_return_profit_volume), 0, 2))->setCellValue("G{$i}", $v->order_quantity);
             }
         }
         // Rename worksheet
         $objPHPExcel->getActiveSheet()->setTitle('REPORT');
         // Set active sheet index to the first sheet, so Excel opens this as the first sheet
         $objPHPExcel->setActiveSheetIndex(0);
         // Redirect output to a client’s web browser (Excel5)
         header('Content-Type: application/vnd.ms-excel');
         header('Content-Disposition: attachment;filename="' . $title . '.xls"');
         header('Cache-Control: max-age=0');
         // If you're serving to IE 9, then the following may be needed
         header('Cache-Control: max-age=1');
         // If you're serving to IE over SSL, then the following may be needed
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         // Date in the past
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
         // always modified
         header('Cache-Control: cache, must-revalidate');
         // HTTP/1.1
         header('Pragma: public');
         // HTTP/1.0
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
         $objWriter->save('php://output');
         exit;
     } else {
         exit('This page is expired !');
     }
 }
        if (!empty($location) && !empty($Order->shipstate)) {
            $location .= ', ';
        }
        $location .= $Order->shipstate;
        if (!empty($location) && !empty($Order->shipcountry)) {
            $location .= ' &mdash; ';
        }
        $location .= $Order->shipcountry;
        echo $location;
        ?>
</td>
			<td class="total column-total<?php 
        echo in_array('total', $hidden) ? ' hidden' : '';
        ?>
"><?php 
        echo money($Order->total);
        ?>
</td>
			<td class="txn column-txn<?php 
        echo in_array('txn', $hidden) ? ' hidden' : '';
        ?>
"><?php 
        echo $Order->transactionid;
        ?>
<br /><strong><?php 
        echo $Order->gateway;
        ?>
</strong> &mdash; <?php 
        echo $txnstatus;
        ?>
</td>
Example #16
0
 /**
  * Provides a labeled version of the current applied discount
  *
  * This is used within a discount loop.
  *
  * @see ShoppCartThemeAPI::discounts() Used within a shopp('cart.discounts') loop
  * @api `shopp('cart.discount-applied')`
  * @since 1.1
  *
  * @param string    $result  The output
  * @param array     $options The options
  * - **label**: `%s off` The label format where `%s` is a token replaced with the discount name
  * - **creditlabel**: `%s applied` The label for credits (not discounts) where `%s` is the credit name
  * - **before**: Markup to use before the entry
  * - **after**: Markup to use after the entry,
  * - **remove**: `on` (on, off) Include a remove link that unapplies the discount
  * @param ShoppCart $O       The working object
  * @return The discount label
  **/
 public static function discount_applied($result, $options, $O)
 {
     $Discount = ShoppOrder()->Discounts->current();
     if (!$Discount->applies()) {
         return false;
     }
     $defaults = array('label' => __('%s off', 'Shopp'), 'creditlabel' => __('%s applied', 'Shopp'), 'before' => '', 'after' => '', 'remove' => 'on');
     $options = array_merge($defaults, $options);
     extract($options, EXTR_SKIP);
     if (false === strpos($label, '%s')) {
         $label = "%s {$label}";
     }
     $string = $before;
     switch ($Discount->type()) {
         case ShoppOrderDiscount::SHIP_FREE:
             $string .= Shopp::esc_html__('Free Shipping!');
             break;
         case ShoppOrderDiscount::PERCENT_OFF:
             $string .= sprintf(esc_html($label), percentage((double) $Discount->discount(), array('precision' => 0)));
             break;
         case ShoppOrderDiscount::AMOUNT_OFF:
             $string .= sprintf(esc_html($label), money($Discount->discount()));
             break;
         case ShoppOrderDiscount::CREDIT:
             $string .= sprintf(esc_html($creditlabel), money($Discount->amount()));
             break;
         case ShoppOrderDiscount::BOGOF:
             list($buy, $get) = $Discount->discount();
             $string .= ucfirst(strtolower(Shopp::esc_html__('Buy %s Get %s Free', $buy, $get)));
             break;
     }
     $options['label'] = '';
     if (Shopp::str_true($remove)) {
         $string .= '&nbsp;' . self::discount_remove('', $options, $O);
     }
     $string .= $after;
     return $string;
 }
Example #17
0
	/**
	 * ecart('category','...') tags
	 * 
	 * @since 1.0
	 * @version 1.1
	 *
	 * @param string $property The property to handle
	 * @param array $options (optional) The tag options to process
	 * @return mixed
	 **/
	function tag ($property,$options=array()) {
		global $Ecart;
		$db = DB::get();

		switch ($property) {
			case "link":
			case "url":
				return ecarturl(ECART_PRETTYURLS?'category/'.$this->uri:array('ecart_category'=>$this->id));
				break;
			case "feed-url":
			case "feedurl":
				$uri = 'category/'.$this->uri;
				if ($this->slug == "tag") $uri = $this->slug.'/'.$this->tag;
				return ecarturl(ECART_PRETTYURLS?"$uri/feed":array('ecart_category'=>urldecode($this->uri),'src'=>'category_rss'));
			case "id": return $this->id; break;
			case "parent": return $this->parent; break;
			case "name": return $this->name; break;
			case "slug": return urldecode($this->slug); break;
			case "description": return wpautop($this->description); break;
			case "total": return $this->loaded?$this->total:false; break;
			case "has-products":
			case "loadproducts":
			case "load-products":
			case "hasproducts":
				if (empty($this->id) && empty($this->slug)) return false;
				if (isset($options['load'])) {
					$dataset = explode(",",$options['load']);
					$options['load'] = array();
					foreach ($dataset as $name) $options['load'][] = trim($name);
				 } else {
					$options['load'] = array('prices');
				}
				if (!$this->loaded) $this->load_products($options);
				if (count($this->products) > 0) return true; else return false; break;
			case "products":
				if (!isset($this->_product_loop)) {
					reset($this->products);
					$Ecart->Product = current($this->products);
					$this->_pindex = 0;
					$this->_rindex = false;
					$this->_product_loop = true;
				} else {
					$Ecart->Product = next($this->products);
					$this->_pindex++;
				}

				if (current($this->products) !== false) return true;
				else {
					unset($this->_product_loop);
					$this->_pindex = 0;
					return false;
				}
				break;
			case "row":
				if (!isset($this->_rindex) || $this->_rindex === false) $this->_rindex = 0;
				else $this->_rindex++;
				if (empty($options['products'])) $options['products'] = $Ecart->Settings->get('row_products');
				if (isset($this->_rindex) && $this->_rindex > 0 && $this->_rindex % $options['products'] == 0) return true;
				else return false;
				break;
			case "has-categories":
			case "hascategories":
				if (empty($this->children)) $this->load_children();
				return (!empty($this->children));
				break;
			case "is-subcategory":
			case "issubcategory":
				return ($this->parent != 0);
				break;
			case "subcategories":
				if (!isset($this->_children_loop)) {
					reset($this->children);
					$this->child = current($this->children);
					$this->_cindex = 0;
					$this->_children_loop = true;
				} else {
					$this->child = next($this->children);
					$this->_cindex++;
				}

				if ($this->child !== false) return true;
				else {
					unset($this->_children_loop);
					$this->_cindex = 0;
					$this->child = false;
					return false;
				}
				break;
			case "subcategory-list":
				if (isset($Ecart->Category->controls)) return false;

				$defaults = array(
					'title' => '',
					'before' => '',
					'after' => '',
					'class' => '',
					'exclude' => '',
					'orderby' => 'name',
					'order' => 'ASC',
					'depth' => 0,
					'childof' => 0,
					'parent' => false,
					'showall' => false,
					'linkall' => false,
					'linkcount' => false,
					'dropdown' => false,
					'hierarchy' => false,
					'products' => false,
					'wraplist' => true,
					'showsmart' => false
					);

				$options = array_merge($defaults,$options);
				extract($options, EXTR_SKIP);

				if (!$this->children) $this->load_children(array('orderby'=>$orderby,'order'=>$order));
				if (empty($this->children)) return false;

				$string = "";
				$depthlimit = $depth;
				$depth = 0;
				$exclude = explode(",",$exclude);
				$classes = ' class="ecart_categories'.(empty($class)?'':' '.$class).'"';
				$wraplist = value_is_true($wraplist);

				if (value_is_true($dropdown)) {
					$count = 0;
					$string .= $title;
					$string .= '<select name="ecart_cats" id="ecart-'.$this->slug.'-subcategories-menu" class="ecart-categories-menu">';
					$string .= '<option value="">'.__('Select a sub-category&hellip;','Ecart').'</option>';
					foreach ($this->children as &$category) {
						if (!empty($show) && $count+1 > $show) break;
						if (value_is_true($hierarchy) && $depthlimit && $category->depth >= $depthlimit) continue;
						if ($category->products == 0) continue; // Only show categories with products
						if (value_is_true($hierarchy) && $category->depth > $depth) {
							$parent = &$previous;
							if (!isset($parent->path)) $parent->path = '/'.$parent->slug;
						}
						$padding = str_repeat("&nbsp;",$category->depth*3);

						$category_uri = empty($category->id)?$category->uri:$category->id;
						$link = ECART_PRETTYURLS?ecarturl("category/$category->uri"):ecarturl(array('ecart_category'=>$category_uri));

						$total = '';
						if (value_is_true($products)) $total = '&nbsp;&nbsp;('.$category->products.')';

						$string .= '<option value="'.htmlentities($link).'">'.$padding.$category->name.$total.'</option>';
						$previous = &$category;
						$depth = $category->depth;
						$count++;
					}
					$string .= '</select>';
				} else {
					if (!empty($class)) $classes = ' class="'.$class.'"';
					$string .= $title.'<ul'.$classes.'>';
					$count = 0;
					foreach ($this->children as &$category) {
						if (!isset($category->total)) $category->total = 0;
						if (!isset($category->depth)) $category->depth = 0;
						if (!empty($category->id) && in_array($category->id,$exclude)) continue; // Skip excluded categories
						if ($depthlimit && $category->depth >= $depthlimit) continue;
						if (value_is_true($hierarchy) && $category->depth > $depth) {
							$parent = &$previous;
							if (!isset($parent->path)) $parent->path = $parent->slug;
							$string = substr($string,0,-5); // Remove the previous </li>
							$active = '';

							if (isset($Ecart->Category) && !empty($parent->slug)
									&& preg_match('/(^|\/)'.$parent->path.'(\/|$)/',$Ecart->Category->uri)) {
								$active = ' active';
							}

							$subcategories = '<ul class="children'.$active.'">';
							$string .= $subcategories;
						}

						if (value_is_true($hierarchy) && $category->depth < $depth) {
							for ($i = $depth; $i > $category->depth; $i--) {
								if (substr($string,strlen($subcategories)*-1) == $subcategories) {
									// If the child menu is empty, remove the <ul> to avoid breaking standards
									$string = substr($string,0,strlen($subcategories)*-1).'</li>';
								} else $string .= '</ul></li>';
							}
						}

						$category_uri = empty($category->id)?$category->uri:$category->id;
						$link = ECART_PRETTYURLS?
							ecarturl("category/$category->uri"):
							ecarturl(array('ecart_category'=>$category_uri));

						$total = '';
						if (value_is_true($products) && $category->total > 0) $total = ' <span>('.$category->total.')</span>';

						$current = '';
						if (isset($Ecart->Category) && $Ecart->Category->slug == $category->slug)
							$current = ' class="current"';

						$listing = '';
						if ($category->total > 0 || isset($category->smart) || $linkall)
							$listing = '<a href="'.$link.'"'.$current.'>'.$category->name.($linkcount?$total:'').'</a>'.(!$linkcount?$total:'');
						else $listing = $category->name;

						if (value_is_true($showall) ||
							$category->total > 0 ||
							isset($category->smart) ||
							$category->children)
							$string .= '<li'.$current.'>'.$listing.'</li>';

						$previous = &$category;
						$depth = $category->depth;
						$count++;
					}
					if (value_is_true($hierarchy) && $depth > 0)
						for ($i = $depth; $i > 0; $i--) {
							if (substr($string,strlen($subcategories)*-1) == $subcategories) {
								// If the child menu is empty, remove the <ul> to avoid breaking standards
								$string = substr($string,0,strlen($subcategories)*-1).'</li>';
							} else $string .= '</ul></li>';
						}
					if ($wraplist) $string .= '</ul>';
				}
				return $string;
				break;
			case "section-list":
				if (empty($this->id)) return false;
				if (isset($Ecart->Category->controls)) return false;
				if (empty($Ecart->Catalog->categories))
					$Ecart->Catalog->load_categories(array("where"=>"(pd.status='publish' OR pd.id IS NULL)"));
				if (empty($Ecart->Catalog->categories)) return false;
				if (!$this->children) $this->load_children();

				$defaults = array(
					'title' => '',
					'before' => '',
					'after' => '',
					'class' => '',
					'classes' => '',
					'exclude' => '',
					'total' => '',
					'current' => '',
					'listing' => '',
					'depth' => 0,
					'parent' => false,
					'showall' => false,
					'linkall' => false,
					'dropdown' => false,
					'hierarchy' => false,
					'products' => false,
					'wraplist' => true
					);

				$options = array_merge($defaults,$options);
				extract($options, EXTR_SKIP);

				$string = "";
				$depthlimit = $depth;
				$depth = 0;
				$wraplist = value_is_true($wraplist);
				$exclude = explode(",",$exclude);
				$section = array();

				// Identify root parent
				if (empty($this->id)) return false;
				$parent = '_'.$this->id;
				while($parent != 0) {
					if (!isset($Ecart->Catalog->categories[$parent])) break;
					if ($Ecart->Catalog->categories[$parent]->parent == 0
						|| $Ecart->Catalog->categories[$parent]->parent == $parent) break;
					$parent = '_'.$Ecart->Catalog->categories[$parent]->parent;
				}
				$root = $Ecart->Catalog->categories[$parent];
				if ($this->id == $parent && empty($this->children)) return false;

				// Build the section
				$section[] = $root;
				$in = false;
				foreach ($Ecart->Catalog->categories as &$c) {
					if ($in && $c->depth == $root->depth) break; // Done
					if ($in) $section[] = $c;
					if (!$in && isset($c->id) && $c->id == $root->id) $in = true;
				}

				if (value_is_true($dropdown)) {
					$string .= $title;
					$string .= '<select name="ecart_cats" id="ecart-'.$this->slug.'-subcategories-menu" class="ecart-categories-menu">';
					$string .= '<option value="">'.__('Select a sub-category&hellip;','Ecart').'</option>';
					foreach ($section as &$category) {
						if (value_is_true($hierarchy) && $depthlimit && $category->depth >= $depthlimit) continue;
						if (in_array($category->id,$exclude)) continue; // Skip excluded categories
						if ($category->products == 0) continue; // Only show categories with products
						if (value_is_true($hierarchy) && $category->depth > $depth) {
							$parent = &$previous;
							if (!isset($parent->path)) $parent->path = '/'.$parent->slug;
						}
						$padding = str_repeat("&nbsp;",$category->depth*3);

						$category_uri = empty($category->id)?$category->uri:$category->id;
						$link = ECART_PRETTYURLS?ecarturl("category/$category->uri"):ecarturl(array('ecart_category'=>$category_uri));

						$total = '';
						if (value_is_true($products)) $total = '&nbsp;&nbsp;('.$category->total.')';

						$string .= '<option value="'.htmlentities($link).'">'.$padding.$category->name.$total.'</option>';
						$previous = &$category;
						$depth = $category->depth;

					}
					$string .= '</select>';
				} else {
					if (!empty($class)) $classes = ' class="'.$class.'"';
					$string .= $title;
					if ($wraplist) $string .= '<ul'.$classes.'>';
					foreach ($section as &$category) {
						if (in_array($category->id,$exclude)) continue; // Skip excluded categories
						if (value_is_true($hierarchy) && $depthlimit &&
							$category->depth >= $depthlimit) continue;
						if (value_is_true($hierarchy) && $category->depth > $depth) {
							$parent = &$previous;
							if (!isset($parent->path) && isset($parent->slug)) $parent->path = $parent->slug;
							$string = substr($string,0,-5);
							$string .= '<ul class="children">';
						}
						if (value_is_true($hierarchy) && $category->depth < $depth) $string .= '</ul></li>';

						$category_uri = empty($category->id)?$category->uri:$category->id;
						$link = ECART_PRETTYURLS?ecarturl("category/$category->uri"):ecarturl(array('ecart_category'=>$category_uri));

						if (value_is_true($products)) $total = ' <span>('.$category->total.')</span>';

						if ($category->total > 0 || isset($category->smart) || $linkall) $listing = '<a href="'.$link.'"'.$current.'>'.$category->name.$total.'</a>';
						else $listing = $category->name;

						if (value_is_true($showall) ||
							$category->total > 0 ||
							$category->children)
							$string .= '<li>'.$listing.'</li>';

						$previous = &$category;
						$depth = $category->depth;
					}
					if (value_is_true($hierarchy) && $depth > 0)
						for ($i = $depth; $i > 0; $i--) $string .= '</ul></li>';

					if ($wraplist) $string .= '</ul>';
				}
				return $string;
				break;
			case "pagination":
				if (!$this->paged) return "";

				$defaults = array(
					'label' => __("Pages:","Ecart"),
					'next' => __("next","Ecart"),
					'previous' => __("previous","Ecart"),
					'jumpback' => '&laquo;',
					'jumpfwd' => '&raquo;',
					'show' => 1000,
					'before' => '<div>',
					'after' => '</div>'
				);
				$options = array_merge($defaults,$options);
				extract($options);

				$_ = array();
				if (isset($this->alpha) && $this->paged) {
					$_[] = $before.$label;
					$_[] = '<ul class="paging">';
					foreach ($this->alpha as $alpha) {
						$link = $this->pagelink($alpha->letter);
						if ($alpha->total > 0)
							$_[] = '<li><a href="'.$link.'">'.$alpha->letter.'</a></li>';
						else $_[] = '<li><span>'.$alpha->letter.'</span></li>';
					}
					$_[] = '</ul>';
					$_[] = $after;
					return join("\n",$_);
				}

				if ($this->pages > 1) {

					if ( $this->pages > $show ) $visible_pages = $show + 1;
					else $visible_pages = $this->pages + 1;
					$jumps = ceil($visible_pages/2);
					$_[] = $before.$label;

					$_[] = '<ul class="paging">';
					if ( $this->page <= floor(($show) / 2) ) {
						$i = 1;
					} else {
						$i = $this->page - floor(($show) / 2);
						$visible_pages = $this->page + floor(($show) / 2) + 1;
						if ($visible_pages > $this->pages) $visible_pages = $this->pages + 1;
						if ($i > 1) {
							$link = $this->pagelink(1);
							$_[] = '<li><a href="'.$link.'">1</a></li>';

							$pagenum = ($this->page - $jumps);
							if ($pagenum < 1) $pagenum = 1;
							$link = $this->pagelink($pagenum);
							$_[] = '<li><a href="'.$link.'">'.$jumpback.'</a></li>';
						}
					}

					// Add previous button
					if (!empty($previous) && $this->page > 1) {
						$prev = $this->page-1;
						$link = $this->pagelink($prev);
						$_[] = '<li class="previous"><a href="'.$link.'">'.$previous.'</a></li>';
					} else $_[] = '<li class="previous disabled">'.$previous.'</li>';
					// end previous button

					while ($i < $visible_pages) {
						$link = $this->pagelink($i);
						if ( $i == $this->page ) $_[] = '<li class="active">'.$i.'</li>';
						else $_[] = '<li><a href="'.$link.'">'.$i.'</a></li>';
						$i++;
					}
					if ($this->pages > $visible_pages) {
						$pagenum = ($this->page + $jumps);
						if ($pagenum > $this->pages) $pagenum = $this->pages;
						$link = $this->pagelink($pagenum);
						$_[] = '<li><a href="'.$link.'">'.$jumpfwd.'</a></li>';
						$_[] = '<li><a href="'.$link.'">'.$this->pages.'</a></li>';
					}

					// Add next button
					if (!empty($next) && $this->page < $this->pages) {
						$pagenum = $this->page+1;
						$link = $this->pagelink($pagenum);
						$_[] = '<li class="next"><a href="'.$link.'">'.$next.'</a></li>';
					} else $_[] = '<li class="next disabled">'.$next.'</li>';

					$_[] = '</ul>';
					$_[] = $after;
				}
				return join("\n",$_);
				break;

			case "has-faceted-menu": return ($this->facetedmenus == "on"); break;
			case "faceted-menu":
				if ($this->facetedmenus == "off") return;
				$output = "";
				$CategoryFilters =& $Ecart->Flow->Controller->browsing[$this->slug];
				$link = $_SERVER['REQUEST_URI'];
				if (!isset($options['cancel'])) $options['cancel'] = "X";
				if (strpos($_SERVER['REQUEST_URI'],"?") !== false)
					list($link,$query) = explode("?",$_SERVER['REQUEST_URI']);
				$query = $_GET;
				$query = http_build_query($query);
				$link = esc_url($link).'?'.$query;

				$list = "";
				if (is_array($CategoryFilters)) {
					foreach($CategoryFilters AS $facet => $filter) {
						$href = add_query_arg('ecart_catfilters['.urlencode($facet).']','',$link);
						if (preg_match('/^(.*?(\d+[\.\,\d]*).*?)\-(.*?(\d+[\.\,\d]*).*)$/',$filter,$matches)) {
							$label = $matches[1].' &mdash; '.$matches[3];
							if ($matches[2] == 0) $label = __('Under ','Ecart').$matches[3];
							if ($matches[4] == 0) $label = $matches[1].' '.__('and up','Ecart');
						} else $label = $filter;
						if (!empty($filter)) $list .= '<li><strong>'.$facet.'</strong>: '.stripslashes($label).' <a href="'.$href.'=" class="cancel">'.$options['cancel'].'</a></li>';
					}
					$output .= '<ul class="filters enabled">'.$list.'</ul>';
				}

				if ($this->pricerange == "auto" && empty($CategoryFilters['Price'])) {
					if (!$this->loaded) $this->load_products();
					$list = "";
					$this->priceranges = auto_ranges($this->pricing['average'],$this->pricing['max'],$this->pricing['min']);
					foreach ($this->priceranges as $range) {
						$href = add_query_arg('ecart_catfilters[Price]',urlencode(money($range['min']).'-'.money($range['max'])),$link);
						$label = money($range['min']).' &mdash; '.money($range['max']-0.01);
						if ($range['min'] == 0) $label = __('Under ','Ecart').money($range['max']);
						elseif ($range['max'] == 0) $label = money($range['min']).' '.__('and up','Ecart');
						$list .= '<li><a href="'.$href.'">'.$label.'</a></li>';
					}
					if (!empty($this->priceranges)) $output .= '<h4>'.__('Price Range','Ecart').'</h4>';
					$output .= '<ul>'.$list.'</ul>';
				}

				$catalogtable = DatabaseObject::tablename(Catalog::$table);
				$producttable = DatabaseObject::tablename(Product::$table);
				$spectable = DatabaseObject::tablename(Spec::$table);

				$query = "SELECT spec.name,spec.value,
					IF(spec.numeral > 0,spec.name,spec.value) AS merge,
					count(*) AS total,avg(numeral) AS avg,max(numeral) AS max,min(numeral) AS min
					FROM $catalogtable AS cat
					LEFT JOIN $producttable AS p ON cat.product=p.id
					LEFT JOIN $spectable AS spec ON p.id=spec.parent AND spec.context='product' AND spec.type='spec'
					WHERE cat.parent=$this->id AND cat.type='category' AND spec.value != '' AND spec.value != '0' GROUP BY merge ORDER BY spec.name,merge";

				$results = $db->query($query,AS_ARRAY);

				$specdata = array();
				foreach ($results as $data) {
					if (isset($specdata[$data->name])) {
						if (!is_array($specdata[$data->name]))
							$specdata[$data->name] = array($specdata[$data->name]);
						$specdata[$data->name][] = $data;
					} else $specdata[$data->name] = $data;
				}

				if (is_array($this->specs)) {
					foreach ($this->specs as $spec) {
						$list = "";
						if (!empty($CategoryFilters[$spec['name']])) continue;

						// For custom menu presets
						if ($spec['facetedmenu'] == "custom" && !empty($spec['options'])) {
							foreach ($spec['options'] as $option) {
								$href = add_query_arg('ecart_catfilters['.$spec['name'].']',urlencode($option['name']),$link);
								$list .= '<li><a href="'.$href.'">'.$option['name'].'</a></li>';
							}
							$output .= '<h4>'.$spec['name'].'</h4><ul>'.$list.'</ul>';

						// For preset ranges
						} elseif ($spec['facetedmenu'] == "ranges" && !empty($spec['options'])) {
							foreach ($spec['options'] as $i => $option) {
								$matches = array();
								$format = '%s-%s';
								$next = 0;
								if (isset($spec['options'][$i+1])) {
									if (preg_match('/(\d+[\.\,\d]*)/',$spec['options'][$i+1]['name'],$matches))
										$next = $matches[0];
								}
								$matches = array();
								$range = array("min" => 0,"max" => 0);
								if (preg_match('/^(.*?)(\d+[\.\,\d]*)(.*)$/',$option['name'],$matches)) {
									$base = $matches[2];
									$format = $matches[1].'%s'.$matches[3];
									if (!isset($spec['options'][$i+1])) $range['min'] = $base;
									else $range = array("min" => $base, "max" => ($next-1));
								}
								if ($i == 1) {
									$href = add_query_arg('ecart_catfilters['.$spec['name'].']', urlencode(sprintf($format,'0',$range['min'])),$link);
									$label = __('Under ','Ecart').sprintf($format,$range['min']);
									$list .= '<li><a href="'.$href.'">'.$label.'</a></li>';
								}

								$href = add_query_arg('ecart_catfilters['.$spec['name'].']', urlencode(sprintf($format,$range['min'],$range['max'])), $link);
								$label = sprintf($format,$range['min']).' &mdash; '.sprintf($format,$range['max']);
								if ($range['max'] == 0) $label = sprintf($format,$range['min']).' '.__('and up','Ecart');
								$list .= '<li><a href="'.$href.'">'.$label.'</a></li>';
							}
							$output .= '<h4>'.$spec['name'].'</h4><ul>'.$list.'</ul>';

						// For automatically building the menu options
						} elseif ($spec['facetedmenu'] == "auto" && isset($specdata[$spec['name']])) {

							if (is_array($specdata[$spec['name']])) { // Generate from text values
								foreach ($specdata[$spec['name']] as $option) {
									$href = add_query_arg('ecart_catfilters['.$spec['name'].']',urlencode($option->value),$link);
									$list .= '<li><a href="'.$href.'">'.$option->value.'</a></li>';
								}
								$output .= '<h4>'.$spec['name'].'</h4><ul>'.$list.'</ul>';
							} else { // Generate number ranges
								$format = '%s';
								if (preg_match('/^(.*?)(\d+[\.\,\d]*)(.*)$/',$specdata[$spec['name']]->content,$matches))
									$format = $matches[1].'%s'.$matches[3];

								$ranges = auto_ranges($specdata[$spec['name']]->avg,$specdata[$spec['name']]->max,$specdata[$spec['name']]->min);
								foreach ($ranges as $range) {
									$href = add_query_arg('ecart_catfilters['.$spec['name'].']', urlencode($range['min'].'-'.$range['max']), $link);
									$label = sprintf($format,$range['min']).' &mdash; '.sprintf($format,$range['max']);
									if ($range['min'] == 0) $label = __('Under ','Ecart').sprintf($format,$range['max']);
									elseif ($range['max'] == 0) $label = sprintf($format,$range['min']).' '.__('and up','Ecart');
									$list .= '<li><a href="'.$href.'">'.$label.'</a></li>';
								}
								if (!empty($list)) $output .= '<h4>'.$spec['name'].'</h4>';
								$output .= '<ul>'.$list.'</ul>';

							}
						}
					}
				}


				return $output;
				break;
			case "hasimages":
			case "has-images":
				if (empty($this->images)) $this->load_images();
				if (empty($this->images)) return false;
				return true;
				break;
			case "images":
				if (!isset($this->_images_loop)) {
					reset($this->images);
					$this->_images_loop = true;
				} else next($this->images);

				if (current($this->images) !== false) return true;
				else {
					unset($this->_images_loop);
					return false;
				}
				break;
			case "coverimage":
			case "thumbnail": // deprecated
				// Force select the first loaded image
				unset($options['id']);
				$options['index'] = 0;
			case "image":
				if (empty($this->images)) $this->load_images();
				if (!(count($this->images) > 0)) return "";

				// Compatibility defaults
				$_size = 96;
				$_width = $Ecart->Settings->get('gallery_thumbnail_width');
				$_height = $Ecart->Settings->get('gallery_thumbnail_height');
				if (!$_width) $_width = $_size;
				if (!$_height) $_height = $_size;

				$defaults = array(
					'img' => false,
					'id' => false,
					'index' => false,
					'class' => '',
					'width' => false,
					'height' => false,
					'width_a' => false,
					'height_a' => false,
					'size' => false,
					'fit' => false,
					'sharpen' => false,
					'quality' => false,
					'bg' => false,
					'alt' => '',
					'title' => '',
					'zoom' => '',
					'zoomfx' => 'ecart-zoom',
					'property' => false
				);
				$options = array_merge($defaults,$options);
				extract($options);

				// Select image by database id
				if ($id !== false) {
					for ($i = 0; $i < count($this->images); $i++) {
						if ($img->id == $id) {
							$img = $this->images[$i]; break;
						}
					}
					if (!$img) return "";
				}

				// Select image by index position in the list
				if ($index !== false && isset($this->images[$index]))
					$img = $this->images[$index];

				// Use the current image pointer by default
				if (!$img) $img = current($this->images);

				if ($size !== false) $width = $height = $size;
				if (!$width) $width = $_width;
				if (!$height) $height = $_height;

				$scale = $fit?array_search($fit,$img->_scaling):false;
				$sharpen = $sharpen?min($sharpen,$img->_sharpen):false;
				$quality = $quality?min($quality,$img->_quality):false;
				$fill = $bg?hexdec(ltrim($bg,'#')):false;

				list($width_a,$height_a) = array_values($img->scaled($width,$height,$scale));
				if ($size == "original") {
					$width_a = $img->width;
					$height_a = $img->height;
				}
				if ($width_a === false) $width_a = $width;
				if ($height_a === false) $height_a = $height;

				$alt = esc_attr(empty($alt)?(empty($img->alt)?$img->name:$img->alt):$alt);
				$title = empty($title)?$img->title:$title;
				$titleattr = empty($title)?'':' title="'.esc_attr($title).'"';
				$classes = empty($class)?'':' class="'.esc_attr($class).'"';

				$src = ecarturl($img->id,'images');
				if ($size != "original") {
					$src = add_query_string(
						$img->resizing($width,$height,$scale,$sharpen,$quality,$fill),
						trailingslashit(ecarturl($img->id,'images')).$img->filename
					);
				}

				switch (strtolower($property)) {
					case "id": return $img->id; break;
					case "url":
					case "src": return $src; break;
					case "title": return $title; break;
					case "alt": return $alt; break;
					case "width": return $width_a; break;
					case "height": return $height_a; break;
					case "class": return $class; break;
				}

				$imgtag = '<img src="'.$src.'"'.$titleattr.' alt="'.$alt.'" width="'.$width_a.'" height="'.$height_a.'" '.$classes.' />';

				if (value_is_true($zoom))
					return '<a href="'.ecarturl($img->id,'images').'/'.$img->filename.'" class="'.$zoomfx.'" rel="product-'.$this->id.'">'.$imgtag.'</a>';

				return $imgtag;
				break;
			case "slideshow":
				$options['load'] = array('images');
				if (!$this->loaded) $this->load_products($options);
				if (count($this->products) == 0) return false;

				$defaults = array(
					'width' => '440',
					'height' => '180',
					'fit' => 'crop',
					'fx' => 'fade',
					'duration' => 1000,
					'delay' => 7000,
					'order' => 'normal'
				);
				$options = array_merge($defaults,$options);
				extract($options, EXTR_SKIP);

				$href = ecarturl(ECART_PERMALINKS?trailingslashit('000'):'000','images');
				$imgsrc = add_query_string("$width,$height",$href);

				$string = '<ul class="slideshow '.$fx.'-fx '.$order.'-order duration-'.$duration.' delay-'.$delay.'">';
				$string .= '<li class="clear"><img src="'.$imgsrc.'" width="'.$width.'" height="'.$height.'" /></li>';
				foreach ($this->products as $Product) {
					if (empty($Product->images)) continue;
					$string .= '<li><a href="'.$Product->tag('url').'">';
					$string .= $Product->tag('image',array('width'=>$width,'height'=>$height,'fit'=>$fit));
					$string .= '</a></li>';
				}
				$string .= '</ul>';
				return $string;
				break;
			case "carousel":
				$options['load'] = array('images');
				if (!$this->loaded) $this->load_products($options);
				if (count($this->products) == 0) return false;

				$defaults = array(
					'imagewidth' => '96',
					'imageheight' => '96',
					'fit' => 'all',
					'duration' => 500
				);
				$options = array_merge($defaults,$options);
				extract($options, EXTR_SKIP);

				$string = '<div class="carousel duration-'.$duration.'">';
				$string .= '<div class="frame">';
				$string .= '<ul>';
				foreach ($this->products as $Product) {
					if (empty($Product->images)) continue;
					$string .= '<li><a href="'.$Product->tag('url').'">';
					$string .= $Product->tag('image',array('width'=>$imagewidth,'height'=>$imageheight,'fit'=>$fit));
					$string .= '</a></li>';
				}
				$string .= '</ul></div>';
				$string .= '<button type="button" name="left" class="left">&nbsp;</button>';
				$string .= '<button type="button" name="right" class="right">&nbsp;</button>';
				$string .= '</div>';
				return $string;
				break;
		}
	}
Example #18
0
File: index.php Project: mvnp/site
    ?>
            <tr>
                <td class="text-center"><a href="orders.php?txn_id=<?php 
    echo $order['id'];
    ?>
" class="btn btn-xs btn-info">Details</a></td>
                <td><?php 
    echo $order['full_name'];
    ?>
</td>
                <td><?php 
    echo $order['description'];
    ?>
</td>
                <td><?php 
    echo money($order['grand_total']);
    ?>
</td>
                <td><?php 
    echo format_date($order['txn_date']);
    ?>
</td>
            </tr>
            <?php 
}
?>
        </tbody>
    
    </table>
</div>
Example #19
0
			<th scope='row' class='check-column'><input type='checkbox' name='selected[]' value='<?php echo $Customer->id; ?>' /></th>
			<td class="name column-name"><a class='row-title' href='<?php echo esc_url( add_query_arg(array('page'=>'ecart-customers','id'=>$Customer->id),admin_url('admin.php'))); ?>' title='<?php _e('Edit','Ecart'); ?> &quot;<?php echo esc_attr($CustomerName); ?>&quot;'><?php echo esc_html($CustomerName); ?></a><?php echo !empty($Customer->company)?"<br />".esc_html($Customer->company):""; ?></td>
			<td class="login column-login<?php echo in_array('login',$hidden)?' hidden':''; ?>"><?php echo esc_html($Customer->user_login); ?></td>
			<td class="email column-email<?php echo in_array('email',$hidden)?' hidden':''; ?>"><a href="mailto:<?php echo esc_attr($Customer->email); ?>"><?php echo esc_html($Customer->email); ?></a></td>

			<td class="location column-location<?php echo in_array('location',$hidden)?' hidden':''; ?>"><?php
				$location = '';
				$location = $Customer->city;
				if (!empty($location) && !empty($Customer->state)) $location .= ', ';
				$location .= $Customer->state;
				if (!empty($location) && !empty($Customer->country))
					$location .= ' &mdash; ';
				$location .= $Customer->country;
				echo esc_html($location);
				 ?></td>
			<td class="total column-total<?php echo in_array('total',$hidden)?' hidden':''; ?>"><a href="<?php echo esc_url( add_query_arg(array('page'=>'ecart-orders','customer'=>$Customer->id),admin_url('admin.php'))); ?>"><?php echo $Customer->orders; ?> &mdash; <?php echo money($Customer->total); ?></a></td>
			<td class="date column-date<?php echo in_array('date',$hidden)?' hidden':''; ?>"><?php echo date("Y/m/d",mktimestamp($Customer->created)); ?></td>
		</tr>
		<?php endforeach; ?>
		</tbody>
	<?php else: ?>
		<tbody><tr><td colspan="6"><?php _e('No','Ecart'); ?> <?php _e('customers, yet.','Ecart'); ?></td></tr></tbody>
	<?php endif; ?>
	</table>

	</form>
	<div class="tablenav" style="display:none !important;">
		<?php if(current_user_can('ecart_export_customers')): ?>
		<div class="alignleft actions">
			<form action="<?php echo esc_url(add_query_arg(array_merge($_GET,array('src'=>'export_customers')),admin_url("admin.php"))); ?>" id="log" method="post">
			<button type="button" id="export-settings-button" name="export-settings" class="button-secondary"><?php _e('Export Options','Ecart'); ?></button>
Example #20
0
 static function grossed($data)
 {
     return money($data->grossed);
 }
Example #21
0
,</strong></p>
	<p>Please verify your subscription information below. Your contact information is received from Paypal. When you are satisfied, click <strong>Pay Now</strong> to confirm the subscription.</p>

	<div class="page" style="background-color:#FFF;padding-bottom:0px;">

		<table style="width:100%;">

			<tr><td style="vertical-align:top;">
				<h3>Subscription Info</h3>
				<table style="width:100%;">
					<tr><th>Membership Plan:</th><td><?php 
echo $sub_info['description'];
?>
</td></tr>
					<tr><th>Plan Price:</th><td><?php 
echo money($sub_info['amount']);
?>
 <?php 
echo $sub_info['currency_code'];
?>
</td></tr>
					<tr><th>Billing Period:</th><td><?php 
echo $sub_info['billing_period'];
?>
</td></tr>
					<tr><th>Plan Begins:</th><td><?php 
echo date('M j Y');
?>
</td></tr>
					<tr><th>&nbsp;</th><td>&nbsp;</td></tr>
					<tr><th>
Example #22
0
	/**
	 * Provides ecart('shipping') template API functionality
	 *
	 * Used primarily in the summary.php template
	 *	 
	 * @since 1.0
	 *
	 * @return mixed
	 **/
	function shippingtag ($property,$options=array()) {
		global $Ecart;
		$result = "";

		switch ($property) {
			case "url": return is_ecart_page('checkout')?ecarturl(false,'confirm-order'):ecarturl(false,'cart');
			case "hasestimates": return apply_filters('ecart_shipping_hasestimates',!empty($this->shipping)); break;
			case "options":
			case "methods":
				if (!isset($this->sclooping)) $this->sclooping = false;
				if (!$this->sclooping) {
					reset($this->shipping);
					$this->sclooping = true;
				} else next($this->shipping);

				if (current($this->shipping) !== false) return true;
				else {
					$this->sclooping = false;
					reset($this->shipping);
					return false;
				}
				break;
			case "option-menu":
			case "method-menu":
				// @todo Add options for differential pricing and estimated delivery dates
				$_ = array();
				$_[] = '<select name="shipmethod" class="ecart shipmethod">';
				foreach ($this->shipping as $method) {
					$selected = ((isset($Ecart->Order->Shipping->method) &&
						$Ecart->Order->Shipping->method == $method->name))?' selected="selected"':false;

					$_[] = '<option value="'.$method->name.'"'.$selected.'>'.$method->name.' &mdash '.money($method->amount).'</option>';
				}
				$_[] = '</select>';
				return join("",$_);
				break;
			case "option-name":
			case "method-name":
				$option = current($this->shipping);
				return $option->name;
				break;
			case "method-selected":
				$method = current($this->shipping);
				return ((isset($Ecart->Order->Shipping->method) &&
					$Ecart->Order->Shipping->method == $method->name));
				break;
			case "option-cost":
			case "method-cost":
				$option = current($this->shipping);
				return money($option->amount);
				break;
			case "method-selector":
				$method = current($this->shipping);

				$checked = '';
				if ((isset($Ecart->Order->Shipping->method) &&
					$Ecart->Order->Shipping->method == $method->name))
						$checked = ' checked="checked"';

				$result = '<input type="radio" name="shipmethod" value="'.$method->name.'" class="ecart shipmethod" '.$checked.' />';
				return $result;

				break;
			case "option-delivery":
			case "method-delivery":
				$periods = array("h"=>3600,"d"=>86400,"w"=>604800,"m"=>2592000);
				$option = current($this->shipping);
				if (!$option->delivery) return "";
				$estimates = explode("-",$option->delivery);
				$format = get_option('date_format');
				if (count($estimates) > 1
					&& $estimates[0] == $estimates[1]) $estimates = array($estimates[0]);
				$result = "";
				for ($i = 0; $i < count($estimates); $i++) {
					list($interval,$p) = sscanf($estimates[$i],'%d%s');
					if (empty($interval)) $interval = 1;
					if (empty($p)) $p = 'd';
					if (!empty($result)) $result .= "&mdash;";
					$result .= _d($format,mktime()+($interval*$periods[$p]));
				}
				return $result;
		}
	}
Example #23
0
 /**
  * Provides a property or list of properties for the current download from the downloads loop
  *
  * @api `shopp('customer.download')`
  * @since 1.3
  *
  * @param string        $result  The output
  * @param array         $options The options
  * @param ShoppCustomer $O       The working object
  * @return string The download property list
  **/
 public static function download($result, $options, $O)
 {
     $download = $O->_download;
     $df = get_option('date_format');
     $string = '';
     if (array_key_exists('id', $options)) {
         $string .= $download->download;
     }
     if (array_key_exists('purchase', $options)) {
         $string .= $download->purchase;
     }
     if (array_key_exists('name', $options)) {
         $string .= $download->name;
     }
     if (array_key_exists('variation', $options)) {
         $string .= $download->optionlabel;
     }
     if (array_key_exists('downloads', $options)) {
         $string .= $download->downloads;
     }
     if (array_key_exists('key', $options)) {
         $string .= $download->dkey;
     }
     if (array_key_exists('created', $options)) {
         $string .= $download->created;
     }
     if (array_key_exists('total', $options)) {
         $string .= money($download->total);
     }
     if (array_key_exists('filetype', $options)) {
         $string .= $download->mime;
     }
     if (array_key_exists('size', $options)) {
         $string .= readableFileSize($download->size);
     }
     if (array_key_exists('date', $options)) {
         $string .= _d($df, $download->created);
     }
     if (array_key_exists('url', $options)) {
         $string .= Shopp::url('' == get_option('permalink_structure') ? array('src' => 'download', 'shopp_download' => $download->dkey) : 'download/' . $download->dkey, 'account');
     }
     return $string;
 }
Example #24
0
 /**
  * Renders the recent orders dashboard widget
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @return void
  **/
 public static function orders_widget($args = false)
 {
     $defaults = array('before_widget' => '', 'before_title' => '', 'widget_name' => '', 'after_title' => '', 'after_widget' => '');
     $args = array_merge($defaults, (array) $args);
     extract($args, EXTR_SKIP);
     $statusLabels = shopp_setting('order_status');
     echo $before_widget;
     echo $before_title;
     echo $widget_name;
     echo $after_title;
     $purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
     $purchasedtable = ShoppDatabaseObject::tablename(Purchased::$table);
     $txnlabels = Lookup::txnstatus_labels();
     if (!($Orders = get_transient('shopp_dashboard_orders'))) {
         $Orders = sDB::query("SELECT p.*,count(*) as items FROM (SELECT * FROM {$purchasetable} WHERE txnstatus != 'purchased' AND txnstatus != 'invoiced' ORDER BY created DESC LIMIT 6) AS p LEFT JOIN {$purchasedtable} AS i ON i.purchase=p.id GROUP BY p.id ORDER BY p.id DESC", 'array');
         set_transient('shopp_dashboard_orders', $Orders, 90);
         // Keep for the next 1 minute
     }
     if (!empty($Orders)) {
         echo '<table class="widefat">' . '<thead>' . '	<tr>' . '		<th scope="col">' . __('Name', 'Shopp') . '</th>' . '		<th scope="col">' . __('Date', 'Shopp') . '</th>' . '		<th scope="col" class="num">' . Shopp::__('Items') . '</th>' . '		<th scope="col" class="num">' . Shopp::__('Total') . '</th>' . '		<th scope="col" class="num">' . Shopp::__('Status') . '</th>' . '	</tr>' . '</thead>' . '	<tbody id="orders" class="list orders">';
         $even = false;
         foreach ($Orders as $Order) {
             $classes = array();
             if ($even = !$even) {
                 $classes[] = 'alternate';
             }
             $txnstatus = isset($txnlabels[$Order->txnstatus]) ? $txnlabels[$Order->txnstatus] : $Order->txnstatus;
             $status = isset($statusLabels[$Order->status]) ? $statusLabels[$Order->status] : $Order->status;
             $contact = '' == $Order->firstname . $Order->lastname ? '(no contact name)' : $Order->firstname . ' ' . $Order->lastname;
             $url = add_query_arg(array('page' => ShoppAdmin()->pagename('orders'), 'id' => $Order->id), admin_url('admin.php'));
             $classes[] = strtolower(preg_replace('/[^\\w]/', '_', $Order->txnstatus));
             echo '<tr class="' . join(' ', $classes) . '">' . '	<td><a class="row-title" href="' . $url . '" title="View &quot;Order ' . $Order->id . '&quot;">' . (empty($Order->firstname) && empty($Order->lastname) ? '(no contact name)' : $Order->firstname . ' ' . $Order->lastname) . '</a></td>' . '	<td>' . date("Y/m/d", mktimestamp($Order->created)) . '</td>' . '	<td class="num items">' . $Order->items . '</td>' . '	<td class="num total">' . money($Order->total) . '</td>' . '	<td class="num status">' . $statusLabels[$Order->status] . '</td>' . '</tr>';
         }
         echo '</tbody></table>';
     } else {
         echo '<p>' . Shopp::__('No orders, yet.') . '</p>';
     }
     echo $after_widget;
 }
Example #25
0
    ?>
</td>-->
                            <td>¥<?php 
    echo bcadd(money($v->normal_return_profit_sub2self), bcadd(money($v->extra_return_profit_sub2self), 0, 2), 2);
    ?>
</td>
                            <!--<td><?php 
    echo cny($v->normal_return_profit_self2parent);
    ?>
</td>
                            <td><?php 
    echo cny($v->extra_return_profit_self2parent);
    ?>
</td>
                            <td>¥<?php 
    echo bcadd(money($v->normal_return_profit_self2parent), money($v->extra_return_profit_self2parent), 2);
    ?>
</td>-->
                            <?php 
    if (intval($v->pid) <= 0 || $v->pid == '') {
        ?>
                                <td></td>
                            <?php 
    } else {
        ?>
                                <td><a target="_blank" href="<?php 
        echo base_url();
        ?>
user/details_admin/<?php 
        echo $v->pid;
        ?>
 function dashboard_orders($args = null)
 {
     global $Shopp;
     $db = DB::get();
     $defaults = array('before_widget' => '', 'before_title' => '', 'widget_name' => '', 'after_title' => '', 'after_widget' => '');
     if (!$args) {
         $args = array();
     }
     $args = array_merge($defaults, $args);
     if (!empty($args)) {
         extract($args, EXTR_SKIP);
     }
     $statusLabels = $this->Settings->get('order_status');
     echo $before_widget;
     echo $before_title;
     echo $widget_name;
     echo $after_title;
     $purchasetable = DatabaseObject::tablename(Purchase::$table);
     $purchasedtable = DatabaseObject::tablename(Purchased::$table);
     $Orders = $db->query("SELECT p.*,count(i.id) as items FROM {$purchasetable} AS p LEFT JOIN {$purchasedtable} AS i ON i.purchase=p.id GROUP BY i.purchase ORDER BY created DESC LIMIT 6", AS_ARRAY);
     if (!empty($Orders)) {
         echo '<table class="widefat">';
         echo '<tr><th scope="col">' . __('Name', 'Shopp') . '</th><th scope="col">' . __('Date', 'Shopp') . '</th><th scope="col" class="num">' . __('Items', 'Shopp') . '</th><th scope="col" class="num">' . __('Total', 'Shopp') . '</th><th scope="col" class="num">' . __('Status', 'Shopp') . '</th></tr>';
         echo '<tbody id="orders" class="list orders">';
         $even = false;
         foreach ($Orders as $Order) {
             echo '<tr' . (!$even ? ' class="alternate"' : '') . '>';
             $even = !$even;
             echo '<td><a class="row-title" href="' . add_query_arg(array('page' => $this->Admin->orders, 'id' => $Order->id), $Shopp->wpadminurl . "admin.php") . '" title="View &quot;Order ' . $Order->id . '&quot;">' . (empty($Order->firstname) && empty($Order->lastname) ? '(no contact name)' : $Order->firstname . ' ' . $Order->lastname) . '</a></td>';
             echo '<td>' . date("Y/m/d", mktimestamp($Order->created)) . '</td>';
             echo '<td class="num">' . $Order->items . '</td>';
             echo '<td class="num">' . money($Order->total) . '</td>';
             echo '<td class="num">' . $statusLabels[$Order->status] . '</td>';
             echo '</tr>';
         }
         echo '</tbody></table>';
     } else {
         echo '<p>' . __('No orders, yet.', 'Shopp') . '</p>';
     }
     echo $after_widget;
 }
Example #27
0
         <td>
           <a href="products.php?edit=<?php 
        echo $product['id'];
        ?>
" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
           <a href="products.php?delete=<?php 
        echo $product['id'];
        ?>
" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-remove"></span></a>
         </td>
         <td><?php 
        echo $product['title'];
        ?>
</td>
         <td><?php 
        echo money($product['price']);
        ?>
</td>
         <td><?php 
        echo $category;
        ?>
</td>
         <td><a href="products.php?featured=<?php 
        echo $product['featured'] == 0 ? '1' : '0';
        ?>
&id=<?php 
        echo $product['id'];
        ?>
" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-<?php 
        echo $product['featured'] == 1 ? 'minus' : 'plus';
        ?>
Example #28
0
function history_meta_box($Purchase)
{
    echo '<table class="widefat history">';
    echo '<tfoot>';
    echo '<tr class="balance"><td colspan="3">' . __('Order Balance', 'Shopp') . '</td><td>' . money($Purchase->balance) . '</td></tr>';
    echo '</tfoot>';
    echo '<tbody>';
    foreach ($Purchase->events as $id => $Event) {
        echo apply_filters('shopp_order_manager_event', $Event);
    }
    echo '</tbody>';
    echo '</table>';
}
Example #29
0
 function printSeat($f_iSeat)
 {
     global $szEmptySeat;
     $iSeat = min(MAX_PLAYERS_EVER, max(1, (int) $f_iSeat));
     $arrSeat = getSeatInfo($iSeat);
     $szHtml = '';
     if ($arrSeat) {
         $arrPlayer = $arrSeat[0];
         $szHtml .= '<td' . ((int) $arrPlayer['user_id'] === USER_ID ? ' bgcolor="#eeeeee"' : '') . '>';
         $szHtml .= '<table width="100%" height="100%">';
         $szHtml .= '<tr>';
         $szHtml .= '<td></td>';
         $szHtml .= '<td>[action]</td>';
         $szHtml .= '<td>[notes]</td>';
         $szHtml .= '</tr>';
         $szHtml .= '<tr>';
         $szHtml .= '<td></td>';
         $szHtml .= '<td class="center">' . $arrPlayer['username'] . '</td>';
         $szHtml .= '<td></td>';
         $szHtml .= '</tr>';
         $szHtml .= '<tr>';
         $szHtml .= '<td></td>';
         $szHtml .= '<td>' . money($arrPlayer['balance']) . '</td>';
         $szHtml .= '<td></td>';
         $szHtml .= '</tr>';
         $szHtml .= '</table>';
         $szHtml .= '</td>';
     } else {
         $szHtml .= '<td>' . sprintf($szEmptySeat, $iSeat) . '</td>';
     }
     return $szHtml;
 }
Example #30
0
 public function parse($column)
 {
     if (sdb::serialized($column)) {
         $list = unserialize($column);
         $column = "";
         foreach ($list as $name => $value) {
             if (is_a($value, 'ShoppPurchaseDiscount')) {
                 $Discount = $value;
                 $column .= (empty($column) ? "" : ";") . trim("{$Discount->id}:{$Discount->name} (" . money($Discount->discount) . ") {$Discount->code}");
             } else {
                 $column .= (empty($column) ? "" : ";") . "{$name}:{$value}";
             }
         }
     }
     return $this->escape($column);
 }