Intégration du module OrderStatusNotify

This commit is contained in:
2020-03-02 12:19:02 +01:00
parent b8430cf78e
commit 04a53140c2
22 changed files with 2793 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<hooks>
<hook id="orderstatusnotify.hook.back" class="OrderStatusNotify\Hook\BackHook" scope="request">
<tag name="hook.event_listener" event="main.top-menu-tools" type="back" />
</hook>
</hooks>
<services>
<service id="orderstatusnotify.mailing.service" class="OrderStatusNotify\EventListeners\OrderStatusListener">
<argument type="service" id="mailer" />
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
<fullnamespace>OrderStatusNotify\OrderStatusNotify</fullnamespace>
<descriptive locale="en_US">
<title>Send email on order status' change</title>
</descriptive>
<descriptive locale="fr_FR">
<title>Envoi d'email lors du changement de statut d'une commande</title>
</descriptive>
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0</version>
<authors>
<author>
<name>Laurent LE CORRE</name>
<email>laurent@thecoredev.fr</email>
</author>
</authors>
<type>classic</type>
<thelia>2.3.0</thelia>
<stability>beta</stability>
</module>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="orderstatusnotify.back" path="/admin/module/orderstatusnotify">
<default key="_controller">OrderStatusNotify\Controller\Back\OrderStatusController::showStatus</default>
</route>
<route id="orderstatusnotify.toggle-online" path="/admin/module/orderstatusnotify/toggle-online">
<default key="_controller">OrderStatusNotify\Controller\Back\OrderStatusController::setToggleVisibilityAction</default>
</route>
</routes>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="OrderStatusNotify\Model">
<table name="order_status_notification">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="order_status_id" required="true" type="INTEGER" />
<column name="to_notify" required="true" type="BOOLEAN" default="false" />
<foreign-key foreignTable="order_status" name="fk_order_status_notify_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="order_status_id" />
</foreign-key>
</table>
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
</database>

View File

@@ -0,0 +1,2 @@
# Sqlfile -> Database map
thelia.sql=thelia

View File

@@ -0,0 +1,40 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- order_status_notification
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `order_status_notification`;
CREATE TABLE `order_status_notification`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`order_status_id` INTEGER NOT NULL,
`to_notify` TINYINT(1) DEFAULT 0 NOT NULL,
PRIMARY KEY (`id`),
INDEX `FI_order_status_notify_id` (`order_status_id`),
CONSTRAINT `fk_order_status_notify_id`
FOREIGN KEY (`order_status_id`)
REFERENCES `order_status` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
-- ---------------------------------------------------------------------
-- Affectation du modèle d'email
-- ---------------------------------------------------------------------
INSERT INTO `message` (name,secured,text_layout_file_name,text_template_file_name,html_layout_file_name,html_template_file_name,created_at,updated_at,version,version_created_at,version_created_by) VALUES
('order_status_changed',NULL,NULL,NULL,NULL,'order_status_changed.html','2020-02-12 19:18:35.0','2020-03-01 09:56:48.0',3,'2020-03-01 09:56:48.0',NULL);
INSERT INTO `message_i18n` (id,locale,title,subject,text_message,html_message)
(SELECT max(id), 'fr_FR','Informer le client du changement de statut de sa commande','Votre commande {$order_ref} chez {config key="store_name"}',NULL,'Bonjour,
Votre commande référence {$order_ref} vient de passer à l''état {$new_status}.'
from `message`);

View File

