Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
b12e87ab
Commit
b12e87ab
authored
10 years ago
by
Charles Benke
Browse files
Options
Downloads
Patches
Plain Diff
Update index.php
add the categories pie graph on product too (and correct some bug)
parent
769c7935
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/product/index.php
+75
-9
75 additions, 9 deletions
htdocs/product/index.php
with
75 additions
and
9 deletions
htdocs/product/index.php
+
75
−
9
View file @
b12e87ab
...
...
@@ -111,9 +111,10 @@ $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
$result
=
$db
->
query
(
$sql
);
while
(
$objp
=
$db
->
fetch_object
(
$result
))
{
$status
=
1
;
$status
=
2
;
if
(
!
$objp
->
tosell
&&
!
$objp
->
tobuy
)
$status
=
0
;
// To sell OR to buy
$prodser
[
$objp
->
fk_product_type
][
$status
]
+=
$objp
->
total
;
if
((
!
$objp
->
tosell
&&
$objp
->
tobuy
)
||
(
$objp
->
tosell
&&
!
$objp
->
tobuy
))
$status
=
1
;
$prodser
[
$objp
->
fk_product_type
][
$status
]
=
$objp
->
total
;
}
print
'<table class="noborder" width="100%">'
;
...
...
@@ -124,40 +125,105 @@ if (! empty($conf->product->enabled))
$statProducts
.
=
'<td><a href="liste.php?type=0&tosell=0&tobuy=0">'
.
$langs
->
trans
(
"ProductsNotOnSell"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
0
][
0
])
.
'</td>'
;
$statProducts
.
=
"</tr>"
;
$statProducts
.
=
"<tr "
.
$bc
[
1
]
.
">"
;
$statProducts
.
=
'<td><a href="liste.php?type=0
&tosell=1
">'
.
$langs
->
trans
(
"ProductsOnSell"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
0
][
1
])
.
'</td>'
;
$statProducts
.
=
'<td><a href="liste.php?type=0">'
.
$langs
->
trans
(
"ProductsOnSell"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
0
][
1
])
.
'</td>'
;
$statProducts
.
=
"</tr>"
;
$statProducts
.
=
"<tr "
.
$bc
[
0
]
.
">"
;
$statProducts
.
=
'<td><a href="liste.php?type=0&tosell=1&tobuy=1">'
.
$langs
->
trans
(
"ProductsOnSellAndOnBuy"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
0
][
2
])
.
'</td>'
;
$statProducts
.
=
"</tr>"
;
}
if
(
!
empty
(
$conf
->
service
->
enabled
))
{
$statServices
=
"<tr "
.
$bc
[
0
]
.
">"
;
$statServices
=
"<tr "
.
$bc
[
1
]
.
">"
;
$statServices
.
=
'<td><a href="liste.php?type=1&tosell=0&tobuy=0">'
.
$langs
->
trans
(
"ServicesNotOnSell"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
1
][
0
])
.
'</td>'
;
$statServices
.
=
"</tr>"
;
$statServices
.
=
"<tr "
.
$bc
[
0
]
.
">"
;
$statServices
.
=
'<td><a href="liste.php?type=1">'
.
$langs
->
trans
(
"ServicesOnSell"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
1
][
1
])
.
'</td>'
;
$statServices
.
=
"</tr>"
;
$statServices
.
=
"<tr "
.
$bc
[
1
]
.
">"
;
$statServices
.
=
'<td><a href="liste.php?type=1&tosell=1">'
.
$langs
->
trans
(
"ServicesOnSell"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
1
][
1
])
.
'</td>'
;
$statServices
.
=
'<td><a href="liste.php?type=1&tosell=1
&tobuy=1
">'
.
$langs
->
trans
(
"ServicesOnSell
AndOnBuy
"
)
.
'</a></td><td align="right">'
.
round
(
$prodser
[
1
][
2
])
.
'</td>'
;
$statServices
.
=
"</tr>"
;
}
$total
=
0
;
if
(
$type
==
'0'
)
{
print
$statProducts
;
$total
=
round
(
$prodser
[
0
][
0
])
+
round
(
$prodser
[
0
][
1
]);
$total
=
round
(
$prodser
[
0
][
0
])
+
round
(
$prodser
[
0
][
1
])
+
round
(
$prodser
[
0
][
2
])
;
}
else
if
(
$type
==
'1'
)
{
print
$statServices
;
$total
=
round
(
$prodser
[
1
][
0
])
+
round
(
$prodser
[
1
][
1
]);
$total
=
round
(
$prodser
[
1
][
0
])
+
round
(
$prodser
[
1
][
1
])
+
round
(
$prodser
[
1
][
2
])
;
}
else
{
print
$statProducts
.
$statServices
;
$total
=
round
(
$prodser
[
1
][
0
])
+
round
(
$prodser
[
1
][
1
])
+
round
(
$prodser
[
0
][
0
])
+
round
(
$prodser
[
0
][
1
]);
$total
=
round
(
$prodser
[
1
][
0
])
+
round
(
$prodser
[
1
][
1
])
+
round
(
$prodser
[
1
][
2
])
+
round
(
$prodser
[
0
][
0
])
+
round
(
$prodser
[
0
][
1
])
+
round
(
$prodser
[
0
][
2
])
;
}
print
'<tr class="liste_total"><td>'
.
$langs
->
trans
(
"Total"
)
.
'</td><td align="right">'
;
print
$total
;
print
'</td></tr>'
;
print
'</table>'
;
if
(
!
empty
(
$conf
->
categorie
->
enabled
))
{
require_once
DOL_DOCUMENT_ROOT
.
'/categories/class/categorie.class.php'
;
print
'<br>'
;
print
'<table class="noborder" width="100%">'
;
print
'<tr class="liste_titre"><th colspan="2">'
.
$langs
->
trans
(
"Categories"
)
.
'</th></tr>'
;
print
'<tr><td align="center">'
;
$sql
=
"SELECT c.label, count(*) as nb"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"categorie_product as cs"
;
$sql
.
=
" LEFT JOIN "
.
MAIN_DB_PREFIX
.
"categorie as c ON cs.fk_categorie = c.rowid"
;
$sql
.
=
" WHERE c.type = 0"
;
$sql
.
=
" AND c.entity IN ("
.
getEntity
(
'category'
,
1
)
.
")"
;
$sql
.
=
" GROUP BY c.label"
;
$total
=
0
;
$result
=
$db
->
query
(
$sql
);
if
(
$result
)
{
$num
=
$db
->
num_rows
(
$result
);
$i
=
0
;
if
(
!
empty
(
$conf
->
use_javascript_ajax
))
{
$dataseries
=
array
();
$rest
=
0
;
$nbmax
=
10
;
while
(
$i
<
$num
)
{
$obj
=
$db
->
fetch_object
(
$result
);
if
(
$i
<
$nbmax
)
$dataseries
[]
=
array
(
'label'
=>
$obj
->
label
,
'data'
=>
round
(
$obj
->
nb
));
else
$rest
+=
$obj
->
nb
;
$total
+=
$obj
->
nb
;
$i
++
;
}
if
(
$i
>
$nbmax
)
$dataseries
[]
=
array
(
'label'
=>
$langs
->
trans
(
"Other"
),
'data'
=>
round
(
$rest
));
$data
=
array
(
'series'
=>
$dataseries
);
dol_print_graph
(
'statscategproduct'
,
300
,
180
,
$data
,
1
,
'pie'
,
0
);
}
else
{
$var
=
true
;
while
(
$i
<
$num
)
{
$obj
=
$db
->
fetch_object
(
$result
);
$var
=!
$var
;
print
'<tr $bc[$var]><td>'
.
$obj
->
label
.
'</td><td>'
.
$obj
->
nb
.
'</td></tr>'
;
$total
+=
$obj
->
nb
;
$i
++
;
}
}
}
print
'</td></tr>'
;
print
'<tr class="liste_total"><td>'
.
$langs
->
trans
(
"Total"
)
.
'</td><td align="right">'
;
print
$total
;
print
'</td></tr>'
;
print
'</table>'
;
}
print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment