On avance sur LivraisonParSecteurs

This commit is contained in:
2021-02-11 17:28:25 +01:00
parent d60cc44eb1
commit 9e7232d209
17 changed files with 685 additions and 167 deletions

View File

@@ -5,6 +5,11 @@
{block name="check-access"}update{/block}
{block name="check-module"}LivraisonParSecteurs{/block}
{block name="after-bootstrap-css"}
<link rel="stylesheet"
href="{stylesheet file='assets/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css'}">
{/block}
{block name="main-content"}
<div id="wrapper" class="container">
{assign "area_id" $smarty.get.area_id}
@@ -14,7 +19,6 @@
{intl l='Edit an area' d='livraisonparsecteurs'}&nbsp;: <b>{loop name="area" type="lps_area" id={$area_id}}{$TITLE}{/loop}</b>
</div>
{hookblock name="area.tabs" area=$area_id}
<ul class="nav nav-tabs" id="tabbed-menu">
{loop name="auth-general" type="auth" role="ADMIN" resource="admin" access="VIEW" module="LivraisonParSecteurs"}
<li class="active"><a href="#general" data-toggle="tab">{intl l="General" d="livraisonparsecteurs"}</a></li>
@@ -44,21 +48,29 @@
</div>
{/loop}
</div>
{/hookblock}
</div>
</div>
{include file="modal/area-schedule-modal.html"}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
<script>
$(function() {
$(".toggle-active").on('switch-change', function (event, data) {
$("#active").val(data['value'] ? 1 : 0);
{javascripts file='assets/js/moment-with-locales.min.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
<script>
$(function() {
$(".toggle-active").on('switch-change', function (event, data) {
$("#active").val(data['value'] ? 1 : 0);
});
});
});
</script>
{/javascripts}
</script>
{/javascripts}
{include file="js/area-schedule-js.html"}
{/block}

View File

@@ -0,0 +1,116 @@
{form name=$form_name}
{form_hidden_fields form=$form}
{render_form_field form=$form field="success_url" value={url path="/admin/module/LivraisonParSecteurs/edit?area_id={$area_id}#schedule"}}
{render_form_field form=$form field="error_url" value={url path="/admin/module/LivraisonParSecteurs/edit?area_id={$area_id}#schedule"}}
{*
{form_field form=$form field="area-schedule_id"}
<div class="form-group">
<input type="text" class="form-control" name="{$name}" id="{$label_attr.for}"
value="{$area-schedule_id}"/>
</div>
{/form_field}
*}
{form_field form=$form field="area_id"}
<div class="form-group">
<input type="text" class="form-control" name="{$name}" id="{$label_attr.for}"
value="{$area_id}"/>
</div>
{/form_field}
{form_field form=$form field="day"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d="livraisonparsecteurs"}
{if $required}<span class="required">*</span>{/if}
</label>
{form_error form=$form field="day"}{$message}{/form_error}
<select class="form-control" name="{$name}" id="{$label_attr.for}" {if {$update|default:false} == false}multiple{/if}>
{if {$update|default:false} == true}
<option value="" selected></option>
{/if}
{foreach $choices as $choice}
<option value="{$choice->value}" {if $DAY == $choice->value}selected{/if} >{$choice->label}</option>
{/foreach}
</select>
</div>
{/form_field}
{if {$update|default:false} == false}
<div class="row">
<div class="col-sm-12">
<h3>{intl l="AM" d='livraisonparsecteurs'}</h3>
{form_field form=$form field="begin"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d='livraisonparsecteurs'}
{if $required}<span class="required">*</span>{/if}
</label>
{form_error form=$form field="begin"}{$message}{/form_error}
<div class='input-group time' id="{$label_attr.for}">
<input type='text' class="form-control" name="{$name}" value="{$BEGIN|default:"9:00"}"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
{/form_field}
{form_field form=$form field="end"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d='livraisonparsecteurs'}
{if $required}<span class="required">*</span>{/if}
</label>
{form_error form=$form field="end"}{$message}{/form_error}
<div class='input-group time' id="{$label_attr.for}">
<input type='text' class="form-control" name="{$name}" value="{$END|default:"12:00"}"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
{/form_field}
</div>
</div>
{else}
{form_field form=$form field="begin"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d='livraisonparsecteurs'}
{if $required}<span class="required">*</span>{/if}
</label>
{form_error form=$form field="begin"}{$message}{/form_error}
<div class='input-group time' id="{$label_attr.for}">
<input type='text' class="form-control" name="{$name}" value="{$BEGIN}"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
{/form_field}
{form_field form=$form field="end"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d='livraisonparsecteurs'}
{if $required}<span class="required">*</span>{/if}
</label>
{form_error form=$form field="end"}{$message}{/form_error}
<div class='input-group time' id="{$label_attr.for}">
<input type='text' class="form-control" name="{$name}" value="{$END}"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
{/form_field}
{/if}
{/form}

View File

@@ -23,20 +23,6 @@
{/form_field}
<div class="row form-inline">
<div class="col-md-6">
{form_field form=$form field="price"}
<div class="form-group form-inline">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d='livraisonparsecteurs'}
{if $required}<span class="required">*</span>{/if}
</label>
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$PRICE}" {if $required}required{/if} />
</div>
{form_error form=$form field="price"}{$message}{/form_error}
{/form_field}
</div>
<div class="col-md-6">
{form_field form=$form field="active"}
<div class="form-group">
@@ -53,6 +39,20 @@
</div>
{/form_field}
</div>
<div class="col-md-6">
{form_field form=$form field="price"}
<div class="form-group form-inline">
<label class="control-label" for="{$label_attr.for}">
{intl l=$label d='livraisonparsecteurs'}
{if $required}<span class="required">*</span>{/if}
</label>
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$PRICE}" {if $required}required{/if} />&nbsp;
</div>
{form_error form=$form field="price"}{$message}{/form_error}
{/form_field}
</div>
</div>
</form>
{/loop}

