Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Manuel Raynaud
2013-09-11 11:06:02 +02:00
12 changed files with 252 additions and 99 deletions

2
.gitignore vendored
View File

@@ -22,6 +22,6 @@ web/cache/*
web/.htaccess
phpdoc*.log
php-cs
xhprof
xhprof/
phpunit.phar
.DS_Store

View File

@@ -37,6 +37,11 @@
<default key="_controller">Thelia\Controller\Admin\CustomerController::indexAction</default>
</route>
<route id="admin.customer.update.view" path="/admin/customer/update/{customer_id}">
<default key="_controller">Thelia\Controller\Admin\CustomerController::viewAction</default>
<requirement key="customer_id">\d+</requirement>
</route>
<!-- end Customer rule management -->
<!-- Categories management -->

View File

@@ -35,4 +35,12 @@ class CustomerController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.customers.view")) return $response;
return $this->render("customers", array("display_customer" => 20));
}
}
public function viewAction($customer_id)
{
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
}

View File

@@ -34,6 +34,7 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\ProductSaleElementsQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\ProductSaleElementsTableMap;
use Thelia\Type\TypeCollection;
use Thelia\Type;
@@ -41,7 +42,7 @@ use Thelia\Type;
*
* Product Sale Elements loop
*
* @todo : manage currency and attribute_availability
* @todo : manage attribute_availability ?
*
* Class ProductSaleElements
* @package Thelia\Core\Template\Loop
@@ -68,9 +69,9 @@ class ProductSaleElements extends BaseLoop
new Argument(
'order',
new TypeCollection(
new Type\EnumListType(array('alpha', 'alpha_reverse', 'attribute', 'attribute_reverse'))
new Type\EnumListType(array('min_price', 'max_price', 'promo', 'new', 'random'))
),
'attribute'
'random'
)
);
}
@@ -94,16 +95,16 @@ class ProductSaleElements extends BaseLoop
foreach ($orders as $order) {
switch ($order) {
case "min_price":
$search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC);
$search->addAscendingOrderByColumn('price_FINAL_PRICE', Criteria::ASC);
break;
case "max_price":
$search->addDescendingOrderByColumn('real_lowest_price');
$search->addDescendingOrderByColumn('price_FINAL_PRICE');
break;
case "promo":
$search->addDescendingOrderByColumn('main_product_is_promo');
$search->orderByPromo(Criteria::DESC);
break;
case "new":
$search->addDescendingOrderByColumn('main_product_is_new');
$search->orderByNewness(Criteria::DESC);
break;
case "random":
$search->clearOrderByColumns();
@@ -125,12 +126,22 @@ class ProductSaleElements extends BaseLoop
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
$defaultCurrencySuffix = '_default_currency';
$search->joinProductPrice('price', Criteria::INNER_JOIN);
//->addJoinCondition('price', '');
$search->joinProductPrice('price', Criteria::LEFT_JOIN)
->addJoinCondition('price', '`price`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
$search->withColumn('`price`.CURRENCY_ID', 'price_CURRENCY_ID')
->withColumn('`price`.PRICE', 'price_PRICE')
->withColumn('`price`.PROMO_PRICE', 'price_PROMO_PRICE');
$search->joinProductPrice('price' . $defaultCurrencySuffix, Criteria::LEFT_JOIN)
->addJoinCondition('price_default_currency', '`price' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
/**
* rate value is checked as a float in overloaded getRate method.
*/
$priceSelectorAsSQL = 'ROUND(CASE WHEN ISNULL(`price`.PRICE) THEN `price_default_currency`.PRICE * ' . $currency->getRate() . ' ELSE `price`.PRICE END, 2)';
$promoPriceSelectorAsSQL = 'ROUND(CASE WHEN ISNULL(`price`.PRICE) THEN `price_default_currency`.PROMO_PRICE * ' . $currency->getRate() . ' ELSE `price`.PROMO_PRICE END, 2)';
$search->withColumn($priceSelectorAsSQL, 'price_PRICE')
->withColumn($promoPriceSelectorAsSQL, 'price_PROMO_PRICE')
->withColumn('CASE WHEN ' . ProductSaleElementsTableMap::PROMO . ' = 1 THEN ' . $promoPriceSelectorAsSQL . ' ELSE ' . $priceSelectorAsSQL . ' END', 'price_FINAL_PRICE');
$search->groupById();
$PSEValues = $this->search($search, $pagination);
@@ -153,8 +164,6 @@ class ProductSaleElements extends BaseLoop
->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0)
->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0)
->set("WEIGHT", $PSEValue->getWeight())
->set("CURRENCY", $PSEValue->getVirtualColumn('price_CURRENCY_ID'))
->set("PRICE", $price)
->set("PRICE_TAX", $taxedPrice - $price)
->set("TAXED_PRICE", $taxedPrice)

