Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
e91645f2
Commit
e91645f2
authored
Oct 06, 2016
by
philippepary
Browse files
Added a auto-creatation of composition category if none exists on composition creation
parent
91d1ab1f
Changes
3
Show whitespace changes
Inline
Side-by-side
inc/data/services/CategoriesService.php
View file @
e91645f2
...
...
@@ -129,6 +129,10 @@ class CategoriesService {
}
}
static
function
create
(
$cat
,
$image
=
null
)
{
CategoriesService
::
createCat
(
$cat
,
$image
);
}
static
function
createCat
(
$cat
,
$image
=
null
)
{
$pdo
=
PDOBuilder
::
getPDO
();
$id
=
md5
(
time
()
.
rand
());
...
...
inc/data/services/CompositionsService.php
View file @
e91645f2
...
...
@@ -43,6 +43,20 @@ class CompositionsService {
return
$compo
;
}
/** Check if a composition category exists
Create it if not */
static
function
checkCategory
()
{
if
(
CategoriesService
::
get
(
CompositionsService
::
CAT_ID
)
===
null
)
{
$compositionsCategory
=
\
Pasteque\Category
::
__build
(
CompositionsService
::
CAT_ID
,
"COMPOSITIONS"
,
""
,
"Compositions"
,
false
,
99
);
if
(
!
CategoriesService
::
create
(
$compositionsCategory
))
{
return
true
;
}
}
return
true
;
}
/** Return an array of composition */
static
function
getAll
()
{
$compos
=
array
();
...
...
@@ -105,6 +119,7 @@ class CompositionsService {
}
static
function
update
(
$composition
,
$img
=
""
,
$groupImgs
)
{
CompositionsService
::
checkCategory
();
if
(
$composition
->
id
===
null
)
{
return
false
;
}
...
...
@@ -143,6 +158,7 @@ class CompositionsService {
}
static
function
create
(
$composition
,
$img
,
$groupImgs
)
{
CompositionsService
::
checkCategory
();
$pdo
=
PDOBuilder
::
getPDO
();
$newTransaction
=
!
$pdo
->
inTransaction
();
if
(
$newTransaction
)
{
...
...
modules/product_compositions/actions/composition_edit.php
View file @
e91645f2
...
...
@@ -183,7 +183,7 @@ $row .= "<select id=\"listSubGr\" onchange=\"showSubgroup();\"></select>\n";
$displayData
=
\
Pasteque\row
(
$row
);
$content
.
=
\
Pasteque\form_fieldset
(
$legend
,
$displayData
);
$content
.
=
\
Pasteque\form_text
(
"edit-sgName"
,
null
,
\
i18n
(
"Subgroup.label"
),
null
,
"javascript:editSubgroup();"
);
$content
.
=
\
Pasteque\form_number
(
"edit-sgOrder"
,
null
,
\
i18n
(
"Subgroup.dispOrder"
),
1
,
0
);
$content
.
=
\
Pasteque\form_number
(
"edit-sgOrder"
,
0
,
\
i18n
(
"Subgroup.dispOrder"
),
1
,
0
);
$buttons
=
\
Pasteque\jsAddButton
(
\
i18n
(
"Add subgroup"
,
PLUGIN_NAME
),
"newSubgroup();"
);
$buttons
.
=
\
Pasteque\jsDeleteButton
(
\
i18n
(
"Delete subgroup"
,
PLUGIN_NAME
),
"delSubgroup();"
);
$content
.
=
\
Pasteque\buttonGroup
(
$buttons
);
...
...
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