View File

@@ -1,90 +1,90 @@
<div class="row">
<div class="col-md-12">
<table class="table table-striped table-condensed">
<caption class="clearfix">
{loop name="auth-create" type="auth" role="ADMIN" resource="admin.dealer.schedules" access="CREATE" module="Dealer"}
<div class="pull-right">
<a class="btn btn-default btn-primary dealer-schedules-default"
title="{intl l='Create a new Default Schedules' d='dealer.bo.default'}"
data-target="#dealer-schedules-create" data-toggle="modal">
<i class="glyphicon glyphicon-plus-sign"></i>
</a>
</div>
{/loop}
<h4>{intl l="Delivery days" d="livraisonparsecteurs"}</h4>
</caption>
{form name='lps-area-schedule-update'}
<div class="form-container">
<thead>
<tr>
<th>
{intl l="Day" d="livraisonparsecteurs"}
</th>
<th>
{intl l="Begin" d="livraisonparsecteurs"}
</th>
<th>
{intl l="End" d="livraisonparsecteurs"}
</th>
<th>
{intl l="Actions" d="livraisonparsecteurs"}
</th>
</tr>
</thead>
{if $form_error}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
<tbody>
{loop name="dealer-schedules-defaults" type="lap_area_schedule" area_id=$area_id}
<tr>
<td>
{$DAY_LABEL}
</td>
<td>
{format_date date=$BEGIN format="H:i"}
</td>
<td>
{format_date date=$END format="H:i"}
</td>
{* Actions *}
<td>
<div class="btn-group">
{loop name="auth-edit" type="auth" role="ADMIN" resource="admin.dealer.schedules" access="UPDATE" module="Dealer"}
<a class="btn btn-default btn-xs dealer-schedules-update-default"
title="{intl l='Modify this Schedule' d='dealer.bo.default'}"
data-target="#dealer-schedules-update" data-toggle="modal" data-id="{$ID}"
data-day="{$DAY}" data-begin="{format_date date=$BEGIN format="H:i"}"
data-end="{format_date date=$END format="H:i"}">
<i class="glyphicon glyphicon-edit"></i>
</a>
{/loop}
{loop name="auth-edit" type="auth" role="ADMIN" resource="admin.dealer.schedules" access="CREATE" module="Dealer"}
<a class="btn btn-default btn-xs dealer-schedules-clone"
title="{intl l='Clone this Schedule' d='dealer.bo.default'}"
data-target="#dealer-schedules-clone" data-toggle="modal" data-id="{$ID}">
{loop name="area" type="lps_area" id="$area_id"}
<form action="{url path='/admin/module/LivraisonParSecteurs/edit' area_id={$area_id}}" method="POST" class="clearfix" {form_enctype form=$form}>
{form_hidden_fields form=$form}
{form_field form=$form field="area_id"}
<input type="hidden" name="{$name}" value="{$area_id}"/>
{/form_field}
<div class="row">
<div class="col-md-12">
<table class="table table-striped table-condensed">
<caption class="clearfix">
{loop name="auth-create" type="auth" role="ADMIN" resource="admin.lps.schedule" access="CREATE" module="LivraisonParSecteurs"}
<div class="pull-right">
<a class="btn btn-default btn-primary area-schedule-default"
title="{intl l='Add a new delivery day' d='livraisonparsecteurs'}"
data-target="#area-schedule-create" data-toggle="modal">
<i class="glyphicon glyphicon-plus-sign"></i>
</a>
{/loop}
{loop name="auth-delete" type="auth" role="ADMIN" resource="admin.dealer.schedules" access="DELETE" module="Dealer"}
<a class="btn btn-default btn-xs dealer-schedules-delete"
title="{intl l='Delete this Schedule' d='dealer.bo.default'}"
data-target="#dealer-schedules-delete" data-toggle="modal" data-id="{$ID}">
<i class="glyphicon glyphicon-trash"></i>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
{elseloop rel="dealer-schedules-defaults"}
<tr>
<td colspan="1000">
<div class="alert alert-info">
{intl l="There is no Default Schedules" d="livraisonparsecteurs"}
</div>
</td>
</tr>
{/elseloop}
</tbody>
{/loop}
</caption>
<thead>
<tr>
<th>{intl l="Delivery day" d="livraisonparsecteurs"}</th>
<th>{intl l="Delivery beginning time" d="livraisonparsecteurs"}</th>
<th>{intl l="Delivery ending time" d="livraisonparsecteurs"}</th>
<th>{intl l="Actions" d="livraisonparsecteurs"}</th>
</tr>
</thead>
</table>
<tbody>
{loop name="area-schedule" type="lps_area_schedule" area_id=$area_id}
<tr>
<td>{$DAY_LABEL}</td>
<td>{format_date date=$BEGIN format="H:i"}</td>
<td>{format_date date=$END format="H:i"}</td>
{* Actions *}
<td>
<div class="btn-group">
{loop name="auth-edit" type="auth" role="ADMIN" resource="admin.lps.schedule" access="UPDATE" module="LivraisonParSecteurs"}
<a class="btn btn-default btn-xs area-schedule-update-default"
title="{intl l='Modify this delivery day' d='livraisonparsecteurs'}"
data-target="#area-schedule-update" data-toggle="modal" data-id="{$ID}"
data-day="{$DAY}" data-begin="{format_date date=$BEGIN format="H:i"}"
data-end="{format_date date=$END format="H:i"}">
<i class="glyphicon glyphicon-edit"></i>
</a>
{/loop}
{loop name="auth-delete" type="auth" role="ADMIN" resource="admin.lps.schedule" access="DELETE" module="LivraisonParSecteurs"}
<a class="btn btn-default btn-xs area-schedule-delete"
title="{intl l='Delete this delivery day' d='livraisonparsecteurs'}"
data-target="#area-schedule-delete" data-toggle="modal" data-id="{$ID}">
<i class="glyphicon glyphicon-trash"></i>
</a>
{/loop}
</div>
<input type="hidden" name="{$name}" value="{$ID}"/>
</td>
</tr>
{/loop}
{elseloop rel="area-schedule"}
<tr>
<td colspan="1000">
<div class="alert alert-info">
{intl l="There is no schedule for this area" d="livraisonparsecteurs"}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
</div>
</form>
{/loop}
</div>
{/form}