View File

@@ -83,7 +83,7 @@ class Thelia extends Kernel
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
if ($this->isDebug()) {
//$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
$con->useDebug(true);
}
}

View File

@@ -1,7 +1,7 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
@@ -17,7 +17,7 @@
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Form;
@@ -217,4 +217,4 @@ class CustomerCreation extends BaseForm
{
return "thelia_customer_creation";
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -7,7 +7,8 @@
// -------------------------
body {
background: url("@{imgDir}/bg.jpg") repeat;
background: #FFF url("@{imgDir}/bg.jpg") top left no-repeat;
background-size: cover;
}

View File

@@ -10,99 +10,99 @@
<div class="catalog">
<div id="wrapper" class="container">
<div id="wrapper" class="container">
{module_include location='customer_top'}
{module_include location='customer_top'}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<table class="table table-striped table-condensed" id="customer_list">
<caption>
{intl l="Customers list"}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<table class="table table-striped table-condensed" id="customer_list">
<caption>
{intl l="Customers list"}
{module_include location='customer_list_caption'}
{module_include location='customer_list_caption'}
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.customers.create"}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new Customer'}" href="#add_customer_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.customers.create"}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new Customer'}" href="#add_customer_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
{ifloop rel="customer_list"}
<thead>
<tr>
<th class="object-title">
{intl l="customer ref"}
</th>
{ifloop rel="customer_list"}
<thead>
<tr>
<th class="object-title">
{intl l="customer ref"}
</th>
<th class="object-title">
{intl l="company"}
</th>
<th class="object-title">
{intl l="company"}
</th>
{module_include location='category_list_header'}
{module_include location='category_list_header'}
<th>
{intl l="firstname & lastname"}
</th>
<th>
{intl l="firstname & lastname"}
</th>
<th>
{intl l="last order"}
</th>
<th>
{intl l="last order"}
</th>
<th>{intl l='order amount'}</th>
<th>{intl l='order amount'}</th>
<th>{intl l='Actions'}</th>
</tr>
</thead>
<th>{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
{loop name="customer_list" type="customer" current="false" visible="*" last_order="1" backend_context="1" page={$customer_page} limit={$display_customer}}
<tr>
<td>{$REF}</td>
<tbody>
{loop name="customer_list" type="customer" current="false" visible="*" last_order="1" backend_context="1" page={$customer_page} limit={$display_customer}}
<tr>
<td>{$REF}</td>
<td>
{$COMPANY}
</td>
<td>
{$COMPANY}
</td>
<td class="object-title">
{$FIRSTNAME} {$LASTNAME}
</td>
<td class="object-title">
{$FIRSTNAME} {$LASTNAME}
</td>
{module_include location='customer_list_row'}
{module_include location='customer_list_row'}
<td>
{format_date date=$LASTORDER_DATE}
</td>
<td>
{format_date date=$LASTORDER_DATE}
</td>
<td>
{format_number number=$LASTORDER_AMOUNT}
</td>
<td>
<div class="btn-group">
<td>
{format_number number=$LASTORDER_AMOUNT}
</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.customer.edit"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this customer'}" href="{url path="/admin/customer/update/{$ID}" }"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
{loop type="auth" name="can_send_mail" roles="ADMIN" permissions="admin.customer.sendMail"}
<a class="btn btn-default btn-xs" title="{intl l="Send a mail to this customer"}" href="mailto:{$EMAIL}"><span class="glyphicon glyphicon-envelope"></span></a>
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.customer.delete"}
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_customer_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop}
</div>
</td>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.customer.edit"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this customer'}" href="{url path="/admin/customer/update/{$ID}" }"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
{loop type="auth" name="can_send_mail" roles="ADMIN" permissions="admin.customer.sendMail"}
<a class="btn btn-default btn-xs" title="{intl l="Send a mail to this customer"}" href="mailto:{$EMAIL}"><span class="glyphicon glyphicon-envelope"></span></a>
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.customer.delete"}
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_customer_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
{/ifloop}
</table>
</tr>
{/loop}
</tbody>
{/ifloop}
</table>
</div>
</div>
</div>
</div>
</div>
{module_include location='customer_bottom'}
@@ -131,10 +131,136 @@
{/if}
{/pageloop}
</ul>
</div>
</div>
</div>
</div>
{* Adding a new Category *}
{form name="thelia.customer.creation"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "customer_creation_dialog"}
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/customer/update/_ID_'}" />
{/form_field}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="title" name="title1"}
<option value="{$ID}">{$LONG}</option>
{/loop}
</select>
</div>
{/form_field}
{form_field form=$form field='firstname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Firstname'}">
</div>
{/form_field}
{form_field form=$form field='lastname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Lastname'}">
</div>
{/form_field}
{form_field form=$form field='address1'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Address'}">
</div>
<div class="form-group">
{form_field form=$form field='address2'}
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
<div class="form-group">
{form_field form=$form field='address3'}
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
{/form_field}
{form_field form=$form field='zipcode'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Zip code'}">
</div>
{/form_field}
{form_field form=$form field='city'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='City'}">
</div>
{/form_field}
{form_field form=$form field='country'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="country" name="country1"}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
</div>
{/form_field}
{form_field form=$form field='email'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Email address'}">
</div>
{/form_field}
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "add_customer_dialog"
dialog_title = {intl l="Create a new customer"}
dialog_body = {$smarty.capture.customer_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this customer"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path='/admin/customer/create'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
{/form}
{* Delete confirmation dialog *}
{capture "delete_customer_dialog"}
<input type="hidden" name="customer_id" id="customer_delete_id" value="" />
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "delete_customer_dialog"
dialog_title = {intl l="Delete customer"}
dialog_message = {intl l="Do you really want to delete this customer ?"}
form_action = {url path='/admin/customer/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
}
{/block}

View File

@@ -1,3 +1,5 @@
{*include file="includes/header.html"*}
Here you are : {navigate to="current"}<br />
From : {navigate to="return_to"}<br />
Index : {navigate to="index"}<br />
@@ -60,7 +62,7 @@ Index : {navigate to="index"}<br />
<h4>Product sale elements</h4>
{assign var=current_product value=$ID}
{loop name="pse" type="product_sale_elements" product="$ID"}
{loop name="pse" type="product_sale_elements" product="$ID" order="promo,min_price"}
<div style="border: solid 2px darkorange; padding: 5px; margin: 5px;">
{loop name="combi" type="attribute_combination" product_sale_elements="$ID"}
{$ATTRIBUTE_TITLE} = {$ATTRIBUTE_AVAILABILITY_TITLE}<br />
@@ -87,4 +89,6 @@ Index : {navigate to="index"}<br />
{elseloop rel="product"}
<h2>Produit introuvable !</h2>
{/elseloop}
{/elseloop}
{*include file="includes/footer.html"*}

View File

@@ -34,7 +34,8 @@ require __DIR__ . '/../core/bootstrap.php';
// List of allowed IP
$trustedIp = array(
'::1',
'127.0.0.1'
'127.0.0.1',
'192.168.56.1'
);
$request = Request::createFromGlobals();