LivraisonParSecteurs > onglet "Communes desservies" : la carte est intégrée, il reste l'ajout et la suppression de communes

This commit is contained in:
2021-02-16 12:16:14 +01:00
parent bdc040b7a4
commit 54a4b98b7d
17 changed files with 203 additions and 245 deletions

View File

@@ -6,33 +6,47 @@ INSERT INTO `lps_area`(`id`,`title`) VALUES
INSERT INTO `lps_area_city`(`id_area`,`zipcode`) VALUES
(1,'62120'),
(1,'62129'),
(1,'62219'),
(1,'62500'),
(1,'62510'),
(1,'62570'),
(1,'62575'),
(1,'62910');
INSERT INTO `lps_area_city`(`id_area`,`zipcode`,`title`,`latitude`,`longitude`) VALUES
(1,'62120','CAMPAGNE LES WARDRECQUES','50.7136140049','2.33349766884'),
(1,'62120','AIRE SUR LA LYS','50.6441641115','2.39533267946'),
(1,'62120','WITTES','50.6716650445','2.38817871374'),
(1,'62129','ECQUES','50.6751011115','2.28909761313'),
(1,'62219','LONGUENESSE','50.7356717764','2.24445927669'),
(1,'62500','CLAIRMARAIS','50.7691557578','2.34273928671'),
(1,'62500','ST MARTIN LEZ TATINGHEM','50.7568801196','2.2297072767'),
(1,'62500','ST OMER','50.7679781717','2.26334881482'),
(1,'62500','SALPERWICK','50.768362521','2.21963774504'),
(1,'62500','TILQUES','50.7728122391','2.20152463188'),
(1,'62510','ARQUES','50.7402216255','2.31902794783'),
(1,'62570','HALLINES','50.7007255503','2.20827364581'),
(1,'62570','HELFAUT','50.6917027903','2.25015585426'),
(1,'62570','WIZERNES','50.7153325042','2.22913159655'),
(1,'62575','BLENDECQUES','50.7159944346','2.27536301448'),
(1,'62575','HEURINGHEM','50.6957474078','2.29391988057'),
(1,'62910','BAYENGHEM LES SENINGHEM','50.7048864835','2.07577387326'),
(1,'62910','EPERLECQUES','50.8183914819','2.16069366951'),
(1,'62910','HOULLE','50.7969936327','2.16484725691'),
(1,'62910','MORINGHEM','50.7633897725','2.12682414351'),
(1,'62910','MOULLE','50.7883148321','2.1706543981'),
(1,'62910','SERQUES','50.7907495973','2.20166097242');
INSERT INTO `lps_area_city`(`id_area`,`zipcode`) VALUES
(2,'62010'),
(2,'62024'),
(2,'62088'),
(2,'62229'),
(2,'62292'),
(2,'62309'),
(2,'62504'),
(2,'62534'),
(2,'62613'),
(2,'62656'),
(2,'62674'),
(2,'62702'),
(2,'62788'),
(2,'62794'),
(2,'62803'),
(2,'62882'),
(2,'62897'),
(2,'62898'),
(2,'62905');
INSERT INTO `lps_area_city`(`id_area`,`zipcode`,`title`,`latitude`,`longitude`) VALUES
(2,'62010','AFFRINGUES','50.6903350571','2.07492436119'),
(2,'62024','ALQUINES','50.7335685811','1.99279258078'),
(2,'62088','BAYENGHEM LES SENINGHEM','50.7048864835','2.07577387326'),
(2,'62229','CLETY','50.6533415783','2.18209813078'),
(2,'62292','ELNES','50.6860806657','2.11534643648'),
(2,'62309','ESQUERDES','50.7009057679','2.17889940044'),
(2,'62504','LEULINGHEM','50.7346790388','2.16911709043'),
(2,'62534','LUMBRES','50.705094418','2.11706482499'),
(2,'62613','NIELLES LES BLEQUIN','50.675332061','2.03042491518'),
(2,'62656','PIHEM','50.6761891157','2.21194474254'),
(2,'62674','QUELMES','50.7344041405','2.12647655403'),
(2,'62702','REMILLY WIRQUIN','50.6699885591','2.17457011207'),
(2,'62788','SENINGHEM','50.6984836133','2.02702639439'),
(2,'62794','SETQUES','50.7145017028','2.15645765074'),
(2,'62803','SURQUES','50.7434489941','1.92294829855'),
(2,'62882','WAVRANS SUR L AA','50.6749530079','2.13817752788'),
(2,'62897','WISMES','50.6613559583','2.07972084711'),
(2,'62898','WISQUES','50.7269504581','2.1911996601'),
(2,'62905','ZUDAUSQUES','50.7526605163','2.16024730203');