View File

@@ -0,0 +1,65 @@
<script>
$(function () {
$('a.area-schedule-delete').click(function (ev) {
$('#attr-area-schedule-id').val($(this).data('id'));
$("#attr-area-schedule-begin input, #attr-area-schedule-end input").prop('required', false);
$("#attr-area-schedule-day").prop('required', false);
});
$('a.area-schedule-update-default').click(function (ev) {
$("#attr-area-schedule-id").val($(this).data('id'));
$("#attr-area-schedule-begin input", "#area-schedule-update").val($(this).data('begin'));
$("#attr-area-schedule-end input", "#area-schedule-update").val($(this).data('end'));
$('#attr-area-schedule-day option[value="' + $(this).data('day') + '"]', '#area-schedule-update').prop('selected', true);
$("#attr-area-schedule-day").prop('required', true);
});
// $('a.dealer-schedules-default').click(function (ev) {
// $(".period").addClass("hidden");
// $("#attr-dealer-schedules-closed", "#dealer-schedules-create").val("0");
// $("#attr-dealer-schedules-period-begin input, #attr-dealer-schedules-period-end input").prop('required', false);
// $("#attr-dealer-schedules-day").prop('required', true);
// $('#attr-dealer-schedules-day option').prop('selected', false);
// });
// $('a.dealer-schedules-closed').click(function (ev) {
// $(".period").removeClass("hidden");
// $("#attr-dealer-schedules-closed", "#dealer-schedules-create").val("1");
// $("#attr-dealer-schedules-period-begin input, #attr-dealer-schedules-period-end input").prop('required', true);
// $("#attr-dealer-schedules-day").prop('required', false);
// $('#attr-dealer-schedules-day option').prop('selected', false);
// });
// $('a.dealer-schedules-update-closed').click(function (ev) {
// $(".period").removeClass("hidden");
// $("#attr-dealer-schedules-id", "#dealer-schedules-update").val($(this).data('id'));
// $("#attr-dealer-schedules-begin input", "#dealer-schedules-update").val($(this).data('begin'));
// $("#attr-dealer-schedules-end input", "#dealer-schedules-update").val($(this).data('end'));
// $("#attr-dealer-schedules-period-begin input", "#dealer-schedules-update").val($(this).data('periodbegin'));
// $("#attr-dealer-schedules-period-end input", "#dealer-schedules-update").val($(this).data('periodend'));
// $('#attr-dealer-schedules-day option[value="' + $(this).data('day') + '"]', '#dealer-schedules-update').prop('selected', true);
// $("#attr-dealer-schedules-closed", "#dealer-schedules-update").val("1");
// $("#attr-dealer-schedules-period-begin input, #attr-dealer-schedules-period-end input").prop('required', true);
// $("#attr-dealer-schedules-day").prop('required', false);
//
// });
{$langcode = {lang attr="code"}|substr:0:2}
$(document).ready(function () {
$('.input-group.time').datetimepicker({
locale: "{$langcode}",
format: 'HH:mm',
stepping: 15
});
});
$(document).ready(function () {
$('.input-group.date').datetimepicker({
locale: "{$langcode}",
format: 'YYYY-MM-DD'
});
});
});
</script>

