Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -0,0 +1,70 @@
{form name="admin.order.creation.create.form"}
{if !isset($pseId)}
{assign var="pseId" value="0"}
{assign var="productId" value="0"}
{assign var="categoryId" value="0"}
{assign var="quantity" value="1"}
{else}
{loop type="product_sale_elements" name="prod" id=$pseId}
{assign var="productId" value=$PRODUCT_ID}
{loop name="cat-product" type="category" product=$PRODUCT_ID visible='*' limit=1}
{assign var="categoryId" value="$ID"}
{/loop}
{/loop}
{/if}
<tr id="tr-{$position}" class="title-without-tabs">
<td colspan="2">
<table class="table table-striped table-condensed">
<tbody>
<tr>
<td colspan="2">
<div class="input-group">
<select id="category{$position}"
required="required"
class="form-control category-list"
data-pse-id="{$pseId}"
data-target="item{$position}"
data-destination="tr-item{$position}">
<option>{intl l="Select product category" d="ordercreation.bo.default"}</option>
{loop name="cat-parent" type="category-tree" category="0" visible="*" product=$productId}
<option value="{$ID}"{if $categoryId == $ID} selected="selected"{/if}>{option_offset l=$LEVEL+1 label=$TITLE}</option>
{/loop}
</select>
<span class="input-group-btn">
<a class="btn btn-danger item-ajax-delete" data-toggle="modal" title="{intl l='Remove this product from order' d="ordercreation.bo.default"}" data-target="tr-{$position}" href="#">
<i class="glyphicon glyphicon-remove"></i>
</a>
</span>
</div>
</td>
</tr>
<tr id="tr-item{$position}" class="hide">
<td>
{form_field field='product_sale_element_id' value_key=$position}
<select required id="item{$position}" class="form-control" name="{$name}"></select>
{/form_field}
</td>
<td class="text-nowrap">
{form_field field='quantity' value_key=$position}
<div class="form-inline">
<div class="form-group">
<label for="quantity{$position}">{$label}</label>
<input id="quantity{$position}" required type="text" class="form-control" name="{$name}" value="{$quantity}">
</div>
</div>
{/form_field}
</td>
</tr>
<tr id="err_tr-item{$position}" class="hide">
<td colspan="2">
<div class="alert alert-warning" style="margin-bottom:0">{intl l="There's no product in this category" d="ordercreation.bo.default"}</div>
</td>
</tr>
</tbody>
</table>
</td>
<td></td>
</tr>
{/form}

View File