View File

@@ -17,6 +17,9 @@
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="id_area" required="true" type="INTEGER" />
<column name="zipcode" required="true" size="10" type="VARCHAR" />
<column name="title" required="true" size="50" type="VARCHAR" />
<column name="latitude" required="false" type="DOUBLE" />
<column name="longitude" required="false" type="DOUBLE" />
<foreign-key foreignTable="lps_area" name="fk_area_area_city" onDelete="CASCADE">
<reference foreign="id" local="id_area"/>

View File

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

View File

@@ -1,68 +0,0 @@
# 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;
-- ---------------------------------------------------------------------
-- lps_area
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `lps_area`;
CREATE TABLE `lps_area`
(
`id` INTEGER NOT NULL,
`title` VARCHAR(50) NOT NULL,
`active` TINYINT DEFAULT 1 NOT NULL,
`price` FLOAT DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- lps_area_city
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `lps_area_city`;
CREATE TABLE `lps_area_city`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`id_area` INTEGER NOT NULL,
`zipcode` VARCHAR(10) NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `fi_area_area_city` (`id_area`),
CONSTRAINT `fk_area_area_city`
FOREIGN KEY (`id_area`)
REFERENCES `lps_area` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- lps_area_schedule
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `lps_area_schedule`;
CREATE TABLE `lps_area_schedule`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`id_area` INTEGER NOT NULL,
`day` INTEGER NOT NULL,
`begin_time` TIME NOT NULL,
`end_time` TIME NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `fi_area_area_schedule` (`id_area`),
CONSTRAINT `fk_area_area_schedule`
FOREIGN KEY (`id_area`)
REFERENCES `lps_area` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -5,8 +5,10 @@ return array(
'Add a new delivery day' => 'Ajouter un jour de livraison',
'Area name' => 'Nom du secteur',
'Cities' => 'Communes desservies',
'City' => 'Commune',
'Create a delivery day' => 'Créer un nouveau jour de livraison',
'Delete an entry of schedule' => 'Supprimer un jour de livraison',
'Delivered cities count' => 'Nb de communes desservies',
'Delivery beginning time' => 'Début de la tournée',
'Delivery day' => 'Jour de livraison',
'Delivery days' => 'Jours de livraison',
@@ -22,6 +24,7 @@ return array(
'Schedule' => 'Horaires de livraison',
'There is no schedule for this area' => 'Aucune livraison actuellement sur ce secteur',
'Title of config view' => 'Module LivraisonParSecteurs - Configuration',
'Zipcode' => 'Code postal',
'Monday' => 'Lundi',
'Tuesday' => 'Mardi',
'Wednesday' => 'Mercredi',

View File

@@ -33,6 +33,9 @@ class AreaCitiesLoop extends BaseLoop implements PropelSearchLoopInterface
$loopResultRow
->set("ID", $lps_area_cities->getId())
->set("ZIPCODE", $lps_area_cities->getZipcode())
->set("TITLE", $lps_area_cities->getTitle())
->set("LATITUDE", $lps_area_cities->getLatitude())
->set("LONGITUDE", $lps_area_cities->getLongitude())
;
$loopResult->addRow($loopResultRow);
}

View File

@@ -3,6 +3,7 @@
namespace LivraisonParSecteurs\Loop;
use LivraisonParSecteurs\LivraisonParSecteurs;
use LivraisonParSecteurs\Model\LpsAreaCityQuery;
use LivraisonParSecteurs\Model\LpsAreaScheduleQuery;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
@@ -40,12 +41,15 @@ class AreaLoop extends BaseLoop implements PropelSearchLoopInterface
}
$deliveryDays = substr($deliveryDays, 0, strlen($deliveryDays)-2);
$citiesCount = LpsAreaCityQuery::create()->findByIdArea($lps_area->getId())->count();
$loopResultRow
->set("ID", $lps_area->getId())
->set("TITLE", $lps_area->getTitle())
->set("ACTIVE", $lps_area->getActive())
->set("PRICE", $lps_area->getPrice())
->set("DELIVERY_DAYS", $deliveryDays)
->set("COVERED_CITIES_NUMBER", $citiesCount)
;
$loopResult->addRow($loopResultRow);
}

