Skip to content

Commit

Permalink
Merge pull request #8 from zawaze/master
Browse files Browse the repository at this point in the history
Update and fix
  • Loading branch information
gillesbourgeat authored Sep 3, 2018
2 parents 9e2d073 + 2ef10fd commit f3d1e65
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<argument type="service" id="thelia.taxEngine"/>
<tag name="kernel.event_subscriber"/>
</service>

<service id="module.data.service" class="OrderCreation\Service\ModuleDataService">
</service>
</services>

<hooks>
Expand Down
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<descriptive locale="fr_FR">
<title>Creation de commande dans le BackOffice</title>
</descriptive>
<version>1.5</version>
<version>1.6</version>
<author>
<name>gbarral</name>
<email>[email protected]</email>
Expand Down
24 changes: 23 additions & 1 deletion Controller/Admin/OrderCreationAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OrderCreation\Form\OrderCreationCreateForm;
use OrderCreation\OrderCreation;
use OrderCreation\OrderCreationConfiguration;
use OrderCreation\Service\ModuleDataService;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Propel\Runtime\Propel;
Expand Down Expand Up @@ -48,8 +49,17 @@ public function addItemAction($position)

public function getConfigurationAjaxAction()
{
$tabResult =[];

$moduleId = OrderCreationConfiguration::getDeliveryModuleId();
return JsonResponse::create(["moduleId" => $moduleId]);
$tabResult['moduleId'] = $moduleId;

if(OrderCreationConfiguration::getSoColissimoMode()){
$mode = OrderCreationConfiguration::getDeliveryModuleId();
$tabResult['modeTT'] = $mode;
}

return JsonResponse::create($tabResult);
}

public function configureAction()
Expand All @@ -64,6 +74,18 @@ public function configureAction()
$form = $this->validateForm($configurationForm, "POST");
$data = $form->getData();
OrderCreationConfiguration::setDeliveryModuleId($data['order_creation_delivery_module_id']);

/** @var ModuleDataService $moduleService */
$moduleService = $this->container->get('module.data.service');

$codeModule = $moduleService->getModuleCode($data['order_creation_delivery_module_id']);

if(OrderCreation::SOCOLISSIMO == $codeModule){
OrderCreationConfiguration::setSoColissimoMode('DOM');
} else {
OrderCreationConfiguration::setSoColissimoMode('');
}

$this->adminLogAppend(
OrderCreation::MESSAGE_DOMAIN . ".configuration.message",
AccessManager::UPDATE,
Expand Down
2 changes: 1 addition & 1 deletion Form/ConfigurationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function buildForm()
->add(
'order_creation_delivery_module_id',
TextType::class, [
'label' => Translator::getInstance()->trans("Delivery module use to create order in back office", OrderCreation::MESSAGE_DOMAIN),
'label' => Translator::getInstance()->trans("Delivery module use to create order in back office", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => array(
'help' => $this->translator->trans('Leave blank to select delivery module on each order', [], OrderCreation::MESSAGE_DOMAIN)
),
Expand Down
2 changes: 2 additions & 0 deletions OrderCreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
class OrderCreation extends BaseModule
{
const MESSAGE_DOMAIN = "ordercreation";

const SOCOLISSIMO = "SoColissimo";
}
12 changes: 12 additions & 0 deletions OrderCreationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class OrderCreationConfiguration
{
const CONFIG_KEY_DELIVERY_MODULE_ID = 'order_creation_delivery_module_id';
const SOCOLISSIMO_MODE = 'order_creation_socolissimo_mode';

/**
* @param $moduleId integer | null
Expand All @@ -21,6 +22,16 @@ public static function setDeliveryModuleId($moduleId)
OrderCreation::setConfigValue(self::CONFIG_KEY_DELIVERY_MODULE_ID, $moduleId);
}

public static function setSoColissimoMode($mode)
{
OrderCreation::setConfigValue(self::SOCOLISSIMO_MODE, $mode);
}

public static function getSoColissimoMode()
{
return OrderCreation::getConfigValue(self::SOCOLISSIMO_MODE, null);
}

/**
* @return integer | null
*/
Expand All @@ -29,4 +40,5 @@ public static function getDeliveryModuleId()
return OrderCreation::getConfigValue(self::CONFIG_KEY_DELIVERY_MODULE_ID, null);
}


}
4 changes: 4 additions & 0 deletions templates/backOffice/default/customer-edit-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
if (!json.moduleId) {
return;
}

if(json.modeTT){
$('#mode-socolissimo').append('<input type="hidden "name="socolissimo-home" value="DOM" >');
}
$('#create-order-form-td-delivery-module').hide();
$('#create-order-form-td-payment_module_id').colspan = 2;
}
Expand Down
4 changes: 3 additions & 1 deletion templates/backOffice/default/forms/create-order-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<td>
{form_field form=$form field='delivery_address_id'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} * : </label>
<label for="{$label_attr.for}" class="control-label">{$label} * :</label>

<select name="{$name}" id="{$label_attr.for}" class="form-control" required="required">
<option value="0" {if $value == $ID}selected="selected"{/if} >{intl l="Choose" d="ordercreation"}</option>
Expand Down Expand Up @@ -131,6 +131,8 @@
</tfoot>
</table>

<div id="mode-socolissimo"></div>

{/capture}
{include
file = "includes/generic-create-dialog.html"
Expand Down

0 comments on commit f3d1e65

Please sign in to comment.