@@ -0,0 +1,216 @@
<script>
$(function() {
$.ajax({
url: '{url path="/admin/module/OrderCreation/config/ajax"}',
type: 'get',
dataType: 'json',
success: function (json) {
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();
}
});
function updateRedirectableStatus() {
moduleID = $('select', '#create-order-form-td-payment_module_id').val();
url = '{url path="/admin/module/OrderCreation/redirectable-payment/"}';
$.ajax({
url: url + moduleID,
type: 'get',
dataType: 'json',
success: function (json) {
if (json.test === 1) {
$('#create-order-form-td-check-payment-redirect').show();
} else {
$('#create-order-form-td-check-payment-redirect').hide();
}
}
});
}
//Automatic product add during order creation
$('#add-cart-item').click(function (ev) {
$('#empty-order-row').hide();
var nb_products = $(".category-list").length;
$.get("{url path='/admin/module/OrderCreation/add-item'}/" + nb_products, function (data) {
$('#body-order-cart').append(data);
}, 'html');
});
$('#create-order-form-td-payment_module_id').on('change', function (clickEvent) {
updateRedirectableStatus();
});
function makeOption(value, target_pse_id, title)
{
return '<option value="' + value.id + '"'
+ (target_pse_id === value.id ? "selected " : "")
+ '>'
+ (title !== undefined ? title : value.ref) + ' ({intl l='stock:' d="ordercreation.bo.default" js=1} ' + value.quantity + ')'
+ '</option>';
}
$('#body-order-cart').on('change', '.category-list', function (clickEvent) {
var target_id = $(this).data('target');
var target_destination_id = $(this).data('destination');
var target_pse_id = $(this).data('pse-id');
$.ajax({
url: '{url path="/admin/module/OrderCreation/0/list-products/"}' + $(this).val() + '.xml',
type: 'get',
dataType: 'json',
success: function (json) {
var listOfOptions = '';
$.each(json, function (product_ref, product) {
if (product.pse_list.length === 1) {
listOfOptions += makeOption(product.pse_list[0], target_pse_id, product.title);
} else {
listOfOptions += '<optgroup label="'+ product.title + ' (' + product_ref +')">';
$.each(product.pse_list, function (pidx, pse) {
listOfOptions += makeOption(pse, target_pse_id);
});
listOfOptions += '</optgroup>';
}
});
var $targetId = $('#' + target_id);
$targetId.empty();
if (listOfOptions !== '') {
listOfOptions =
'<option value="">{intl l="Please select a product" d="ordercreation.bo.default"}</option>'
+ listOfOptions
;
$targetId.append(listOfOptions);
$('#' + target_destination_id).removeClass('hide');
$('#err_' + target_destination_id).addClass('hide');
} else {
$('#' + target_destination_id).addClass('hide');
$('#err_' + target_destination_id).removeClass('hide');
}
}
});
});
$('#body-order-cart').on('click', '.item-ajax-delete', function (clickEvent) {
$('#' + $(this).data('target')).remove();
if ($(".category-list").length === 0) {
$('#empty-order-row').show();
}
});
$('#type_order_form').change(function (ev) {
if ($(this).val() === 2) {
$('#type_order_info').removeClass('hide');
} else {
$('#type_order_info').addClass('hide');
}
});
var prefixUrl = document.location.href.split('/admin');
var $listDelivery = $('#list-delivery');
$('#delivery_address_id_form').change(function() {
if ($(this).val() !== '') {
$listDelivery.addClass('loading');
// update the country in the request
$.ajax({
type: "POST",
url: prefixUrl[0] + "/admin/module/OrderCreation/update/country/request",
data: {
address_id: $(this).val()
}
})
.done(function (response) {
$.ajax({
type: "GET",
url: prefixUrl[0] + "/order/deliveryModuleList?back=1"
})
.done(function (response) {
$listDelivery.removeClass('loading');
$listDelivery.html(response);
$('#list-delivery input.delivery-method').each(function () {
if ($(this).is(':checked')) {
$('#delivery-module').val($(this).val());
}
});
//clear both between all radio button
$('#list-delivery .radio').each(function () {
$(this).css('clear', 'both');
});
})
.error(function (error) {
$listDelivery.removeClass('loading');
if (typeof (error.statusTexddt) != 'undefined') {
$listDelivery.html('<div class="alert alert-danger">' + error.statusText + '</div>');
}
});
})
.error(function (error) {
$listDelivery.removeClass('loading');
if (typeof (error.statusTexddt) != 'undefined') {
$listDelivery.html('<div class="alert alert-danger">' + error.statusText + '</div>');
}
});
} else {
$('#delivery-module').val(0);
$listDelivery.removeClass('loading');
$listDelivery.html(
'<div class="alert alert-danger">' +
"{intl l='Choose a delivery address first' d='ordercreation.bo.default' js=1}" +
'</div>'
);
}
});
$listDelivery.on('change', '.delivery-method', function () {
$('#delivery-module').val($(this).val());
});
$('form', '#order_create_dialog').submit(function (ev) {
if ($(".category-list").length === 0) {
ev.preventDefault();
alert("{intl l='Please add at lead one product to this order.' d='ordercreation.bo.default' js=1}");
}
if ($(".js-change-delivery-method:checked").length === 0) {
ev.preventDefault();
alert("{intl l='You should select a shipping method to create an order.' d='ordercreation.bo.default' js=1}");
}
});
// Update shipping mode list
$("#delivery_address_id_form").trigger("change");
// Update all products in cart
$('.category-list').trigger("change");
// Update rediect to payment checkbox
updateRedirectableStatus();
});
</script>

View File

