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
97fd4dd7
Commit
97fd4dd7
authored
Dec 05, 2014
by
Cédric Houbart
Browse files
Sort inventory by categories (and add some data escaping)
parent
83f9fba0
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/base_stocks/actions/inventory.php
View file @
97fd4dd7
...
...
@@ -42,11 +42,24 @@ if (isset($_POST['location'])) {
$currLocation
=
$locations
[
0
]
->
id
;
}
$products
=
\
Pasteque\ProductsService
::
getAll
(
true
);
$categories
=
\
Pasteque\CategoriesService
::
getAll
();
$prdCat
=
array
();
// Link products to categories and don't track compositions
foreach
(
$products
as
$product
)
{
if
(
$product
->
categoryId
!==
\
Pasteque\CompositionsService
::
CAT_ID
)
{
$prdCat
[
$product
->
categoryId
][]
=
$product
;
}
}
$levels
=
\
Pasteque\StocksService
::
getLevels
(
$currLocation
);
$prdLevel
=
array
();
foreach
(
$levels
as
$level
)
{
$prdLevel
[
$level
->
productId
]
=
$level
;
}
?>
<h1>
<?php
\
pi18n
(
"Inventory"
,
PLUGIN_NAME
);
?>
</h1>
<?php
if
(
$multilocations
)
{
?>
<?php
if
(
$multilocations
)
{
// Location picker ?>
<
form
class
=
"edit"
action
=
"<?php echo \Pasteque\get_current_url(); ?>"
method
=
"post"
>
<
div
class
=
"row"
>
<?
php
\
Pasteque\form_select
(
"location"
,
\
i18n
(
"Location"
),
$locIds
,
$locNames
,
$currLocation
);
?>
...
...
@@ -55,8 +68,14 @@ $levels = \Pasteque\StocksService::getLevels($currLocation);
<?php
\
Pasteque\form_send
();
?>
</div>
</form>
<?php
}
?>
<?php
}
$par
=
false
;
foreach
(
$categories
as
$category
)
{
if
(
isset
(
$prdCat
[
$category
->
id
]))
{
// Category header ?>
<
h3
><?
php
echo
\
Pasteque\esc_html
(
$category
->
label
);
?>
</h3>
<table
cellpadding=
"0"
cellspacing=
"0"
>
<thead>
<tr>
...
...
@@ -68,49 +87,49 @@ $levels = \Pasteque\StocksService::getLevels($currLocation);
</thead>
<tbody>
<?php
$par
=
FALSE
;
foreach
(
$levels
as
$level
)
{
$par
=
!
$par
;
$prdRef
=
""
;
$prdLabel
=
""
;
$imgSrc
=
""
;
foreach
(
$products
as
$product
)
{
if
(
$product
->
id
==
$level
->
productId
)
{
$prdLabel
=
$product
->
label
;
$prdRef
=
$product
->
reference
;
if
(
$product
->
hasImage
)
{
$imgSrc
=
\
Pasteque\PT
::
URL_ACTION_PARAM
.
"=img&w=product&id="
.
$product
->
id
;
}
else
{
$imgSrc
=
\
Pasteque\PT
::
URL_ACTION_PARAM
.
"=img&w=product"
;
}
break
;
}
}
$security
=
$level
->
security
;
$max
=
$level
->
max
;
$qty
=
$level
->
qty
!==
null
?
$level
->
qty
:
0
;
$class
=
""
;
$help
=
""
;
if
(
$security
!==
NULL
&&
$qty
<
$security
)
{
$class
=
" warn-level"
;
$help
=
' title="'
.
\
i18n
(
"Stock is below security level!"
,
PLUGIN_NAME
)
.
'"'
;
}
if
(
$qty
<
0
)
{
$class
=
" alert-level"
;
$help
=
' title="'
.
\
i18n
(
"Stock is negative!"
,
PLUGIN_NAME
)
.
'"'
;
}
else
if
(
$max
!==
NULL
&&
$qty
>
$max
)
{
$class
=
" alert-level"
;
$help
=
' title="'
.
\
i18n
(
"Overstock!"
,
PLUGIN_NAME
)
.
'"'
;
}
?>
<tr
class=
"row-
<?php
echo
$par
?
'par'
:
'odd'
;
?>
"
>
<td><img
class=
"thumbnail"
src=
"?
<?php
echo
$imgSrc
?>
"
/>
<td>
<?php
echo
$prdRef
;
?>
</td>
<td>
<?php
echo
$prdLabel
;
?>
</td>
<td
class=
"numeric
<?php
echo
$class
;
?>
"
<?php
echo
$help
;
?>
>
<?php
echo
$qty
;
?>
</td>
</tr>
foreach
(
$prdCat
[
$category
->
id
]
as
$product
)
{
if
(
!
isset
(
$prdLevel
[
$product
->
id
]))
{
continue
;
}
// Level lines
$par
=
!
$par
;
$prdRef
=
""
;
$prdLabel
=
""
;
$imgSrc
=
""
;
$level
=
$prdLevel
[
$product
->
id
];
if
(
$product
->
hasImage
)
{
$imgSrc
=
\
Pasteque\PT
::
URL_ACTION_PARAM
.
"=img&w=product&id="
.
$product
->
id
;
}
else
{
$imgSrc
=
\
Pasteque\PT
::
URL_ACTION_PARAM
.
"=img&w=product"
;
}
$prdLabel
=
$product
->
label
;
$prdRef
=
$product
->
reference
;
$security
=
$level
->
security
;
$max
=
$level
->
max
;
$qty
=
$level
->
qty
!==
null
?
$level
->
qty
:
0
;
$class
=
""
;
$help
=
""
;
if
(
$security
!==
null
&&
$qty
<
$security
)
{
$class
=
" warn-level"
;
$help
=
' title="'
.
\
Pasteque\esc_attr
(
\
i18n
(
"Stock is below security level!"
,
PLUGIN_NAME
))
.
'"'
;
}
if
(
$qty
<
0
)
{
$class
=
" alert-level"
;
$help
=
' title="'
.
\
Pasteque\esc_attr
(
\
i18n
(
"Stock is negative!"
,
PLUGIN_NAME
))
.
'"'
;
}
else
if
(
$max
!==
NULL
&&
$qty
>
$max
)
{
$class
=
" alert-level"
;
$help
=
' title="'
.
\
Pasteque\esc_attr
(
\
i18n
(
"Overstock!"
,
PLUGIN_NAME
))
.
'"'
;
}
?>
<tr
class=
"row-
<?php
echo
$par
?
'par'
:
'odd'
;
?>
"
>
<td><img
class=
"thumbnail"
src=
"?
<?php
echo
\
Pasteque\esc_attr
(
$imgSrc
);
?>
"
/>
<td>
<?php
echo
\
Pasteque\esc_html
(
$prdRef
);
?>
</td>
<td>
<?php
echo
\
Pasteque\esc_html
(
$prdLabel
);
?>
</td>
<td
class=
"numeric
<?php
echo
$class
;
?>
"
<?php
echo
$help
;
?>
>
<?php
echo
\
Pasteque\esc_html
(
$qty
);
?>
</td>
</tr>
<?php
}
?>
}
?>
</tbody>
</table>
<?php
}
}
Write
Preview
Supports
Markdown
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