@@ -0,0 +1,49 @@
<?php
namespace OrderStatusNotify\Controller\Back;
use Thelia\Controller\Admin\BaseAdminController;
use OrderStatusNotify\Model\OrderStatusNotificationQuery;
use OrderStatusNotify\Model\OrderStatusNotification;
/**
* Class OrderStatusController
* @package OrderStatusNotify\Controller\Back
* @author Laurent LE CORRE <laurent@thecoredev.fr>
*/
class OrderStatusController extends BaseAdminController
{
public function showStatus()
{
$vars = '';
if (null !== $result = OrderStatusNotificationQuery::create()->findByToNotify(true)) {
foreach ($result->getData() as $order_status) {
// Il faut serialiser le tableau afin de pouvoir l'exploiter dans la page HTML.
$vars .= $order_status->getOrderStatusId() . ',';
}
}
return $this->render('display-order-status', ['status' => $vars]);
}
public function setToggleVisibilityAction()
{
try {
$order_status_to_modify = $_GET['order_status_id'];
$current_order_status = OrderStatusNotificationQuery::create()->findOneByOrderStatusId($order_status_to_modify);
if (null === $current_order_status) {
$new_order_status = new OrderStatusNotification();
$new_order_status->setOrderStatusId($order_status_to_modify);
$new_order_status->setToNotify(true);
$new_order_status->save();
}
else {
$current_order_status->delete();
}
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
return $this->nullResponse();
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace OrderStatusNotify\EventListeners;
use OrderStatusNotify\Model\OrderStatusNotificationQuery;
use OrderStatusNotify\OrderStatusNotify;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Mailer\MailerFactory;
use Thelia\Model\OrderStatusI18nQuery;
use Thelia\Log\Tlog;
/**
* Class OrderStatusListener
* @package OrderStatusNotify\EventListeners
*/
class OrderStatusListener implements EventSubscriberInterface
{
/**
* @var MailerFactory
*/
protected $mailer;
public function __construct(MailerFactory $mailer)
{
$this->mailer = $mailer;
}
public static function getSubscribedEvents()
{
return [TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 200)];
}
public function updateStatus(OrderEvent $event)
{
$order = $event->getOrder();
$new_status_id = $event->getStatus();
$is_order_status_to_notify = OrderStatusNotificationQuery::create()->findOneByOrderStatusId($new_status_id);
if (null !== $is_order_status_to_notify) {
$new_statut_label = OrderStatusI18nQuery::create()
->filterByLocale($order->getLang()->getLocale())
->findOneById($new_status_id)
->getTitle();
$this->mailer->sendEmailToCustomer(
OrderStatusNotify::MESSAGE_NAME,
$order->getCustomer(),
[
'order_id' => $order->getId(),
'order_ref' => $order->getRef(),
'new_status' => $new_statut_label,
]
);
Tlog::getInstance()->debug("Order status change sent to customer " . $order->getCustomer()->getEmail());
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace OrderStatusNotify\Hook;
use OrderStatusNotify\OrderStatusNotify;
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
use Thelia\Core\Hook\BaseHook;
use Thelia\Tools\URL;
/**
* Class BackHook
* @package OrderStatusNotify\Hook
* @author Laurent LE CORRE
*/
class BackHook extends BaseHook
{
public function onMainTopMenuTools(HookRenderBlockEvent $event)
{
$event->add(
[
'id' => 'tools_menu_orderstatusnotify',
'class' => '',
'url' => URL::getInstance()->absoluteUrl('/admin/module/orderstatusnotify'),
'title' => $this->trans('Order status notification', [], OrderStatusNotify::DOMAIN_NAME)
]
);
}
}

View File

@@ -0,0 +1,12 @@
<?php
return array(
'Order status notification' => 'Order\'s status change notification',
'Home' => 'Home',
'Tools' => 'Tools',
'To notify' => 'Notify to customer',
'Status' => 'Order status',
'Status list' => 'Order status list',
'Purpose of feature' => 'Please select order status you want to notify the customer : an email will be sent when the order will get to this status.',
'Change on your order %ref on %store_name' => 'Change on your order %ref on %store_name',
'Hello, your order has just changed to' => 'Hello, your order has just changed to status : ',
);

View File

@@ -0,0 +1,12 @@
<?php
return [
'Order status notification' => 'Notifier des changements de statut',
'Home' => 'Accueil',
'Tools' => 'Outils',
'To notify' => 'A notifier au client',
'Status' => 'Statut de la commande',
'Status list' => 'Liste des statuts de commande',
'Purpose of feature' => 'Veuillez sélectionner les statuts de commande pour lesquels vous souhaitez notifier le client : dès que la commande passera dans ce statut, un email sera envoyé au client.',
'Change on your order %ref on %store_name' => 'Evolution sur votre commande %ref sur le site %store_name',
'Hello, your order has just changed to' => 'Bonjour, votre commande vient de passer à l\'état : ',
];

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,505 @@
<?php
namespace OrderStatusNotify\Model\Base;
use \Exception;
use \PDO;
use OrderStatusNotify\Model\OrderStatusNotification as ChildOrderStatusNotification;
use OrderStatusNotify\Model\OrderStatusNotificationQuery as ChildOrderStatusNotificationQuery;
use OrderStatusNotify\Model\Map\OrderStatusNotificationTableMap;
use OrderStatusNotify\Model\Thelia\Model\OrderStatus;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'order_status_notification' table.
*
*
*
* @method ChildOrderStatusNotificationQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildOrderStatusNotificationQuery orderByOrderStatusId($order = Criteria::ASC) Order by the order_status_id column
* @method ChildOrderStatusNotificationQuery orderByToNotify($order = Criteria::ASC) Order by the to_notify column
*
* @method ChildOrderStatusNotificationQuery groupById() Group by the id column
* @method ChildOrderStatusNotificationQuery groupByOrderStatusId() Group by the order_status_id column
* @method ChildOrderStatusNotificationQuery groupByToNotify() Group by the to_notify column
*
* @method ChildOrderStatusNotificationQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildOrderStatusNotificationQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildOrderStatusNotificationQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildOrderStatusNotificationQuery leftJoinOrderStatus($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderStatus relation
* @method ChildOrderStatusNotificationQuery rightJoinOrderStatus($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderStatus relation
* @method ChildOrderStatusNotificationQuery innerJoinOrderStatus($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderStatus relation
*
* @method ChildOrderStatusNotification findOne(ConnectionInterface $con = null) Return the first ChildOrderStatusNotification matching the query
* @method ChildOrderStatusNotification findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderStatusNotification matching the query, or a new ChildOrderStatusNotification object populated from the query conditions when no match is found
*
* @method ChildOrderStatusNotification findOneById(int $id) Return the first ChildOrderStatusNotification filtered by the id column
* @method ChildOrderStatusNotification findOneByOrderStatusId(int $order_status_id) Return the first ChildOrderStatusNotification filtered by the order_status_id column
* @method ChildOrderStatusNotification findOneByToNotify(boolean $to_notify) Return the first ChildOrderStatusNotification filtered by the to_notify column
*
* @method array findById(int $id) Return ChildOrderStatusNotification objects filtered by the id column
* @method array findByOrderStatusId(int $order_status_id) Return ChildOrderStatusNotification objects filtered by the order_status_id column
* @method array findByToNotify(boolean $to_notify) Return ChildOrderStatusNotification objects filtered by the to_notify column
*
*/
abstract class OrderStatusNotificationQuery extends ModelCriteria
{
/**
* Initializes internal state of \OrderStatusNotify\Model\Base\OrderStatusNotificationQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\OrderStatusNotify\\Model\\OrderStatusNotification', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildOrderStatusNotificationQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildOrderStatusNotificationQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \OrderStatusNotify\Model\OrderStatusNotificationQuery) {
return $criteria;
}
$query = new \OrderStatusNotify\Model\OrderStatusNotificationQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildOrderStatusNotification|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = OrderStatusNotificationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(OrderStatusNotificationTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildOrderStatusNotification A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, ORDER_STATUS_ID, TO_NOTIFY FROM order_status_notification WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildOrderStatusNotification();
$obj->hydrate($row);
OrderStatusNotificationTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildOrderStatusNotification|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(OrderStatusNotificationTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(OrderStatusNotificationTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(OrderStatusNotificationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(OrderStatusNotificationTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderStatusNotificationTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the order_status_id column
*
* Example usage:
* <code>
* $query->filterByOrderStatusId(1234); // WHERE order_status_id = 1234
* $query->filterByOrderStatusId(array(12, 34)); // WHERE order_status_id IN (12, 34)
* $query->filterByOrderStatusId(array('min' => 12)); // WHERE order_status_id > 12
* </code>
*
* @see filterByOrderStatus()
*
* @param mixed $orderStatusId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function filterByOrderStatusId($orderStatusId = null, $comparison = null)
{
if (is_array($orderStatusId)) {
$useMinMax = false;
if (isset($orderStatusId['min'])) {
$this->addUsingAlias(OrderStatusNotificationTableMap::ORDER_STATUS_ID, $orderStatusId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($orderStatusId['max'])) {
$this->addUsingAlias(OrderStatusNotificationTableMap::ORDER_STATUS_ID, $orderStatusId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderStatusNotificationTableMap::ORDER_STATUS_ID, $orderStatusId, $comparison);
}
/**
* Filter the query on the to_notify column
*
* Example usage:
* <code>
* $query->filterByToNotify(true); // WHERE to_notify = true
* $query->filterByToNotify('yes'); // WHERE to_notify = true
* </code>
*
* @param boolean|string $toNotify The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function filterByToNotify($toNotify = null, $comparison = null)
{
if (is_string($toNotify)) {
$to_notify = in_array(strtolower($toNotify), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(OrderStatusNotificationTableMap::TO_NOTIFY, $toNotify, $comparison);
}
/**
* Filter the query by a related \OrderStatusNotify\Model\Thelia\Model\OrderStatus object
*
* @param \OrderStatusNotify\Model\Thelia\Model\OrderStatus|ObjectCollection $orderStatus The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function filterByOrderStatus($orderStatus, $comparison = null)
{
if ($orderStatus instanceof \OrderStatusNotify\Model\Thelia\Model\OrderStatus) {
return $this
->addUsingAlias(OrderStatusNotificationTableMap::ORDER_STATUS_ID, $orderStatus->getId(), $comparison);
} elseif ($orderStatus instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(OrderStatusNotificationTableMap::ORDER_STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrderStatus() only accepts arguments of type \OrderStatusNotify\Model\Thelia\Model\OrderStatus or Collection');
}
}
/**
* Adds a JOIN clause to the query using the OrderStatus relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function joinOrderStatus($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('OrderStatus');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'OrderStatus');
}
return $this;
}
/**
* Use the OrderStatus relation OrderStatus object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \OrderStatusNotify\Model\Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query
*/
public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinOrderStatus($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\OrderStatusNotify\Model\Thelia\Model\OrderStatusQuery');
}
/**
* Exclude object from result
*
* @param ChildOrderStatusNotification $orderStatusNotification Object to remove from the list of results
*
* @return ChildOrderStatusNotificationQuery The current query, for fluid interface
*/
public function prune($orderStatusNotification = null)
{
if ($orderStatusNotification) {
$this->addUsingAlias(OrderStatusNotificationTableMap::ID, $orderStatusNotification->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the order_status_notification table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderStatusNotificationTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
OrderStatusNotificationTableMap::clearInstancePool();
OrderStatusNotificationTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildOrderStatusNotification or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildOrderStatusNotification object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderStatusNotificationTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(OrderStatusNotificationTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
OrderStatusNotificationTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
OrderStatusNotificationTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} // OrderStatusNotificationQuery

View File

@@ -0,0 +1,419 @@
<?php
namespace OrderStatusNotify\Model\Map;
use OrderStatusNotify\Model\OrderStatusNotification;
use OrderStatusNotify\Model\OrderStatusNotificationQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'order_status_notification' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class OrderStatusNotificationTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'OrderStatusNotify.Model.Map.OrderStatusNotificationTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'order_status_notification';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\OrderStatusNotify\\Model\\OrderStatusNotification';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'OrderStatusNotify.Model.OrderStatusNotification';
/**
* The total number of columns
*/
const NUM_COLUMNS = 3;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 3;
/**
* the column name for the ID field
*/
const ID = 'order_status_notification.ID';
/**
* the column name for the ORDER_STATUS_ID field
*/
const ORDER_STATUS_ID = 'order_status_notification.ORDER_STATUS_ID';
/**
* the column name for the TO_NOTIFY field
*/
const TO_NOTIFY = 'order_status_notification.TO_NOTIFY';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'OrderStatusId', 'ToNotify', ),
self::TYPE_STUDLYPHPNAME => array('id', 'orderStatusId', 'toNotify', ),
self::TYPE_COLNAME => array(OrderStatusNotificationTableMap::ID, OrderStatusNotificationTableMap::ORDER_STATUS_ID, OrderStatusNotificationTableMap::TO_NOTIFY, ),
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_STATUS_ID', 'TO_NOTIFY', ),
self::TYPE_FIELDNAME => array('id', 'order_status_id', 'to_notify', ),
self::TYPE_NUM => array(0, 1, 2, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'OrderStatusId' => 1, 'ToNotify' => 2, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderStatusId' => 1, 'toNotify' => 2, ),
self::TYPE_COLNAME => array(OrderStatusNotificationTableMap::ID => 0, OrderStatusNotificationTableMap::ORDER_STATUS_ID => 1, OrderStatusNotificationTableMap::TO_NOTIFY => 2, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_STATUS_ID' => 1, 'TO_NOTIFY' => 2, ),
self::TYPE_FIELDNAME => array('id' => 0, 'order_status_id' => 1, 'to_notify' => 2, ),
self::TYPE_NUM => array(0, 1, 2, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('order_status_notification');
$this->setPhpName('OrderStatusNotification');
$this->setClassName('\\OrderStatusNotify\\Model\\OrderStatusNotification');
$this->setPackage('OrderStatusNotify.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('ORDER_STATUS_ID', 'OrderStatusId', 'INTEGER', 'order_status', 'ID', true, null, null);
$this->addColumn('TO_NOTIFY', 'ToNotify', 'BOOLEAN', true, 1, false);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('OrderStatus', '\\OrderStatusNotify\\Model\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('order_status_id' => 'id', ), 'CASCADE', 'RESTRICT');
} // buildRelations()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? OrderStatusNotificationTableMap::CLASS_DEFAULT : OrderStatusNotificationTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (OrderStatusNotification object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = OrderStatusNotificationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = OrderStatusNotificationTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + OrderStatusNotificationTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = OrderStatusNotificationTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
OrderStatusNotificationTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = OrderStatusNotificationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = OrderStatusNotificationTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
OrderStatusNotificationTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(OrderStatusNotificationTableMap::ID);
$criteria->addSelectColumn(OrderStatusNotificationTableMap::ORDER_STATUS_ID);
$criteria->addSelectColumn(OrderStatusNotificationTableMap::TO_NOTIFY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.ORDER_STATUS_ID');
$criteria->addSelectColumn($alias . '.TO_NOTIFY');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(OrderStatusNotificationTableMap::DATABASE_NAME)->getTable(OrderStatusNotificationTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderStatusNotificationTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(OrderStatusNotificationTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new OrderStatusNotificationTableMap());
}
}
/**
* Performs a DELETE on the database, given a OrderStatusNotification or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or OrderStatusNotification object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderStatusNotificationTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \OrderStatusNotify\Model\OrderStatusNotification) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(OrderStatusNotificationTableMap::DATABASE_NAME);
$criteria->add(OrderStatusNotificationTableMap::ID, (array) $values, Criteria::IN);
}
$query = OrderStatusNotificationQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { OrderStatusNotificationTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { OrderStatusNotificationTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the order_status_notification table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return OrderStatusNotificationQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a OrderStatusNotification or Criteria object.
*
* @param mixed $criteria Criteria or OrderStatusNotification object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderStatusNotificationTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from OrderStatusNotification object
}
if ($criteria->containsKey(OrderStatusNotificationTableMap::ID) && $criteria->keyContainsValue(OrderStatusNotificationTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderStatusNotificationTableMap::ID.')');
}
// Set the correct dbName
$query = OrderStatusNotificationQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // OrderStatusNotificationTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
OrderStatusNotificationTableMap::buildTableMap();

View File

@@ -0,0 +1,10 @@
<?php
namespace OrderStatusNotify\Model;
use OrderStatusNotify\Model\Base\OrderStatusNotification as BaseOrderStatusNotification;
class OrderStatusNotification extends BaseOrderStatusNotification
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace OrderStatusNotify\Model;
use OrderStatusNotify\Model\Base\OrderStatusNotificationQuery as BaseOrderStatusNotificationQuery;
/**
* Skeleton subclass for performing query and update operations on the 'order_status_notification' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class OrderStatusNotificationQuery extends BaseOrderStatusNotificationQuery
{
} // OrderStatusNotificationQuery

View File

@@ -0,0 +1,25 @@
<?php
namespace OrderStatusNotify;
use OrderStatusNotify\Model\OrderStatusNotificationQuery;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Install\Database;
use Thelia\Module\BaseModule;
class OrderStatusNotify extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'orderstatusnotify';
const MESSAGE_NAME = 'order_status_changed';
public function postActivation(ConnectionInterface $con = null)
{
try {
OrderStatusNotificationQuery::create()->findOne();
} catch (\Exception $e) {
$database = new Database($con->getWrappedConnection());
$database->insertSql(null, array(THELIA_ROOT . '/local/modules/OrderStatusNotify/Config/thelia.sql'));
}
}
}

View File

@@ -0,0 +1,31 @@
# Order Status Notify
Envoi d'email lors du changement de statut d'une commande.
## Installation
### Manually
* Copier le module dans le dossier ```<thelia_root>/local/modules/``` et vérifiez que le nom du module est bien OrderStatusNotify.
* Déplacer le template ```order_status_changed.html``` (présent à la racine du dossier du module) vers le répertoire ```templates\email\default```
* Activer le module depuis l'écran d'administration Modules.
### Composer
Ajoutez ceci dans votre fichier composer.json principal.
```
composer require thelia/order-status-notify-module:~1.0
```
## Usage
En back-office, l'administrateur sélectionne, parmi les statuts de commande définis sur votre site, lesquels doivent faire l'objet d'une notification au client.
Dès qu'une commande passe à un état présent dans cette liste, alors un email est immédiatement envoyé au client.
Le template de cet email s'intitule "order_status_changed".
## Hook
Pour la partie back-office, un nouvel écran apparaitra dans le menu "Outils" des écrans d'administration.
Il vous sera ainsi possible de choisir les statuts de commande à surveiller.

View File

@@ -0,0 +1,11 @@
{
"name": "thelia/order-status-notify-module",
"license": "LGPL-3.0+",
"type": "thelia-module",
"require": {
"thelia/installer": "~1.1"
},
"extra": {
"installer-name": "OrderStatusNotify"
}
}

View File

@@ -0,0 +1,55 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl d='orderstatusnotify' l='Order status notification'}{/block}
{block name="main-content"}
<div class="row">
<div class="col-md-12">
<div class="alert alert-info">
{intl d='orderstatusnotify' l='Purpose of feature'}
</div>
</div>
</div>
<div class="order-status">
<div id="wrapper" class="container">
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl d='orderstatusnotify' l="Home"}</a></li>
<li><a href="{url path='/admin/tools'}">{intl d='orderstatusnotify' l="Tools"}</a></li>
<li><a href="{url path='/admin/module/orderstatusnotify'}">{intl d='orderstatusnotify' l="Order status notification"}</a></li>
</ul>
<div class="general-block-decorator">
<div class="row">
<div class="col-md-9">
{include file="include/order-status-list.html"}
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
/* Gestion des switch */
$(".visibleToggle").on('switch-change', function(event, data) {
$.ajax({
url: "{url path='admin/module/orderstatusnotify/toggle-online'}",
data: {
order_status_id: $(this).data('id')
}
});
});
});
</script>
{/block}

View File

@@ -0,0 +1,44 @@
<!-- On dé-serialise le tableau des statuts à notifier. //-->
{assign var="array" value=","|explode:$status}
{$error_message = ''}
{if $error_message}
<div class="row">
<div class="col-md-12">
<div class="alert alert-warning">
{$error_message}
</div>
</div>
</div>
{/if}
<form name="" action="">
<table class="table table-striped table-condensed table-left-aligned">
<caption>
{intl d='orderstatusnotify' l="Status list"}
</caption>
<thead>
<tr>
<th>{intl d='orderstatusnotify' l="ID"}</th>
<th>{intl d='orderstatusnotify' l="Status"}</th>
<th>{intl d='orderstatusnotify' l="To notify"}</th>
</tr>
</thead>
<tbody>
{loop type="order-status" name="order-status-loop" visible="yes" order="alpha"}
<tr>
<td>{$ID}</td>
<td>{$TITLE}</td>
<td>
<div class="make-switch switch-small visibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="visibleToggle" {if in_array($ID, $array)}checked="checked"{/if}>
</div>
</td>
</tr>
{/loop}
</tbody>
<tfoot>
</tfoot>
</table>
</form>