View File

@@ -0,0 +1,62 @@
{* CREATE Modal *}
{form name="lps-area-schedule-create"}
{capture "schedule_create"}
{include file="form/dealer-schedules-create.html" form_name="lps-area-schedule-create" area_id=$smarty.get.area_id}
{/capture}
{include file="includes/generic-create-dialog.html"
dialog_id = "dealer-schedules-create"
dialog_title = {intl l="Create a schedules" d="dealer.bo.default"}
dialog_body = {$smarty.capture.schedules_create nofilter}
dialog_ok_label = {intl l="Create"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path="admin/module/Dealer/schedules"}
form_enctype = {form_enctype form=$form}
}
{/form}
{*Update Modal*}
{form name="dealer-schedules.update"}
{capture "schedules_update"}
{form_field form=$form field="id"}
<input type="hidden" id="{$label_attr.for}" name="{$name}" value=""/>
{/form_field}
{* {include file="form/dealer-schedules-create.html" form_name="dealer-schedules.update" dealer_id=$smarty.get.dealer_id update=true} *}
{/capture}
{include file="includes/generic-create-dialog.html"
dialog_id = "dealer-schedules-update"
dialog_title = {intl l="Modify a schedules" d="dealer.bo.default"}
dialog_body = {$smarty.capture.schedules_update nofilter}
dialog_ok_label = {intl l="Save"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path="admin/module/Dealer/schedules/update"}
form_enctype = {form_enctype form=$form}
}
{/form}
{* DELETE modal *}
{capture "schedules_delete"}
{intl l="Do you really want to delete this schedules ?" d="dealer.bo.default"}
<input type="hidden" name="dealer-schedules_id" id="dealer_schedules_delete_id" value=""/>
<input type="hidden" name="dealer_id" value="{$smarty.get.dealer_id}"/>
<input type="hidden" name="success_url" value="{url path="/admin/module/Dealer/dealer/edit?dealer_id={$dealer_id}#schedules"}"/>
{/capture}
{include file="includes/generic-confirm-dialog.html"
dialog_id = "dealer-schedules-delete"
dialog_title = {intl l="Delete an entry of schedules" d="dealer.bo.default"}
dialog_message = {$smarty.capture.schedules_delete nofilter}
dialog_ok_label = {intl l="Delete"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {token_url path='/admin/module/Dealer/schedules/delete'}
}

View File

@@ -0,0 +1,41 @@
{* DELETE modal *}
{capture "schedule_delete"}
{intl l="Do you really want to delete this delivery day ?" d="livraisonparsecteurs"}
<input type="text" name="area-schedule_id" id="attr-area-schedule-id" value="999"/>
<input type="hidden" name="area_id" value="{$smarty.get.area_id}"/>
<input type="hidden" name="success_url" value="{url path="/admin/module/LivraisonParSecteurs/edit?area_id={$area_id}#schedule"}"/>
{/capture}
{include file="includes/generic-confirm-dialog.html"
dialog_id = "area-schedule-delete"
dialog_title = {intl l="Delete an entry of schedule" d="livraisonparsecteurs"}
dialog_message = {$smarty.capture.schedule_delete nofilter}
dialog_ok_label = {intl l="Delete"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {token_url path='/admin/module/LivraisonParSecteurs/schedule/delete'}
}
{* UPDATE Modal*}
{form name="lps-area-schedule-update"}
{capture "schedule_update"}
{form_field form=$form field="area-schedule_id"}
<input type="hidden" id="area-schedule_id" name="attr-area-schedule-id" value=""/>
{/form_field}
{form_field form=$form field="area_id"}
<input type="hidden" id="area_id" name="area_id" value="{$smarty.get.area_id}"/>
{/form_field}
{include file="form/area-schedule-create.html" form_name="lps-area-schedule-update" area-schedule_id=$smarty.get.id update=true}
{/capture}
{include file="includes/generic-create-dialog.html"
dialog_id = "area-schedule-update"
dialog_title = {intl l="Modify a schedule" d="livraisonparsecteurs"}
dialog_body = {$smarty.capture.schedule_update nofilter}
dialog_ok_label = {intl l="Save"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path='admin/module/LivraisonParSecteurs/schedule/update'}
form_enctype = {form_enctype form=$form}
}
{/form}