Lotsa updates.

git-svn-id: http://svn.cleancode.org/svn/pickles@139 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
Josh Sherman 2009-07-09 03:58:47 +00:00
parent 21e2c997ce
commit d267b214ea
24 changed files with 949 additions and 123 deletions

View file

@ -208,9 +208,9 @@ class Config extends Object {
$additional = null;
if (strpos($requested_module, '_') !== false) {
list($requested_module, $additional) = split('_', $requested_module, 2);
$additional = '_' . $additional;
if (strpos($requested_module, '/') !== false) {
list($requested_module, $additional) = split('/', $requested_module, 2);
$additional = '/' . $additional;
}
if (isset($this->modules->shared->module)) {

View file

@ -36,6 +36,8 @@
*/
class Controller extends Object {
private $execute_tests = false;
/**
* Constructor
*
@ -116,6 +118,11 @@ class Controller extends Object {
break;
default:
// @todo Add conditional for the environment
if ($display_type == 'test') {
$this->execute_tests = true;
}
unset($display_type);
break;
}
@ -139,11 +146,10 @@ class Controller extends Object {
$module['requested']['class_name'] = strtr($module['requested']['filename'], '/', '_');
// Establishes the shared module information
// @todo Bug with requested modules with a dash in the name (store-locator == shared module 'store')
$module['shared']['class_name'] = $config->getSharedModule($module['requested']['class_name']);
$module['shared']['filename'] = strtr($module['shared']['class_name'], '_', '/');
$module['shared']['name'] = $config->getSharedModule($module['requested']['name']);
$module['shared']['filename'] = strtr($module['shared']['name'], '-', '_');
$module['shared']['php_file'] = PICKLES_PATH . 'common/modules/' . $module['shared']['filename'] . '.php';
$module['shared']['name'] = $module['shared']['filename'];
$module['shared']['class_name'] = strtr($module['shared']['filename'], '/', '_');
// Tries to load the site level module
if (file_exists($module['requested']['php_file'])) {
@ -238,6 +244,11 @@ class Controller extends Object {
$display->shared_module_name = $module['shared']['name'];
$display->shared_module_filename = $module['shared']['filename'];
if ($this->execute_tests == true) {
var_dump($module);
exit('caught test');
}
// Loads the module data into the display to be rendered
/**
* @todo perhaps make this a passed variable

View file

@ -142,6 +142,7 @@ class Display_Smarty extends Display_Common {
if (!$this->smarty->is_cached($template, $cache_id)) {
// Build the combined module name array and assign it
$this->module_name = str_replace('-', '_', $this->module_name);
$module_name = split('/', $this->module_name);
array_unshift($module_name, $this->module_name);
$this->smarty->assign('module_name', $module_name);

View file

@ -21,7 +21,7 @@ class store_admin extends Module {
);
$this->setPublic('options', $options);
$this->template = 'store/admin';
$this->shared_template = 'store/admin';
}
public function __default() {

View file

@ -9,18 +9,6 @@ class store_admin_customers extends store_admin {
emails.email,
billing.company AS billing_company,
billing.first_name AS billing_first_name,
billing.last_name AS billing_last_name,
billing.address1 AS billing_address1,
billing.address2 AS billing_address2,
billing.city AS billing_city,
billing.state AS billing_state,
billing.zip_code AS billing_zip_code,
billing.country AS billing_country,
billing.phone AS billing_phone,
billing.fax AS billing_fax,
shipping.company AS shipping_company,
shipping.first_name AS shipping_first_name,
shipping.last_name AS shipping_last_name,
@ -40,10 +28,7 @@ class store_admin_customers extends store_admin {
INNER JOIN emails
ON emails.id = customers.email_id
INNER JOIN addresses AS billing
ON billing.id = customers.billing_address_id
INNER JOIN addresses AS shipping
LEFT JOIN addresses AS shipping
ON shipping.id = customers.shipping_address_id
LEFT JOIN orders
@ -52,6 +37,8 @@ class store_admin_customers extends store_admin {
GROUP BY customers.id
ORDER BY shipping.last_name, shipping.first_name
;
';

View file

@ -0,0 +1,59 @@
<?php
class store_admin_customers_edit extends store_admin {
protected $display = array(DISPLAY_SMARTY, DISPLAY_JSON);
public function __default() {
if (isset($_REQUEST['id'])) {
$sql = '
SELECT
customers.*,
emails.email,
billing.company AS billing_company,
billing.first_name AS billing_first_name,
billing.last_name AS billing_last_name,
billing.address1 AS billing_address1,
billing.address2 AS billing_address2,
billing.city AS billing_city,
billing.state AS billing_state,
billing.zip_code AS billing_zip_code,
billing.country AS billing_country,
billing.phone AS billing_phone,
billing.fax AS billing_fax,
shipping.company AS shipping_company,
shipping.first_name AS shipping_first_name,
shipping.last_name AS shipping_last_name,
shipping.address1 AS shipping_address1,
shipping.address2 AS shipping_address2,
shipping.city AS shipping_city,
shipping.state AS shipping_state,
shipping.zip_code AS shipping_zip_code,
shipping.country AS shipping_country,
shipping.phone AS shipping_phone,
shipping.fax AS shipping_fax
FROM customers
INNER JOIN emails
ON emails.id = customers.email_id
INNER JOIN addresses AS billing
ON billing.id = customers.billing_address_id
INNER JOIN addresses AS shipping
ON shipping.id = customers.shipping_address_id
WHERE customers.id = "' . $_REQUEST['id'] . '";
';
$this->setPublic('customer', $this->db->getRow($sql));
}
}
}
?>

View file

@ -0,0 +1,147 @@
<?php
class store_admin_customers_save extends store_admin {
protected $display = DISPLAY_JSON;
public function __default() {
$update_password = false;
if (isset($_REQUEST['password']) && trim($_REQUEST['password']) != '') {
if ($_REQUEST['password'] != $_REQUEST['password_verify']) {
$this->setPublic('status', 'Error');
$this->setPublic('message', 'The password and verification do not match.');
return false;
}
else {
$update_password = true;
}
}
// Adds the billing information into the database
if (isset($_REQUEST['billing_address1']) && trim($_REQUEST['billing_address1']) != '') {
$billing_address = array(
'company' => $_REQUEST['billing_company'],
'first_name' => $_REQUEST['billing_first_name'],
'last_name' => $_REQUEST['billing_last_name'],
'address1' => $_REQUEST['billing_address1'],
'address2' => $_REQUEST['billing_address2'],
'city' => $_REQUEST['billing_city'],
'state' => $_REQUEST['billing_state'],
'zip_code' => $_REQUEST['billing_zip_code'],
'country' => 'US',
'phone' => $_REQUEST['billing_phone'],
'fax' => $_REQUEST['billing_fax']
);
$billing_address['hash'] = md5(implode('', $billing_address));
if ($this->db->getField("SELECT COUNT(*) FROM addresses WHERE hash = '{$billing_address['hash']}';") == 0) {
$billing_address_id = $this->db->insert('addresses', $billing_address);
}
else {
$billing_address = $this->db->getRow("SELECT * FROM addresses WHERE hash = '{$billing_address['hash']}';");
$billing_address_id = $billing_address['id'];
}
}
// Adds the shipping information into the database
$shipping_address_id = null;
if (isset($_REQUEST['shipping_same_as_billing']) && $_REQUEST['shipping_same_as_billing'] == 'on') {
$shipping_address_id = $billing_address_id;
$shipping_address = $billing_address;
}
else if (isset($_REQUEST['shipping_address1']) && trim($_REQUEST['shipping_address1']) != '') {
$shipping_address = array(
'company' => $_REQUEST['shipping_company'],
'first_name' => $_REQUEST['shipping_first_name'],
'last_name' => $_REQUEST['shipping_last_name'],
'address1' => $_REQUEST['shipping_address1'],
'address2' => $_REQUEST['shipping_address2'],
'city' => $_REQUEST['shipping_city'],
'state' => $_REQUEST['shipping_state'],
'zip_code' => $_REQUEST['shipping_zip_code'],
'country' => 'US',
'phone' => $_REQUEST['shipping_phone'],
'fax' => $_REQUEST['shipping_fax']
);
$shipping_address['hash'] = md5(implode('', $shipping_address));
if ($this->db->getField("SELECT COUNT(*) FROM addresses WHERE hash = '{$shipping_address['hash']}';") == 0) {
$shipping_address_id = $this->db->insert('addresses', $shipping_address);
}
else {
$shipping_address = $this->db->getRow("SELECT * FROM addresses WHERE hash = '{$shipping_address['hash']}';");
$shipping_address_id = $shipping_address['id'];
}
}
// Adds the customer's email into the email database
if (isset($_REQUEST['email']) && trim($_REQUEST['email']) != '') {
$email = $_REQUEST['email'];
if ($this->db->getField("SELECT COUNT(*) FROM emails WHERE email = '{$email}';") == 0) {
$email_id = $this->db->insert('emails', array('email' => $email));
}
else {
$email_id = $this->db->getField("SELECT id FROM emails WHERE email = '{$email}';");
}
}
// Updates the existing customer
if (isset($_REQUEST['id'])) {
$customer = array(
'email_id' => $email_id,
'billing_address_id' => $billing_address_id,
'shipping_address_id' => $shipping_address_id
);
if ($update_password == true) {
$customer['password'] = md5($_REQUEST['password']);
}
$this->db->update('customers', $customer, array('id' => $_REQUEST['id']));
if ($this->error->getErrors()) {
$this->setPublic('status', 'Error');
$this->setPublic('message', 'There was an error updating the customer account (' . implode('. ', $this->error->getErrors()) . '.)');
return false;
}
else {
$this->setPublic('status', 'Success');
$this->setPublic('message', 'The customer information has been updated successfully.');
}
}
// Adds a brand new affiliate
else {
$customer = array(
'email_id' => $email_id,
'password' => md5($_REQUEST['password']),
'billing_address_id' => $billing_address_id,
'shipping_address_id' => $shipping_address_id,
'created_at' => time()
);
$customer_id = $this->db->insert('customers', $customer);
if ($this->error->getErrors()) {
$this->setPublic('status', 'Error');
$this->setPublic('message', 'There was an error adding the customer account (' . implode('. ', $this->error->getErrors()) . '.)');
return false;
}
else {
// @todo Leverage sign up code and reuse here
//mail($_REQUEST['email'], 'Welcome to the ' . $this->config->store->title . ' Affiliate Program', $customer_message, 'From: ' . $this->config->store->return_email);
$this->setPublic('status', 'Success');
$this->setPublic('message', 'The new customer has been added successfully.');
}
}
}
}
?>

View file

@ -4,8 +4,9 @@ class store_admin_discounts extends store_admin {
public function __default() {
$sql = '
SELECT *
FROM discounts
SELECT d1.*
FROM discounts AS d1
WHERE d1.sequence = (SELECT MAX(sequence) FROM discounts WHERE id = d1.id)
ORDER BY valid_through;
';

View file

@ -0,0 +1,70 @@
<?php
class store_admin_discounts_edit extends store_admin {
protected $display = array(DISPLAY_SMARTY, DISPLAY_JSON);
public function __default() {
$sql = '
SELECT c.id, CONCAT(a.last_name, ", ", a.first_name) AS name
FROM customers AS c
INNER JOIN addresses AS a
ON c.shipping_address_id = a.id;
';
$this->setPublic('customers', $this->flattenArray($this->db->getArray($sql)));
$this->setPublic('categories', $this->flattenArray($this->db->getArray('SELECT id, name FROM categories;')));
$this->setPublic('products', $this->flattenArray($this->db->getArray('SELECT id, name FROM products;')));
$this->setPublic('applied_to_options', array('ORDER' => 'Order', 'PRODUCT' => 'Product', 'SHIPPING' => 'Shipping'));
$this->setPublic('amount_type_options', array('FLAT' => 'Flat $ Amount', 'PERCENT' => '% of Applied To' ));
if (isset($_REQUEST['id'])) {
$discount = $this->db->getRow('SELECT * FROM discounts WHERE id = "' . $_REQUEST['id'] . '" ORDER BY sequence DESC LIMIT 1;');
$this->setPublic('discount', $discount);
$sql = '
SELECT *
FROM discount_rules
WHERE discount_id = "' . $discount['id'] . '"
AND sequence = "' . $discount['sequence'] . '"
ORDER BY id;
';
$this->setPublic('rules', $this->db->getArray($sql));
$sql = '
SELECT *
FROM discount_xref
WHERE discount_id = "' . $discount['id'] . '"
AND sequence = "' . $discount['sequence'] . '"
ORDER BY id;
';
$xrefs = $this->db->getArray($sql);
$xrefs_grouped = array('CUSTOMER' => array(), 'CATEGORY' => array(), 'PRODUCT' => array());
if (is_array($xrefs)) {
foreach ($xrefs as $xref) {
// @todo There's currently no code to handle exclusions
if ($xref['eligible'] == 'Y') {
$xrefs_grouped[$xref['type']][] = $xref['xref_id'];
}
}
}
$this->setPublic('xrefs', $xrefs_grouped);
}
}
private function flattenArray($array) {
$formatted_array = array();
foreach ($array as $temp) {
$formatted_array[$temp['id']] = $temp['name'];
}
return $formatted_array;
}
}
?>

View file

@ -0,0 +1,94 @@
<?php
class store_admin_discounts_save extends store_admin {
protected $display = DISPLAY_JSON;
public function __default() {
$discount = array(
'name' => $_REQUEST['name'],
'coupon' => $_REQUEST['coupon'],
'description' => $_REQUEST['description'],
'all_customers' => 'Y',
'all_categories' => 'N',
'all_products' => 'N',
'combinable' => 'N',
'valid_from' => $_REQUEST['valid_from_Year'] . '-' . $_REQUEST['valid_from_Month'] . '-' . $_REQUEST['valid_from_Day'],
'valid_through' => $_REQUEST['valid_through_Year'] . '-' . $_REQUEST['valid_through_Month'] . '-' . $_REQUEST['valid_through_Day'],
'max_customer_usage' => $_REQUEST['max_customer_usage'],
'max_order_usage' => $_REQUEST['max_order_usage'],
'usage_count' => $_REQUEST['usage_count'] == '' ? '0' : $_REQUEST['usage_count'], // @TODO zero is quoted to get around a bug.
'remaining_usages' => $_REQUEST['remaining_usages'] == 'unlimited' ? null : $_REQUEST['remaining_usages_count']
);
// Updates the existing discount
if (isset($_REQUEST['id'])) {
// Checks for changes @todo
// Increments the sequence number
$sequence = $this->db->getField('SELECT MAX(sequence) + 1 FROM discounts WHERE id = "' . $_REQUEST['id'] . '";');
// Inserts row into the discount table
$discount['id'] = $_REQUEST['id'];
$discount['sequence'] = $sequence;
$this->db->insert('discounts', $discount);
$verb = 'updating';
$past = 'updated';
}
// Adds a brand new discount
else {
$discount['id'] = $this->db->insert('discounts', $discount);
$discount['sequence'] = '0';
$verb = 'adding';
$past = 'added';
}
// Inserts one or more rows into the discount_rules table
$discount_rules = array(
'discount_id' => $discount['id'],
'sequence' => $discount['sequence'],
'applied_to' => $_REQUEST['applied_to'],
'amount' => $_REQUEST['amount'],
'amount_type' => $_REQUEST['amount_type'],
'min_subtotal' => $_REQUEST['min_subtotal'],
'min_items' => $_REQUEST['min_items'],
'max_discount' => $_REQUEST['max_discount']
);
$this->db->insert('discount_rules', $discount_rules);
/*
$this->setPublic('status', 'Error');
$this->setPublic('message', print_r($_REQUEST, true));
return false;
*/
// Inserts one or more rows into the discount_xref table
foreach ($_REQUEST['products'] as $product_id) {
$discount_xref = array(
'discount_id' => $discount['id'],
'sequence' => $discount['sequence'],
'type' => 'PRODUCT',
'xref_id' => $product_id,
'eligible' => 'Y',
'exclusion' => 'N'
);
$this->db->insert('discount_xref', $discount_xref);
}
if ($this->error->getErrors()) {
$this->setPublic('status', 'Error');
$this->setPublic('message', 'There was an error ' . $verb . ' the discount (' . implode('. ', $this->error->getErrors()) . '.)');
return false;
}
else {
$this->setPublic('status', 'Success');
$this->setPublic('message', 'The new discount has been ' . $past . ' successfully.');
}
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class store_admin_gift_certificates extends store_admin {
public function __default() {
}
}
?>

View file

@ -0,0 +1,59 @@
<?php
class store_admin_products_edit extends store_admin {
protected $display = array(DISPLAY_SMARTY, DISPLAY_JSON);
public function __default() {
if (isset($_REQUEST['id'])) {
$sql = '
SELECT
customers.*,
emails.email,
billing.company AS billing_company,
billing.first_name AS billing_first_name,
billing.last_name AS billing_last_name,
billing.address1 AS billing_address1,
billing.address2 AS billing_address2,
billing.city AS billing_city,
billing.state AS billing_state,
billing.zip_code AS billing_zip_code,
billing.country AS billing_country,
billing.phone AS billing_phone,
billing.fax AS billing_fax,
shipping.company AS shipping_company,
shipping.first_name AS shipping_first_name,
shipping.last_name AS shipping_last_name,
shipping.address1 AS shipping_address1,
shipping.address2 AS shipping_address2,
shipping.city AS shipping_city,
shipping.state AS shipping_state,
shipping.zip_code AS shipping_zip_code,
shipping.country AS shipping_country,
shipping.phone AS shipping_phone,
shipping.fax AS shipping_fax
FROM customers
INNER JOIN emails
ON emails.id = customers.email_id
INNER JOIN addresses AS billing
ON billing.id = customers.billing_address_id
INNER JOIN addresses AS shipping
ON shipping.id = customers.shipping_address_id
WHERE customers.id = "' . $_REQUEST['id'] . '";
';
$this->setPublic('customer', $this->db->getRow($sql));
}
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class store_admin_reports extends store_admin {
public function __default() {
}
}
?>

View file

@ -0,0 +1,10 @@
<?php
class store_admin_settings extends store_admin {
public function __default() {
}
}
?>

View file

@ -47,7 +47,21 @@ function getForm(form) {
break;
case 'select-one':
params += '&' + element.name + "=" + element.options[element.selectedIndex].value;
params += '&' + element.name + '=' + element.options[element.selectedIndex].value;
break;
case 'select-multiple':
var option_count = element.options.length;
for (var j = 0; j < option_count; j++) {
if (element.options[j].selected == true) {
params += '&' + element.name + '[]=' + element.options[j].value;
}
}
break;
default:
//alert(element.type);
break;
}
}

View file

@ -13,13 +13,13 @@
</tr>
{foreach from=$module.customers item=customer}
<tr class="center">
<td class="left"><a href="/store/admin/customers/view/{$customer.id}">{$customer.billing_last_name}, {$customer.billing_first_name}</a></td>
<td class="left">{$customer.billing_phone}</td>
<td class="left"><a href="/store/admin/customers/view/{$customer.id}">{$customer.shipping_last_name}, {$customer.shipping_first_name}</a></td>
<td class="left">{$customer.shipping_phone}</td>
<td class="left">{mailto address=$customer.email}</td>
<td>{$customer.order_count}</td>
<td>
<a href="/store/admin/customers/edit/{$customer.id}"><img src="/static/contrib/silk/icons/pencil.png" alt="Edit Customer" title="Edit Customer" /></a>
<a href="/store/admin/customers/delete/{$customer.id}" onclick="return confirm('Are you sure you want to delete {$customer.first_name} {$customer.last_name}?')"><img src="/static/contrib/silk/icons/delete.png" alt="Delete Customer" title="Delete Customer" /></a>
<a href="/store/admin/customers/delete/{$customer.id}" onclick="alert('Customer deletion has not yet been implemented.'); return false; return confirm('Are you sure you want to delete {$customer.billing_first_name} {$customer.billing_last_name}?')"><img src="/static/contrib/silk/icons/delete.png" alt="Delete Customer" title="Delete Customer" /></a>
</td>
</tr>
{/foreach}

View file

@ -0,0 +1,215 @@
<script type="text/javascript" src="/static/js/ajax.js" /></script>
{literal}
<script type="text/javascript">
// @todo Move this to an external file so that logic isn't in the template
function copyAddress(that) {
if (that.checked == true) {
// Copy the values
document.getElementById('shipping_company').value = document.getElementById('billing_company').value;
document.getElementById('shipping_first_name').value = document.getElementById('billing_first_name').value;
document.getElementById('shipping_last_name').value = document.getElementById('billing_last_name').value;
document.getElementById('shipping_address1').value = document.getElementById('billing_address1').value;
document.getElementById('shipping_address2').value = document.getElementById('billing_address2').value;
document.getElementById('shipping_city').value = document.getElementById('billing_city').value;
document.getElementById('shipping_state').value = document.getElementById('billing_state').value;
document.getElementById('shipping_zip_code').value = document.getElementById('billing_zip_code').value;
document.getElementById('shipping_phone').value = document.getElementById('billing_phone').value;
document.getElementById('shipping_fax').value = document.getElementById('billing_fax').value;
// Disable the fields
document.getElementById('shipping_company').disabled = true;
document.getElementById('shipping_first_name').disabled = true;
document.getElementById('shipping_last_name').disabled = true;
document.getElementById('shipping_address1').disabled = true;
document.getElementById('shipping_address2').disabled = true;
document.getElementById('shipping_city').disabled = true;
document.getElementById('shipping_state').disabled = true;
document.getElementById('shipping_zip_code').disabled = true;
document.getElementById('shipping_phone').disabled = true;
document.getElementById('shipping_fax').disabled = true;
}
else {
// Clear the values
document.getElementById('shipping_company').value = '';
document.getElementById('shipping_first_name').value = '';
document.getElementById('shipping_last_name').value = '';
document.getElementById('shipping_address1').value = '';
document.getElementById('shipping_address2').value = '';
document.getElementById('shipping_city').value = '';
document.getElementById('shipping_state').value = '';
document.getElementById('shipping_zip_code').value = '';
document.getElementById('shipping_phone').value = '';
document.getElementById('shipping_fax').value = '';
// Enable the fields
document.getElementById('shipping_company').disabled = false;
document.getElementById('shipping_first_name').disabled = false;
document.getElementById('shipping_last_name').disabled = false;
document.getElementById('shipping_address1').disabled = false;
document.getElementById('shipping_address2').disabled = false;
document.getElementById('shipping_city').disabled = false;
document.getElementById('shipping_state').disabled = false;
document.getElementById('shipping_zip_code').disabled = false;
document.getElementById('shipping_phone').disabled = false;
document.getElementById('shipping_fax').disabled = false;
}
}
function clearForm(responseObject, responseElement) {
if (responseObject != null) {
switch (responseObject.status) {
case 'Success':
document.getElementById('billing_company').value = '';
document.getElementById('billing_first_name').value = '';
document.getElementById('billing_last_name').value = '';
document.getElementById('billing_address1').value = '';
document.getElementById('billing_address2').value = '';
document.getElementById('billing_city').value = '';
document.getElementById('billing_state').value = '';
document.getElementById('billing_zip_code').value = '';
document.getElementById('billing_phone').value = '';
document.getElementById('billing_fax').value = '';
document.getElementById('shipping_company').value = '';
document.getElementById('shipping_first_name').value = '';
document.getElementById('shipping_last_name').value = '';
document.getElementById('shipping_address1').value = '';
document.getElementById('shipping_address2').value = '';
document.getElementById('shipping_city').value = '';
document.getElementById('shipping_state').value = '';
document.getElementById('shipping_zip_code').value = '';
document.getElementById('shipping_phone').value = '';
document.getElementById('shipping_fax').value = '';
document.getElementById('email').value = '';
document.getElementById('password').value = '';
document.getElementById('password_verify').value = '';
break;
default:
//alert(responseObject.message);
break;
}
}
var responseMessage = document.createTextNode(responseObject.message);
responseElement.className = responseObject.type;
responseElement.appendChild(responseMessage);
return responseElement;
}
</script>
<style>
form div {
margin-top: 10px;
}
dl {
margin-top: 5px;
width: 400px;
}
dl dt {
float: left;
padding-top: 4px;
text-align: right;
width: 100px;
}
dl dd {
float: left;
width: 240px;
}
dl dd input, dl dd select {
margin: 2px;
width: 250px;
}
</style>
{/literal}
<h3>{if isset($module.customer.id)}Update{else}Add{/if} Customer</h3>
<form method="post" action="/store/admin/customers/save">
<div class="right" style="margin-bottom: -10px;">
Same as billing information?
<input id="shipping_same_as_billing" type="checkbox" onclick="copyAddress(this);" name="shipping_same_as_contact" style="margin-top: -2px" />
</div>
<div class="float-left">
<b>Billing Information:</b>
<dl>
<dt>Company:</dt>
<dd><input type='text' name='billing_company' id='billing_company' maxlength="64" value="{$module.customer.billing_company}" /></dd>
<dt><span class="pink">*</span>First Name:</dt>
<dd><input type='text' name='billing_first_name' id='billing_first_name' title="required" maxlength="50" value="{$module.customer.billing_first_name}" /></dd>
<dt><span class="pink">*</span>Last Name:</dt>
<dd><input type='text' name='billing_last_name' id='billing_last_name' title="required" maxlength="50" value="{$module.customer.billing_last_name}" /></dd>
<dt><span class="pink">*</span>Address:</dt>
<dd>
<input type='text' name='billing_address1' id='billing_address1' title="required" maxlength="64" value="{$module.customer.billing_address1}" /><br />
<input type='text' name='billing_address2' id='billing_address2' maxlength="64" value="{$module.customer.billing_address2}" />
</dd>
<dt><span class="pink">*</span>City:</dt>
<dd><input type='text' name='billing_city' id='billing_city' title="required" maxlength="64" value="{$module.customer.billing_city}" /></dd>
<dt><span class="pink">*</span>State:</dt>
<dd>{html_select_state prefix="billing_" title="required"}</dd>
<dt><span class="pink">*</span>ZIP Code:</dt>
<dd><input type='text' name='billing_zip_code' id='billing_zip_code' style="width: 50px;" title="required" maxlength="5" value="{$module.customer.billing_zip_code}" /></dd>
<dt><span class="pink">*</span>Phone:</dt>
<dd><input type="text" name="billing_phone" id="billing_phone" style="width: 150px" maxlength="32" title="required" value="{$module.customer.billing_phone}" /></dd>
<dt>Fax:</dt>
<dd><input type="text" name="billing_fax" id="billing_fax" style="width: 150px" maxlength="32" value="{$module.customer.billing_fax}" /></dd>
</dl>
</div>
<div class="float-right">
<b>Shipping Information:</b>
<dl>
<dt>Company:</dt>
<dd><input type='text' name='shipping_company' id='shipping_company' maxlength="64" value="{$module.customer.shipping_company}" /></dd>
<dt><span class="pink">*</span>First Name:</dt>
<dd><input type='text' name='shipping_first_name' id='shipping_first_name' title="required" maxlength="50" value="{$module.customer.shipping_first_name}" /></dd>
<dt><span class="pink">*</span>Last Name:</dt>
<dd><input type='text' name='shipping_last_name' id='shipping_last_name' title="required" maxlength="50" value="{$module.customer.shipping_last_name}" /></dd>
<dt><span class="pink">*</span>Address:</dt>
<dd>
<input type='text' name='shipping_address1' id='shipping_address1' title="required" maxlength="64" value="{$module.customer.shipping_address1}" /><br />
<input type='text' name='shipping_address2' id='shipping_address2' maxlength="64" value="{$module.customer.shipping_address2}" />
</dd>
<dt><span class="pink">*</span>City:</dt>
<dd><input type='text' name='shipping_city' id='shipping_city' title="required" maxlength="64" value="{$module.customer.shipping_city}" /></dd>
<dt><span class="pink">*</span>State:</dt>
<dd>{html_select_state prefix="shipping_" title="required"}</dd>
<dt><span class="pink">*</span>ZIP Code:</dt>
<dd><input type='text' name='shipping_zip_code' id='shipping_zip_code' style="width: 50px;" title="required" maxlength="5" value="{$module.customer.shipping_zip_code}" /></dd>
<dt><span class="pink">*</span>Phone:</dt>
<dd><input type="text" name="shipping_phone" id="shipping_phone" style="width: 150px" maxlength="32" title="required" value="{$module.customer.shipping_phone}" /></dd>
<dt>Fax:</dt>
<dd><input type="text" name="shipping_fax" id="shipping_fax" style="width: 150px" maxlength="32" value="{$module.customer.shipping_fax}" /></dd>
</dl>
</div>
<br class="clear-left" /><br />
<div class="float-left">
<b>Email Address:</b><br />
This is what the customer uses as their login ID
<dl>
<dt><span class="pink">*</span>Email:</dt>
<dd><input type="text" name="email" id="email" maxlength="255" value="{$module.customer.email}" /></dd>
</dl>
</div>
<div class="float-right">
<b>Password Change?</b><br />
If you do not wish to update the customer's password, leave blank.
<dl>
<dt>Password:</dt>
<dd><input type="password" id="password" name="password" maxlength="12" value="" /></dd>
<dt>Verify:</dt>
<dd><input type="password" id="password_verify" name="password_verify" maxlength="12" value="" /></dd>
</dl>
</div>
<br class="clear-right" /><br />
<div class="center">
{if isset($module.customer.id)}<input type="hidden" name="id" value="{$module.customer.id}" />{/if}
<input type="reset" value="Reset Form" /><input type="button" value="Store Information" onclick="ajaxRequest(this.parentNode.parentNode{if !isset($module.customer.id)}, 'clearForm'{/if}); return false;" />
</div>
</form>
<script type="text/javascript">
document.getElementById('billing_state').value = "{$module.customer.billing_state}";
document.getElementById('shipping_state').value = "{$module.customer.shipping_state}";
</script>

View file

@ -25,7 +25,7 @@
<td>{if $discount.valid_through == null}<em>Never</em>{else}{$discount.valid_through}{/if}</td>
<td>
<a href="/store/admin/discounts/edit/{$discount.id}"><img src="/static/contrib/silk/icons/pencil.png" alt="Edit Discount" title="Edit Discount" /></a>
<a href="/store/admin/discounts/delete/{$discount.id}" onclick="return confirm('Are you sure you want to delete {$discount.first_name} {$discount.last_name}?')"><img src="/static/contrib/silk/icons/delete.png" alt="Delete Discount" title="Delete Discount" /></a>
<a href="/store/admin/discounts/delete/{$discount.id}" onclick="alert('This function is not yet implemented'); return false; return confirm('Are you sure you want to delete {$discount.first_name} {$discount.last_name}?')"><img src="/static/contrib/silk/icons/delete.png" alt="Delete Discount" title="Delete Discount" /></a>
</td>
</tr>
{/foreach}

View file

@ -7,6 +7,7 @@
if (responseObject != null) {
switch (responseObject.status) {
case 'Success':
/*
document.getElementById('contact_company').value = '';
document.getElementById('contact_first_name').value = '';
document.getElementById('contact_last_name').value = '';
@ -33,6 +34,7 @@
document.getElementById('tax_id').value = '';
document.getElementById('tax_class').value = '';
document.getElementById('commission_rate').value = '';
*/
break;
@ -75,6 +77,13 @@
width: 500px;
height: 50px;
}
table#applicable, table#rules {
margin-top: 0px
}
table#applicable td, table#rules td {
padding: 0px;
}
</style>
{/literal}
<h3>{if isset($module.discount.id)}Update{else}Add{/if} Discount</h3>
@ -83,115 +92,117 @@
<dl>
<dt><span class="pink">*</span>Name:</dt>
<dd>
<input type="text" name="name" id="name" style="margin-right: 53px" />
<input type="text" name="name" id="name" style="margin-right: 53px" value="{$module.discount.name}" title="required" />
Coupon Code:
<input type="text" name="name" id="name" style="width: 100px;" />
<input type="text" name="coupon" id="coupon" style="width: 100px;" value="{$module.discount.coupon}" />
</dd>
<dt>Description:</dt>
<dd><textarea name="description" id="description"></textarea></dd>
<dt>Valid From:</dt>
<dd><textarea name="description" id="description" style="height: 100px">{$module.discount.description}</textarea></dd>
<dt><span class="pink">*</span>Valid From:</dt>
<dd>
{html_select_date prefix='valid_from_'}
to
{html_select_date prefix='valid_to_'}
{html_select_date prefix='valid_through_'}
</dd>
<dt>
</dt>
</dl>
</div>
<br style="clear: left" />
<!--div>
<b>Contact Information:</b>
<dl>
<dt>Company:</dt>
<dd><input type='text' name='contact_company' id='contact_company' maxlength="64" value="{$module.discount.contact_company}" /></dd>
<dt><span class="pink">*</span>First Name:</dt>
<dd><input type='text' name='contact_first_name' id='contact_first_name' title="required" maxlength="50" value="{$module.discount.contact_first_name}" /></dd>
<dt><span class="pink">*</span>Last Name:</dt>
<dd><input type='text' name='contact_last_name' id='contact_last_name' title="required" maxlength="50" value="{$module.discount.contact_last_name}" /></dd>
<dt><span class="pink">*</span>Address:</dt>
<dt><span class="pink">*</span>Applicable:</dt>
<dd>
<input type='text' name='contact_address1' id='contact_address1' title="required" maxlength="64" value="{$module.discount.contact_address1}" /><br />
<input type='text' name='contact_address2' id='contact_address2' maxlength="64" value="{$module.discount.contact_address2}" />
<table cellspacing="0" cellpadding="0" id="applicable">
<tr>
<td><input type="checkbox" checked="checked" style="" disabled="disabled" /> All Customers</td>
<!--td><input type="checkbox" checked="checked" style="" disabled="disabled" /> All Categories</td-->
<td><input type="checkbox" checked="checked" style="" disabled="disabled" /> All Products</td>
</tr>
<tr>
<td>(CTRL + click to select multiple)</td>
<!--td>(CTRL + click to select multiple)</td-->
<td>(CTRL + click to select multiple)</td>
</tr>
<tr>
<td style="vertical-align: top; padding-right: 10px;">
<select multiple="multiple" id="customers" name="customers" style="height: 200px; width: 250px;" disabled="disabled">
{html_options options=$module.customers}
</select>
</td>
<!--td style="vertical-align: top; padding-right: 10px;">
<select multiple="multiple" id="categories" name="categories" style="height: 200px; width: 230px;" disabled="disabled">
{html_options options=$module.categories|truncate:32}
</select>
</td-->
<td style="vertical-align: top;">
<select multiple="multiple" id="products" name="products" style="height: 200px; width: 450px;">
{html_options options=$module.products}
</select>
</td>
</tr>
</table>
</dd>
<dt><span class="pink">*</span>City:</dt>
<dd><input type='text' name='contact_city' id='contact_city' title="required" maxlength="64" value="{$module.discount.contact_city}" /></dd>
<dt><span class="pink">*</span>State:</dt>
<dd>{html_select_state prefix="contact_" title="required"}</dd>
<dt><span class="pink">*</span>ZIP Code:</dt>
<dd><input type='text' name='contact_zip_code' id='contact_zip_code' style="width: 50px;" title="required" maxlength="5" value="{$module.discount.contact_zip_code}" /></dd>
<dt><span class="pink">*</span>Phone:</dt>
<dd><input type="text" name="contact_phone" id="contact_phone" style="width: 150px" maxlength="32" title="required" value="{$module.discount.contact_phone}" /></dd>
<dt>Fax:</dt>
<dd><input type="text" name="contact_fax" id="contact_fax" style="width: 150px" maxlength="32" value="{$module.discount.contact_fax}" /></dd>
</dl>
<br class="clear-left" /><br />
<dl>
<dt>Email:</dt>
<dd><input type="text" name="email" id="email" maxlength="255" value="{$module.discount.email}" /></dd>
</dl>
</div>
<div class="float-right">
<b>Payee Information:</b>
<dl>
<dt>Company:</dt>
<dd><input type='text' name='payee_company' id='payee_company' maxlength="64" value="{$module.discount.payee_company}" /></dd>
<dt><span class="pink">*</span>First Name:</dt>
<dd><input type='text' name='payee_first_name' id='payee_first_name' title="required" maxlength="50" value="{$module.discount.payee_first_name}" /></dd>
<dt><span class="pink">*</span>Last Name:</dt>
<dd><input type='text' name='payee_last_name' id='payee_last_name' title="required" maxlength="50" value="{$module.discount.payee_last_name}" /></dd>
<dt><span class="pink">*</span>Address:</dt>
<dt>Max Usage:</dt>
<dd>
<input type='text' name='payee_address1' id='payee_address1' title="required" maxlength="64" value="{$module.discount.payee_address1}" /><br />
<input type='text' name='payee_address2' id='payee_address2' maxlength="64" value="{$module.discount.payee_address2}" />
<input type="text" style="width: 40px" name="max_customer_usage" />
Per Customer
<input type="text" style="width: 40px" name="max_order_usage" />
Per Order
</dd>
<dt><span class="pink">*</span>City:</dt>
<dd><input type='text' name='payee_city' id='payee_city' title="required" maxlength="64" value="{$module.discount.payee_city}" /></dd>
<dt><span class="pink">*</span>State:</dt>
<dd>{html_select_state prefix="payee_" title="required"}</dd>
<dt><span class="pink">*</span>ZIP Code:</dt>
<dd><input type='text' name='payee_zip_code' id='payee_zip_code' style="width: 50px;" title="required" maxlength="5" value="{$module.discount.payee_zip_code}" /></dd>
<dt><span class="pink">*</span>Phone:</dt>
<dd><input type="text" name="payee_phone" id="payee_phone" style="width: 150px" maxlength="32" title="required" value="{$module.discount.payee_phone}" /></dd>
<dt>Fax:</dt>
<dd><input type="text" name="payee_fax" id="payee_fax" style="width: 150px" maxlength="32" value="{$module.discount.payee_fax}" /></dd>
</dl>
</div>
<br class="clear-left" /><br />
<div class="float-left">
<b>Tax Information:</b>
<dl>
<dt><span class="pink">*</span>Tax ID:</dt>
<dd><input type="input" id="tax_id" name="tax_id" title="required" maxlength="12" value="{$module.discount.tax_id}" /></dd>
<dt><span class="pink">*</span>Tax Class:</dt>
<dt><span class="pink">*</span>Remaining:</dt>
<dd>
<select name="tax_class" id="tax_class" title="required">
<option value="">-- Select a Class --</option>
<option value="I"{if $module.discount.tax_class == 'I'} selected{/if}>Individual</option>
<option value="C"{if $module.discount.tax_class == 'C'} selected{/if}>Corporation</option>
<option value="P"{if $module.discount.tax_class == 'P'} selected{/if}>Partnership</option>
</select>
<input type="radio" checked="checked" name="remaining_usages" value="unlimited" /> Unlimited <input type="radio" name="remaining_usages" value="other" /> Other <input type="text" style="width: 60px;" name="remaining_usages_count" /> Uses <span style="color: #666; margin-left: 20px;">Already Used {$module.discount.usage_count} times</span>
<input type="hidden" name="usage_count" value="{$module.discount.usage_count}" />
</dd>
<dt><span class="pink">*</span>Rules:</dt>
<dd>
<table id="rules" style="width: 700px">
<tr>
<th>Applied To</td>
<th>Amount</th>
<th>Min Subtotal</th>
<th>Min Items</th>
<th>Max Discount</th>
<th>
<img src="/static/contrib/silk/icons/add.png" onclick="alert('The ability to add more than one rule to the discount is currently unavailable');" />
</th>
</tr>
<tr>
<td class="center">
<select name="applied_to" id="applied_to">
{html_options options=$module.applied_to_options selected=$module.rules.0.applied_to}
</select>
</td>
<td class="center">
<select name="amount_type" id="amount_type">
{html_options options=$module.amount_type_options selected=$module.rules.0.amount_type}
</select>
<input type="text" name="amount" id="amount" style="width: 60px" value="{$module.rules.0.amount}" />
</td>
<td class="center">$<input type="text" name="min_subtotal" id="minimum_subtotal" style="width: 60px" value="{$module.rules.0.min_subtotal}" /></td>
<td class="center"><input type="text" name="min_items" id="minimum_items" style="width: 60px" value="{$module.rules.0.min_items}" /></td>
<td class="center">$<input type="text" name="max_discount" id="maximum_discount" style="width: 60px" value="{$module.rules.0.max_discount}" /></td>
</tr>
</table>
</dd>
</dl>
</div>
<div class="float-right">
<b>Commission:</b>
<dl>
<dt><span class="pink">*</span>Rate:</dt>
<dd><input type="input" id="commission_rate" name="commission_rate" title="required" style="width: 50px" value="{$module.discount.commission_rate}" />%</dd>
</dl>
</div>
<br class="clear-left" />
<br style="clear: left" /><br />
<div class="center">
{if isset($module.discount.id)}<input type="hidden" name="id" value="{$module.discount.id}" />{/if}
{if isset($module.discount.id)}
<input type="hidden" name="id" value="{$module.discount.id}" />
<input type="hidden" name="sequence" value="{$module.discount.sequence}" />
{/if}
<input type="reset" value="Reset Form" /><input type="button" value="Store Information" onclick="ajaxRequest(this.parentNode.parentNode{if !isset($module.discount.id)}, 'clearForm'{/if}); return false;" />
</div-->
</div>
</form>
{literal}
<script type="text/javascript">
document.getElementById('contact_state').value = "{$module.discount.contact_state}";
document.getElementById('payee_state').value = "{$module.discount.payee_state}";
var select_box = document.getElementById('products');
var option_count = select_box.options.length;
for (var i = 0; i < option_count; i++) {
{/literal}
{foreach from=$module.xrefs.PRODUCT item=product_id}
if (select_box.options[i].value == {$product_id}) {literal}{{/literal}
select_box.options[i].selected = 'selected';
{literal}}{/literal}
{/foreach}
{literal}
}
</script>
{/literal}

View file

@ -0,0 +1,2 @@
<h3>Gift Certificates</h3>
<em>Gift certificates are currently unavailable.</em>

View file

@ -0,0 +1,115 @@
<script type="text/javascript" src="/static/js/ajax.js" /></script>
{literal}
<script type="text/javascript">
// @todo Move this to an external file so that logic isn't in the template
function clearForm(responseObject, responseElement) {
if (responseObject != null) {
switch (responseObject.status) {
case 'Success':
document.getElementById('billing_company').value = '';
document.getElementById('billing_first_name').value = '';
document.getElementById('billing_last_name').value = '';
document.getElementById('billing_address1').value = '';
document.getElementById('billing_address2').value = '';
document.getElementById('billing_city').value = '';
document.getElementById('billing_state').value = '';
document.getElementById('billing_zip_code').value = '';
document.getElementById('billing_phone').value = '';
document.getElementById('billing_fax').value = '';
document.getElementById('shipping_company').value = '';
document.getElementById('shipping_first_name').value = '';
document.getElementById('shipping_last_name').value = '';
document.getElementById('shipping_address1').value = '';
document.getElementById('shipping_address2').value = '';
document.getElementById('shipping_city').value = '';
document.getElementById('shipping_state').value = '';
document.getElementById('shipping_zip_code').value = '';
document.getElementById('shipping_phone').value = '';
document.getElementById('shipping_fax').value = '';
document.getElementById('email').value = '';
document.getElementById('password').value = '';
document.getElementById('password_verify').value = '';
break;
default:
//alert(responseObject.message);
break;
}
}
var responseMessage = document.createTextNode(responseObject.message);
responseElement.className = responseObject.type;
responseElement.appendChild(responseMessage);
return responseElement;
}
</script>
<style>
form div {
margin-top: 10px;
}
dl {
margin-top: 5px;
width: 400px;
}
dl dt {
float: left;
padding-top: 4px;
text-align: right;
width: 135px;
}
dl dd {
float: left;
width: 240px;
}
dl dd input, dl dd select {
margin: 2px;
width: 250px;
}
</style>
{/literal}
<h3>{if isset($module.product.id)}Update{else}Add{/if} Product</h3>
<form method="post" action="/store/admin/products/save">
<div class="float-left">
<dl>
<dt>SKU:</dt>
<dd><input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>Name:</dt>
<dd><input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>Teaser:</dt>
<dd><input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>Description:</dt>
<dd><input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>MSRP:</dt>
<dd>$<input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>Price:</dt>
<dd>$<input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>Size:</dt>
<dd><input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
<dt>In Stock?</dt>
<dd><input type='checkbox' name='XXX' id='XXX' maxlength="64" /></dd>
<dt style="clear: left">Limit Per Customer:</dt>
<dd><input type='text' name='XXX' id='XXX' maxlength="64" value="{$module.product.XXX}" /></dd>
</dl>
</div>
<div class="float-left">
<dl>
<dt>SKU:</dt>
<dd><input type='text' name='billing_company' id='billing_company' maxlength="64" value="{$module.product.billing_company}" /></dd>
</dl>
</div>
<br class="clear-left" /><br />
<div class="center">
{if isset($module.product.id)}<input type="hidden" name="id" value="{$module.product.id}" />{/if}
<input type="reset" value="Reset Form" /><input type="button" value="Store Information" onclick="ajaxRequest(this.parentNode.parentNode{if !isset($module.product.id)}, 'clearForm'{/if}); return false;" />
</div>
</form>
<script type="text/javascript">
document.getElementById('billing_state').value = "{$module.product.billing_state}";
document.getElementById('shipping_state').value = "{$module.product.shipping_state}";
</script>

View file

@ -0,0 +1,2 @@
<h3>Reports</h3>
<em>Reports are currently unavailable.</em>

View file

@ -0,0 +1,2 @@
<h3>Settings</h3>
<em>Settings are currently unavailable.</em>

6
scripts/generate_docs Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
phpdoc -o HTML:frames:l0l33t -d ../ -t ../docs -dn Miscellaneous -po PICKLES -ct usage -s
#-dc PICKLES
#-ti "PHP Interface Collection of Killer Libraries to Enhance Stuff"