View File

@@ -1,20 +0,0 @@
<?php
namespace LivraisonParSecteurs\Model;
use LivraisonParSecteurs\Model\Base\LpsArea as BaseLpsArea;
/**
* Skeleton subclass for representing a row from the 'lps_area' 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 LpsArea extends BaseLpsArea
{
}

View File

@@ -1,20 +0,0 @@
<?php
namespace LivraisonParSecteurs\Model;
use LivraisonParSecteurs\Model\Base\LpsAreaCity as BaseLpsAreaCity;
/**
* Skeleton subclass for representing a row from the 'lps_area_city' 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 LpsAreaCity extends BaseLpsAreaCity
{
}

View File

@@ -1,20 +0,0 @@
<?php
namespace LivraisonParSecteurs\Model;
use LivraisonParSecteurs\Model\Base\LpsAreaCityQuery as BaseLpsAreaCityQuery;
/**
* Skeleton subclass for performing query and update operations on the 'lps_area_city' 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 LpsAreaCityQuery extends BaseLpsAreaCityQuery
{
}

View File

@@ -1,20 +0,0 @@
<?php
namespace LivraisonParSecteurs\Model;
use LivraisonParSecteurs\Model\Base\LpsAreaQuery as BaseLpsAreaQuery;
/**
* Skeleton subclass for performing query and update operations on the 'lps_area' 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 LpsAreaQuery extends BaseLpsAreaQuery
{
}

View File

@@ -1,20 +0,0 @@
<?php
namespace LivraisonParSecteurs\Model;
use LivraisonParSecteurs\Model\Base\LpsAreaSchedule as BaseLpsAreaSchedule;
/**
* Skeleton subclass for representing a row from the 'lps_area_schedule' 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 LpsAreaSchedule extends BaseLpsAreaSchedule
{
}

View File

@@ -1,20 +0,0 @@
<?php
namespace LivraisonParSecteurs\Model;
use LivraisonParSecteurs\Model\Base\LpsAreaScheduleQuery as BaseLpsAreaScheduleQuery;
/**
* Skeleton subclass for performing query and update operations on the 'lps_area_schedule' 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 LpsAreaScheduleQuery extends BaseLpsAreaScheduleQuery
{
}

View File

@@ -77,4 +77,5 @@
</script>
{/javascripts}
{include file="js/area-schedule-js.html"}
{include file="js/area-cities-js.html"}
{/block}

View File

@@ -29,10 +29,11 @@
<thead>
<tr>
<th>{intl l="Area name" d='livraisonparsecteurs'}</th>
<th>{intl l="Active" d='livraisonparsecteurs'}</th>
<th class="col-md-1">{intl l="Active" d='livraisonparsecteurs'}</th>
<th>{intl l="Delivery price" d='livraisonparsecteurs'}</th>
<th>{intl l="Delivery days" d='livraisonparsecteurs'}</th>
<th></th>
<th>{intl l="Delivered cities count" d='livraisonparsecteurs'}</th>
<th class="col-md-1">&nbsp;</th>
</tr>
</thead>
@@ -49,6 +50,7 @@
</td>
<td>{$PRICE} €</td>
<td>{$DELIVERY_DAYS}</td>
<td>{$COVERED_CITIES_NUMBER}</td>
<td class="actions">
<div class="btn-group" role="group">
<a class="btn btn-info btn-responsive" title="{intl l='Edit this area'}" href="{url path='/admin/module/LivraisonParSecteurs/edit' area_id=$ID}">

View File

@@ -1,3 +1,34 @@
<style>
.custom-map-control-button {
appearance: button;
background-color: #fff;
border: 0;
border-radius: 2px;
box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.3);
cursor: pointer;
margin: 10px;
padding: 0 0.5em;
height: 40px;
font: 400 18px Roboto, Arial, sans-serif;
overflow: hidden;
}
.custom-map-control-button:hover {
background: #ebebeb;
}
.locationMap {
height:600px;
width:100%;
margin-top: 20px;
}
.city-remove {
height: 30x !important;
}
</style>
{form name='lps-area-cities-update'}
<div class="form-container">
@@ -5,28 +36,63 @@
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
<div class="row">
<div class="col-md-4">
{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}
{include
file = "includes/inner-form-toolbar.html"
hide_flags = true
hide_submit_buttons = false
page_url = "{url path='/admin/module/LivraisonParSecteurs/edit' area_id=$area_id}"
close_url = "{url path='/admin/module/LivraisonParSecteurs'}"
current_tab = "general"
}
{form_field form=$form field="area_id"}
<input type="hidden" name="{$name}" value="{$area_id}"/>
{/form_field}
<table>
<thead></thead>
<div class="general-block-decorator">
<div class="table-responsive">
<table class="table table-striped table-condensed" id="areas-table">
<thead>
<tr>
<th>{intl l="Zipcode" d="livraisonparsecteurs"}</th>
<th>{intl l="City" d="livraisonparsecteurs"}</th>
<th class="pull-right">
<div>
<a class="btn btn-default btn-primary city-add"
title="{intl l='Add a new city' d='livraisonparsecteurs'}"
data-target="#city-add" data-toggle="modal">
<i class="glyphicon glyphicon-plus-sign"></i>
</a>
</div>
</th>
</tr>
</thead>
<tbody>
{loop name="cities" type="lps_area_cities" area_id="$area_id"}
<tr><td>{$ZIPCODE}</td></tr>
<tr>
<td>{$ZIPCODE}</td>
<td>{$TITLE}</td>
<td class="actions">
<div class="btn-group" role="group">
<a class="btn btn-danger btn-responsive city-remove" title="{intl l='Remove this city'}" data-target="#city-remove" data-toggle="modal" data-id="{$ID}">
<i class="glyphicon glyphicon-trash"></i>
</a>
</div>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
</div>
<table id="coordinates" class="hidden">
<thead></thead>
<tbody>
{loop name="cities-coordinates" type="lps_area_cities" area_id="$area_id"}
<tr>
<td>{$LATITUDE}</td>
<td>{$LONGITUDE}</td>
<td>{$TITLE}</td>
</tr>
{/loop}
</tbody>
</table>
@@ -34,4 +100,14 @@
</form>
{/loop}
</div>
<div class="col-md-8">
<input type="hidden" id="map-center-lon" value="2.2667287624488397" />
<input type="hidden" id="map-center-lat" value="50.749980292425974" />
<div id="map" class="locationMap"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBb07YA_unrh5w821I1xHxbeYb5KCF_WaM&libraries=&v=weekly" async></script>
</div>
</div>
</div>
{/form}

View File

@@ -0,0 +1,42 @@
<script>
let map;
(function($){
$('a[href="#cities"]').on("shown.bs.tab",function(){
var opt = {
center: new google.maps.LatLng($("#map-center-lat").val(), $("#map-center-lon").val()),
zoom: 12,
streetViewControl: false,
mapTypeControl: false
};
map = new google.maps.Map(document.getElementById("map"),opt);
var markerOpts = {
title: $(document.getElementById("area.title")).val(),
position: opt.center,
draggable: true,
map: map
};
displayPins();
});
function displayPins() {
var arrays = [];
$('#coordinates').eq(0).find('tr').each((r,row) => arrays.push($(row).find('td,th').map((c,cell) => $(cell).text()).toArray()))
arrays.forEach(function(city) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(city[0], city[1]),
map: map,
title: city[2]
});
});
}
})(jQuery);
</script>