Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
potage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
potage
Commits
55df0f3c
Commit
55df0f3c
authored
Jul 27, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Insertion de l'offre dans la lettre, au milieu des infos sortables
parent
10bf134e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
71 deletions
+136
-71
src/APIBundle/Controller/LettreAPIController.php
src/APIBundle/Controller/LettreAPIController.php
+11
-0
src/APIBundle/Resources/config/routing.yml
src/APIBundle/Resources/config/routing.yml
+7
-0
src/PotageBundle/Entity/Lettre.php
src/PotageBundle/Entity/Lettre.php
+2
-2
src/PotageBundle/Entity/Offre.php
src/PotageBundle/Entity/Offre.php
+2
-2
src/PotageBundle/Entity/OffreLegumes.php
src/PotageBundle/Entity/OffreLegumes.php
+17
-2
src/PotageBundle/Repository/LettreRepository.php
src/PotageBundle/Repository/LettreRepository.php
+15
-1
src/PotageBundle/Resources/views/LettreInfos/ajaxDisplay.js
src/PotageBundle/Resources/views/LettreInfos/ajaxDisplay.js
+25
-8
src/PotageBundle/Resources/views/OffreLegumes/ajaxDisplay.js
src/PotageBundle/Resources/views/OffreLegumes/ajaxDisplay.js
+0
-56
web/js/ajax_functions.js
web/js/ajax_functions.js
+57
-0
No files found.
src/APIBundle/Controller/LettreAPIController.php
View file @
55df0f3c
...
...
@@ -261,4 +261,15 @@ class LettreAPIController extends MasterAPIController
return
$this
->
api
(
$legumes
);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public
function
readOffreLegumesAction
(
$id
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$legumes
=
$em
->
getRepository
(
'PotageBundle:Lettre'
)
->
findAllOffreLegumes
(
$id
);
return
$this
->
api
(
$legumes
,
200
,
array
(
'readOffreLegumes'
));
}
}
src/APIBundle/Resources/config/routing.yml
View file @
55df0f3c
...
...
@@ -252,6 +252,13 @@ api_lettre_count_legumes:
_controller
:
APIBundle:LettreAPI:countLegumes
methods
:
[
GET
]
api_lettre_offre_legumes_read
:
path
:
/lettre/{id}/offre/legumes
requirements
:
id
:
\d+
defaults
:
_controller
:
APIBundle:LettreAPI:readOffreLegumes
methods
:
[
GET
]
## CRUD InfoAPI
...
...
src/PotageBundle/Entity/Lettre.php
View file @
55df0f3c
...
...
@@ -21,7 +21,7 @@ class Lettre
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"readLettres"})
* @Serializer\Groups({"readLettres"
, "readOffreLegumes"
})
*/
private
$id
;
...
...
@@ -29,7 +29,7 @@ class Lettre
* @var int
* @ORM\ManyToOne(targetEntity="PotageBundle\Entity\Offre", inversedBy="lettres")
* @ORM\JoinColumn(name="id_offre", nullable=false)
* @Serializer\Groups({"readLettres"})
* @Serializer\Groups({"readLettres"
, "readOffreLegumes"
})
*/
private
$offre
;
...
...
src/PotageBundle/Entity/Offre.php
View file @
55df0f3c
...
...
@@ -22,14 +22,14 @@ class Offre
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"readLettres", "readOffres"})
* @Serializer\Groups({"readLettres", "readOffres"
, "readOffreLegumes"
})
*/
private
$id
;
/**
* @var OffreLegumes[]
* @ORM\OneToMany(targetEntity="PotageBundle\Entity\OffreLegumes", mappedBy="offre")
* @Serializer\Groups({"readOffres"})
* @Serializer\Groups({"readOffres"
, "readOffreLegumes"
})
*/
private
$offreLegumes
;
...
...
src/PotageBundle/Entity/OffreLegumes.php
View file @
55df0f3c
...
...
@@ -25,7 +25,7 @@ class OffreLegumes
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Serializer\Groups({"readOffres"})
* @Serializer\Groups({"readOffres"
, "readOffreLegumes"
})
*/
private
$id
;
...
...
@@ -47,6 +47,7 @@ class OffreLegumes
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$createdAt
;
...
...
@@ -54,6 +55,7 @@ class OffreLegumes
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$updatedAt
;
...
...
@@ -61,7 +63,7 @@ class OffreLegumes
* @var string
*
* @ORM\Column(name="nom", type="string", length=100)
* @Serializer\Groups({"readOffres"})
* @Serializer\Groups({"readOffres"
, "readOffreLegumes"
})
*/
private
$nom
;
...
...
@@ -69,18 +71,21 @@ class OffreLegumes
* @var string
*
* @ORM\Column(name="description", type="text")
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$description
;
/**
* @var boolean
* @ORM\Column(name="is_fruit", type="boolean")
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$fruit
;
/**
* @var boolean
* @ORM\Column(name="is_revente", type="boolean")
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$revente
;
...
...
@@ -88,6 +93,7 @@ class OffreLegumes
* @var string
*
* @ORM\Column(name="origine", type="string", length=100, nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$origine
;
...
...
@@ -95,6 +101,7 @@ class OffreLegumes
* @var float
*
* @ORM\Column(name="prix_unitaire", type="float")
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$prixUnitaire
;
...
...
@@ -102,6 +109,7 @@ class OffreLegumes
* @var string
*
* @ORM\Column(name="unite", type="string", length=25)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$unite
;
...
...
@@ -109,6 +117,7 @@ class OffreLegumes
* @var float
*
* @ORM\Column(name="quantite_min", type="float", nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$quantiteMin
;
...
...
@@ -116,6 +125,7 @@ class OffreLegumes
* @var float
*
* @ORM\Column(name="quantite_max", type="float", nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$quantiteMax
;
...
...
@@ -123,12 +133,14 @@ class OffreLegumes
* @var float
*
* @ORM\Column(name="quantite_step", type="float", nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$quantiteStep
;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$image
;
...
...
@@ -142,6 +154,7 @@ class OffreLegumes
* @var float
*
* @ORM\Column(name="volume_max", type="float", nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$volumeMax
;
...
...
@@ -149,6 +162,7 @@ class OffreLegumes
* @var bool
*
* @ORM\Column(name="is_promo", type="boolean")
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$isPromo
;
...
...
@@ -156,6 +170,7 @@ class OffreLegumes
* @var string
*
* @ORM\Column(name="promo", type="string", length=100, nullable=true)
* @Serializer\Groups({"readOffreLegumes"})
*/
private
$promo
;
...
...
src/PotageBundle/Repository/LettreRepository.php
View file @
55df0f3c
...
...
@@ -192,6 +192,20 @@ class LettreRepository extends \Doctrine\ORM\EntityRepository
->
where
(
'l.id = :id'
)
->
setParameter
(
':id'
,
$id
);
return
$qb
->
getQuery
()
->
getSingleScalarResult
();
}
/**
* @param $id
* @return array
*/
public
function
findAllOffreLegumes
(
$id
)
{
$qb
=
$this
->
createQueryBuilder
(
'l'
)
->
join
(
'l.offre'
,
'o'
)
->
join
(
'o.offreLegumes'
,
'ol'
)
->
where
(
'l.id = :id'
)
->
setParameter
(
':id'
,
$id
);
return
$qb
->
getQuery
()
->
getResult
();
}
}
src/PotageBundle/Resources/views/LettreInfos/ajaxDisplay.js
100644 → 100755
View file @
55df0f3c
...
...
@@ -46,7 +46,13 @@ function insertOffre()
{
if
(
parseInt
(
order
[
i
])
===
-
1
)
{
let
offre
=
getDisplayOffreLegumes
(
id_lettre
);
let
offre
=
document
.
createElement
(
'
div
'
);
offre
.
classList
.
add
(
'
ui-state-default
'
,
'
info
'
,
'
offre
'
);
offre
.
id
=
'
offre
'
;
offre
.
dataset
.
infoId
=
-
1
;
getDisplayOffreLegumes
(
id_lettre
);
sortable
.
insertBefore
(
offre
,
infoItem
[
i
]);
}
...
...
@@ -61,15 +67,26 @@ function insertOffre()
*/
function
getDisplayOffreLegumes
(
id_lettre
)
{
//console.log(id_lettre);
let
URL
=
Routing
.
generate
(
'
api_lettre_offre_legumes_read
'
,
{
'
id
'
:
id_lettre
});
AJAX
(
'
GET
'
,
URL
,
function
(
request
)
{
let
offre
=
document
.
querySelector
(
'
div#offre
'
);
let
div
=
document
.
createElement
(
'
div
'
);
div
.
classList
.
add
(
'
ui-state-default
'
,
'
info
'
,
'
offre
'
);
div
.
dataset
.
infoId
=
-
1
;
div
.
textContent
=
"
OFFRE DE LEGUMES, liée à la lettre
"
+
id_lettre
;
//displayPeriodAndOffre(json)
let
json
=
JSON
.
parse
(
request
.
responseText
);
let
jsonLegumes
=
json
[
0
].
offre
.
offre_legumes
;
return
div
;
for
(
let
i
=
0
;
i
<
jsonLegumes
.
length
;
i
++
)
{
let
div
=
buildItemOffreLegumes
(
jsonLegumes
[
i
]);
//console.log(div);
//console.log(offre);
offre
.
appendChild
(
div
);
}
});
}
...
...
src/PotageBundle/Resources/views/OffreLegumes/ajaxDisplay.js
View file @
55df0f3c
...
...
@@ -22,62 +22,6 @@ function reloadGridLegumes()
}
/*
* Construit une rangée du tableau des Offres
* @param json object jsonRow
*/
function
buildItemOffreLegumes
(
jsonRow
)
{
//console.log(jsonRow);
let
div
=
document
.
createElement
(
'
div
'
);
div
.
classList
.
add
(
'
ui-state-default
'
,
'
legume
'
);
div
.
dataset
.
legumeId
=
jsonRow
.
id
;
let
logo
=
document
.
createElement
(
'
div
'
);
logo
.
classList
.
add
(
'
logo
'
,
'
lg
'
);
let
crop
=
document
.
createElement
(
'
div
'
);
crop
.
classList
.
add
(
'
crop
'
);
let
img
=
document
.
createElement
(
'
img
'
);
img
.
setAttribute
(
'
src
'
,
'
/web/uploads/images/legumes/
'
+
jsonRow
.
image
);
crop
.
appendChild
(
img
);
logo
.
appendChild
(
crop
);
div
.
appendChild
(
logo
);
let
texte
=
document
.
createElement
(
'
div
'
);
texte
.
classList
.
add
(
'
texte
'
);
let
title
=
document
.
createElement
(
'
h5
'
);
title
.
innerHTML
=
jsonRow
.
nom
;
texte
.
appendChild
(
title
);
div
.
appendChild
(
texte
);
let
dprix
=
document
.
createElement
(
'
div
'
);
dprix
.
classList
.
add
(
'
prix
'
);
let
prix
=
document
.
createElement
(
'
span
'
);
prix
.
classList
.
add
(
'
prix
'
);
prix
.
textContent
=
jsonRow
.
prixUnitaire
;
dprix
.
appendChild
(
prix
);
let
devise
=
document
.
createElement
(
'
span
'
);
devise
.
classList
.
add
(
'
devise
'
);
devise
.
textContent
=
'
€
'
;
dprix
.
appendChild
(
devise
);
let
unite
=
document
.
createElement
(
'
span
'
);
unite
.
classList
.
add
(
'
unite
'
);
unite
.
textContent
=
'
/
'
+
jsonRow
.
unite
;
dprix
.
appendChild
(
unite
);
div
.
appendChild
(
dprix
);
return
div
;
}
/*
* =================================
...
...
web/js/ajax_functions.js
View file @
55df0f3c
...
...
@@ -330,6 +330,63 @@ function countLegumes(lettre)
}
/*
* Construit une rangée du tableau des Offres
* @param json object jsonRow
*/
function
buildItemOffreLegumes
(
jsonRow
)
{
console
.
log
(
jsonRow
);
let
div
=
document
.
createElement
(
'
div
'
);
div
.
classList
.
add
(
'
ui-state-default
'
,
'
legume
'
);
div
.
dataset
.
legumeId
=
jsonRow
.
id
;
let
logo
=
document
.
createElement
(
'
div
'
);
logo
.
classList
.
add
(
'
logo
'
,
'
lg
'
);
let
crop
=
document
.
createElement
(
'
div
'
);
crop
.
classList
.
add
(
'
crop
'
);
let
img
=
document
.
createElement
(
'
img
'
);
img
.
setAttribute
(
'
src
'
,
'
/web/uploads/images/legumes/
'
+
jsonRow
.
image
);
crop
.
appendChild
(
img
);
logo
.
appendChild
(
crop
);
div
.
appendChild
(
logo
);
let
texte
=
document
.
createElement
(
'
div
'
);
texte
.
classList
.
add
(
'
texte
'
);
let
title
=
document
.
createElement
(
'
h5
'
);
title
.
innerHTML
=
jsonRow
.
nom
;
texte
.
appendChild
(
title
);
div
.
appendChild
(
texte
);
let
dprix
=
document
.
createElement
(
'
div
'
);
dprix
.
classList
.
add
(
'
prix
'
);
let
prix
=
document
.
createElement
(
'
span
'
);
prix
.
classList
.
add
(
'
prix
'
);
prix
.
textContent
=
jsonRow
.
prixUnitaire
;
dprix
.
appendChild
(
prix
);
let
devise
=
document
.
createElement
(
'
span
'
);
devise
.
classList
.
add
(
'
devise
'
);
devise
.
textContent
=
'
€
'
;
dprix
.
appendChild
(
devise
);
let
unite
=
document
.
createElement
(
'
span
'
);
unite
.
classList
.
add
(
'
unite
'
);
unite
.
textContent
=
'
/
'
+
jsonRow
.
unite
;
dprix
.
appendChild
(
unite
);
div
.
appendChild
(
dprix
);
return
div
;
}
/*
* F O N C T I O N S A J A X
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment