add missing file in colissimo
This commit is contained in:
168
local/modules/Colissimo/Controller/Export.php
Normal file
168
local/modules/Colissimo/Controller/Export.php
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* 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/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Colissimo\Controller;
|
||||||
|
|
||||||
|
use Colissimo\Model\ColissimoQuery;
|
||||||
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Thelia\Controller\Admin\BaseAdminController;
|
||||||
|
use Thelia\Core\Event\Order\OrderEvent;
|
||||||
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
|
use Thelia\Core\HttpFoundation\Response;
|
||||||
|
use Thelia\Core\Security\AccessManager;
|
||||||
|
use Thelia\Core\Security\Resource\AdminResources;
|
||||||
|
use Colissimo\Form\Export as FormExport;
|
||||||
|
use Thelia\Core\Translation\Translator;
|
||||||
|
use Thelia\Form\Exception\FormValidationException;
|
||||||
|
use Thelia\Model\ConfigQuery;
|
||||||
|
use Thelia\Model\CountryQuery;
|
||||||
|
use Thelia\Model\CustomerTitleQuery;
|
||||||
|
use Thelia\Model\OrderQuery;
|
||||||
|
use Thelia\Model\OrderStatus;
|
||||||
|
use Thelia\Model\OrderStatusQuery;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Export
|
||||||
|
* @package Colissimo\Controller
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class Export extends BaseAdminController
|
||||||
|
{
|
||||||
|
const DEFAULT_PHONE = "0100000000";
|
||||||
|
const DEFAULT_CELLPHONE = "0600000000";
|
||||||
|
|
||||||
|
public function exportAction()
|
||||||
|
{
|
||||||
|
if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), array('Colissimo'), AccessManager::UPDATE)) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new FormExport($this->getRequest());
|
||||||
|
|
||||||
|
try {
|
||||||
|
$exportForm = $this->validateForm($form);
|
||||||
|
|
||||||
|
$status_id = $exportForm->get('status_id')->getData();
|
||||||
|
|
||||||
|
$status = OrderStatusQuery::create()
|
||||||
|
->filterByCode($status_id)
|
||||||
|
->findOne();
|
||||||
|
|
||||||
|
$orders = ColissimoQuery::getOrders()
|
||||||
|
->find();
|
||||||
|
|
||||||
|
$export = "";
|
||||||
|
$store_name = ConfigQuery::read("store_name");
|
||||||
|
/** @var $order \Thelia\Model\Order */
|
||||||
|
foreach ($orders as $order) {
|
||||||
|
|
||||||
|
$value = $exportForm->get('order_'.$order->getId())->getData();
|
||||||
|
|
||||||
|
if ($value) {
|
||||||
|
|
||||||
|
$customer = $order->getCustomer();
|
||||||
|
$locale = $order->getLang()->getLocale();
|
||||||
|
$address = $order->getOrderAddressRelatedByDeliveryOrderAddressId();
|
||||||
|
$country = CountryQuery::create()->findPk($address->getCountryId());
|
||||||
|
$country->setLocale($locale);
|
||||||
|
$customerTitle = CustomerTitleQuery::create()->findPk($address->getCustomerTitleId());
|
||||||
|
$customerTitle->setLocale($locale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user's phone & cellphone
|
||||||
|
* First get invoice address phone,
|
||||||
|
* If empty, try to get default address' phone.
|
||||||
|
* If still empty, set default value
|
||||||
|
*/
|
||||||
|
$phone = $address->getPhone();
|
||||||
|
if (empty($phone)) {
|
||||||
|
$phone = $customer->getDefaultAddress()->getPhone();
|
||||||
|
|
||||||
|
if (empty($phone)) {
|
||||||
|
$phone = self::DEFAULT_PHONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cellp
|
||||||
|
*/
|
||||||
|
$cellphone = $customer->getDefaultAddress()->getCellphone();
|
||||||
|
|
||||||
|
if (empty($cellphone)) {
|
||||||
|
$cellphone = $customer->getDefaultAddress()->getCellphone();
|
||||||
|
|
||||||
|
if (empty($cellphone)) {
|
||||||
|
$cellphone = self::DEFAULT_CELLPHONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute package weight
|
||||||
|
*/
|
||||||
|
$weight = 0;
|
||||||
|
/** @var \Thelia\Model\OrderProduct $product */
|
||||||
|
foreach ($order->getOrderProducts() as $product) {
|
||||||
|
$weight+=(double) $product->getWeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
$export .= "\"".$order->getRef()."\";\"".$address->getLastname()."\";\"".$address->getFirstname()."\";\"".$address->getAddress1()."\";\"".$address->getAddress2()."\";\"".$address->getAddress3()."\";\"".$address->getZipcode()."\";\"".$address->getCity()."\";\"".$country->getTitle()."\";\"".$phone."\";\"".$cellphone."\";\"".$weight."\";\"\";\"\";\"".$store_name."\";\"DOM\";\r\n";
|
||||||
|
|
||||||
|
if ($status) {
|
||||||
|
$event = new OrderEvent($order);
|
||||||
|
$event->setStatus($status->getId());
|
||||||
|
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::create(
|
||||||
|
$export,
|
||||||
|
200,
|
||||||
|
array(
|
||||||
|
"Content-Type"=>"application/csv-tab-delimited-table",
|
||||||
|
"Content-disposition"=>"filename=export.csv"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (FormValidationException $e) {
|
||||||
|
$this->setupFormErrorContext(
|
||||||
|
Translator::getInstance()->trans("colissimo expeditor export"),
|
||||||
|
$e->getMessage(),
|
||||||
|
$form,
|
||||||
|
$e
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
"module-configure",
|
||||||
|
array(
|
||||||
|
"module_code" => "Colissimo",
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
91
local/modules/Colissimo/Loop/NotSendLoop.php
Normal file
91
local/modules/Colissimo/Loop/NotSendLoop.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* 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/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Colissimo\Loop;
|
||||||
|
|
||||||
|
use Colissimo\Colissimo;
|
||||||
|
use Colissimo\Model\ColissimoQuery;
|
||||||
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Thelia\Core\Template\Element\BaseLoop;
|
||||||
|
use Thelia\Core\Template\Element\LoopResult;
|
||||||
|
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||||
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||||
|
use Thelia\Core\Template\Loop\Order;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class NotSendLoop
|
||||||
|
* @package Colissimo\Loop
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class NotSendLoop extends Order
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* define all args used in your loop
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* example :
|
||||||
|
*
|
||||||
|
* public function getArgDefinitions()
|
||||||
|
* {
|
||||||
|
* return new ArgumentCollection(
|
||||||
|
* Argument::createIntListTypeArgument('id'),
|
||||||
|
* new Argument(
|
||||||
|
* 'ref',
|
||||||
|
* new TypeCollection(
|
||||||
|
* new Type\AlphaNumStringListType()
|
||||||
|
* )
|
||||||
|
* ),
|
||||||
|
* Argument::createIntListTypeArgument('category'),
|
||||||
|
* Argument::createBooleanTypeArgument('new'),
|
||||||
|
* Argument::createBooleanTypeArgument('promo'),
|
||||||
|
* Argument::createFloatTypeArgument('min_price'),
|
||||||
|
* Argument::createFloatTypeArgument('max_price'),
|
||||||
|
* Argument::createIntTypeArgument('min_stock'),
|
||||||
|
* Argument::createFloatTypeArgument('min_weight'),
|
||||||
|
* Argument::createFloatTypeArgument('max_weight'),
|
||||||
|
* Argument::createBooleanTypeArgument('current'),
|
||||||
|
*
|
||||||
|
* );
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||||
|
*/
|
||||||
|
public function getArgDefinitions()
|
||||||
|
{
|
||||||
|
return new ArgumentCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method returns a Propel ModelCriteria
|
||||||
|
*
|
||||||
|
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||||
|
*/
|
||||||
|
public function buildModelCriteria()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return ColissimoQuery::getOrders();
|
||||||
|
}
|
||||||
|
}
|
||||||
70
local/modules/Colissimo/Model/ColissimoQuery.php
Normal file
70
local/modules/Colissimo/Model/ColissimoQuery.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* 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/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Colissimo\Model;
|
||||||
|
|
||||||
|
use Colissimo\Colissimo;
|
||||||
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Thelia\Model\OrderQuery;
|
||||||
|
use Thelia\Model\OrderStatus;
|
||||||
|
use Thelia\Model\OrderStatusQuery;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ColissimoQuery
|
||||||
|
* @package Colissimo\Model
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class ColissimoQuery
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return OrderQuery
|
||||||
|
*/
|
||||||
|
public static function getOrders()
|
||||||
|
{
|
||||||
|
$status = OrderStatusQuery::create()
|
||||||
|
->filterByCode(
|
||||||
|
array(
|
||||||
|
OrderStatus::CODE_PAID,
|
||||||
|
OrderStatus::CODE_PROCESSING,
|
||||||
|
),
|
||||||
|
Criteria::IN
|
||||||
|
)
|
||||||
|
->find()
|
||||||
|
->toArray("code")
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$query = OrderQuery::create()
|
||||||
|
->filterByDeliveryModuleId((new Colissimo())->getModuleModel()->getId())
|
||||||
|
->filterByStatusId(
|
||||||
|
array(
|
||||||
|
$status[OrderStatus::CODE_PAID]['Id'],
|
||||||
|
$status[OrderStatus::CODE_PROCESSING]['Id']),
|
||||||
|
Criteria::IN
|
||||||
|
);
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
local/modules/Colissimo/THELIA_INET.FMT
Normal file
23
local/modules/Colissimo/THELIA_INET.FMT
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[GENERAL]
|
||||||
|
DELIMITE=O
|
||||||
|
SEPARATEUR=59
|
||||||
|
DELIMITEUR=34
|
||||||
|
FINDELIGNE=CRLF
|
||||||
|
Unité poids=KG
|
||||||
|
[CHAMPS]
|
||||||
|
ReferenceExpedition=1
|
||||||
|
NomDestinataire=2
|
||||||
|
Prenom=3
|
||||||
|
Adresse1=4
|
||||||
|
Adresse2=5
|
||||||
|
Adresse3=6
|
||||||
|
CodePostal=7
|
||||||
|
Commune=8
|
||||||
|
CodePays=9
|
||||||
|
Telephone=10
|
||||||
|
Portable=11
|
||||||
|
Poids=12
|
||||||
|
Mail=13
|
||||||
|
CodePointRetrait=14
|
||||||
|
CodeProduit=15
|
||||||
|
NomCommercialChargeur=16
|
||||||
Reference in New Issue
Block a user