@@ -0,0 +1,31 @@
{loop type="auth" name="can_create" role="ADMIN" resource="admin.ordercreation" access="CREATE"}
<div class="row" id="order-creation-block">
<div class="col-md-12 general-block-decorator">
<div class="alert alert-info">
{intl l="You can create here an order for this customer right from your back-office." d="ordercreation.bo.default"}
</div>
<div class="row">
{if $order_creation_error}
<div class="col-md-12">
<div class="alert alert-danger">{$order_creation_error}</div>
</div>
{/if}
{if $order_creation_success}
<div class="col-md-12">
<div class="alert alert-success">{$order_creation_success}</div>
</div>
{/if}
<div class="col-md-12">
<a class="btn btn-default btn-primary action-btn" title="{intl l='Generate a new order' d='ordercreation.bo.default'}" href="#order_create_dialog" data-toggle="modal">
<span>{intl l="Generate a new order for this customer" d="ordercreation.bo.default"}</span>
</a>
</div>
</div>
</div>
</div>
{/loop}
{* -- Create a new order -------------------- *}
{include file="forms/create-order-form.html"}

View File

@@ -0,0 +1,152 @@
{form name="admin.order.creation.create.form"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "order_create_dialog"}
{form_hidden_fields form=$form}
{form_field form=$form field='customer_id'}
<input type="hidden" name="{$name}" value="{$customer_id}">
{/form_field}
{form_field form=$form field='error_url'}
<input type="hidden" name="{$name}" value="{url path="/admin/customer/update" customer_id=$customer_id}"/>
{/form_field}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path="/admin/customer/update" customer_id=$customer_id}#order-creation-block"/>
{/form_field}
<div class="row">
<div class="col-md-6">
{custom_render_form_field field='delivery_address_id'}
<select {form_field_attributes field='delivery_address_id'}>
<option value="" {if $value == $ID}selected="selected"{/if} >{intl l="Choose" d="ordercreation.bo.default"}</option>
{loop type="address" name="address-delivery" customer=$customer_id}
<option value="{$ID}" {if $value == $ID}selected="selected"{/if}>{$LABEL}</option>
{/loop}
</select>
{/custom_render_form_field}
</div>
<div class="col-md-6">
{custom_render_form_field field='invoice_address_id'}
<select {form_field_attributes field='invoice_address_id'}>
<option value="" {if $value == $ID}selected="selected"{/if} >{intl l="Choose" d="ordercreation.bo.default"}</option>
{loop type="address" name="address-invoice" customer=$customer_id}
<option value="{$ID}" {if $value == $ID}selected="selected"{/if}>{$LABEL}</option>
{/loop}
</select>
{/custom_render_form_field}
</div>
</div>
<div class="row">
<div class="col-md-6">
{render_form_field field='discount_type'}
</div>
<div class="col-md-6">
{custom_render_form_field field='discount_price'}
<div class="input-group">
<input {form_field_attributes field='discount_price'}>
{loop type="currency" name="sale.currencies" backend_context=1 default_only=1}
<span class="input-group-addon">{$SYMBOL} {intl l="or" d="ordercreation.bo.default"} %</span>
{/loop}
</div>
{/custom_render_form_field}
</div>
</div>
<table class="table table-condensed">
<caption><label>{intl l="List or ordered products" d="ordercreation.bo.default"}</label></caption>
<tbody id="body-order-cart">
{$productQuantities = []}
{form_field field='quantity'}
{$productQuantities = $value}
{/form_field}
{$indexProduct=0}
{form_field field='product_sale_element_id'}
{foreach $value as $pseId}
{include
file="../ajax/add-cart-item.html"
productId=$productId
position=$indexProduct
quantity=$productQuantities[$indexProduct]
}
{$indexProduct = $indexProduct+1}
{/foreach}
{/form_field}
{if $indexProduct == 0}
<tr id="empty-order-row">
<td colspan="2">
<div class="alert alert-info" style="margin-bottom: 0">
{intl l="There is no products in this order." d='ordercreation.bo.default'}
</div>
</td>
</tr>
{/if}
</tbody>
<tfoot>
<tr>
<td colspan="2" class="text-right">
<a id="add-cart-item" class="btn btn-default btn-primary action-btn" title="{intl l='Add product to this order' d='ordercreation.bo.default'}" href="#" data-toggle="modal">
<span>{intl l="Add product to order" d="ordercreation.bo.default"}</span>
</a>
</td>
</tr>
</tfoot>
</table>
<div class="row">
<div class="col-md-12">
{custom_render_form_field field='delivery-module'}
<div id="list-delivery">
<div class="alert alert-danger">
{intl l="Please select a delivery adresse to display shipping options" d="ordercreation.bo.default"}
</div>
</div>
{/custom_render_form_field}
</div>
<div class="col-md-6">
<div id="create-order-form-td-payment_module_id">
{custom_render_form_field field='payment_module_id'}
<select {form_field_attributes field='payment_module_id'}>
{loop type="module" name="module-payment" module_type="3" active="1"}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
{/custom_render_form_field}
</div>
</div>
<div class="col-md-6">
<div "id="create-order-form-td-check-payment-redirect">
{render_form_field field='redirects_payment'}
</div>
</div>
</div>
<div class="hidden" id="mode-socolissimo"></div>
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "order_create_dialog"
dialog_title = {intl l="Generate a new order" d="ordercreation.bo.default"}
dialog_body = {$smarty.capture.order_create_dialog nofilter}
dialog_ok_label = {intl l="Save" d='ordercreation.bo.default'}
ok_button_id = "submit_order_creation"
form_action = {url path='/admin/module/OrderCreation/order/create'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
{/form}

View File

@@ -0,0 +1,106 @@
<div class="row">
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-12 title title-without-tabs">
{intl d='ordercreation.bo.default' l="Configuration du module de création de commande en BO"}
</div>
</div>
<div class="form-container">
<div class="row">
<div class="col-md-12">
{form name="admin.order.creation.form.configure"}
<form action="{url path="/admin/module/OrderCreation/configure"}" method="post">
{form_hidden_fields form=$form}
{include file = "includes/inner-form-toolbar.html"
hide_flags = true
page_url = "{url path='/admin/module/OrderCreation'}"
close_url = "{url path='/admin/modules'}"
}
{if $form_error}
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger">{$form_error_message}</div>
</div>
</div>
{/if}
<div class="row">
<div class="col-sm-6">
{form_field field="order_creation_delivery_module_id"}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<input type="hidden" name="{$name}" id="delivery-module" value="{$value}" />
<select class="form-control" id="delivery_module_id_select">
<option value="">{intl d='ordercreation.bo.default' l='No default delivery module (default)'}</option>
{loop type="module" name="delivery-module" backend_context=1 module_type="2"}
<option value="{$ID}" {if $value == $ID}selected="selected"{/if}>{$CODE} - {$TITLE}</option>
{/loop}
</select>
</div>
{/form_field}
</div>
</div>
</form>
{/form}
</div>
</div>
</div>
</div>
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-12 title title-without-tabs">
{intl d='ordercreation.bo.default' l="Configuration de redirection de paiement"}
</div>
</div>
<form action="{url path="/admin/module/OrderCreation/configure-redirects-payment"}" method="post">
{form name="admin.order.redirects.payment.form"}
{form_hidden_fields form=$form}
{if $form_error}
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger">{$form_error_message}</div>
</div>
</div>
{/if}
<div class="row">
<div class="col-sm-6">
{form_field field="order_creation_redirects_payment"}
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<select name="{$name}[]" id="" multiple class="form-control">
{loop type="module" name="delivery-module" backend_context=1 module_type="3" active="1"}
{$value}
<option value="{$ID}" {if $ID|in_array:$value|default:[]} selected="selected"{/if}>{$CODE} - {$TITLE}</option>
{/loop}
</select>
{/form_field}
</div>
</div>
{include file = "includes/inner-form-toolbar.html"
hide_flags = true
page_url = "{url path='/admin/module/OrderCreation'}"
close_url = "{url path='/admin/modules'}"
}
</form>
{/form}
</div>
</div>
{block name="javascript-last-call"}
<script type="text/javascript">
window.onload = function () {
$('#delivery_module_id_select').on('change', function () {
$('#delivery-module').val($(this).val());
});
};
</script>
{/block}