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
ca6fd04a
Commit
ca6fd04a
authored
15 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Fix: uniformize code
parent
ba32176b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/product.class.php
+51
-43
51 additions, 43 deletions
htdocs/product.class.php
with
51 additions
and
43 deletions
htdocs/product.class.php
+
51
−
43
View file @
ca6fd04a
...
@@ -545,6 +545,7 @@ class Product extends CommonObject
...
@@ -545,6 +545,7 @@ class Product extends CommonObject
function
setMultiLangs
()
function
setMultiLangs
()
{
{
global
$langs
;
global
$langs
;
$langs_available
=
$langs
->
get_available_languages
();
$langs_available
=
$langs
->
get_available_languages
();
$current_lang
=
$langs
->
getDefaultLang
();
$current_lang
=
$langs
->
getDefaultLang
();
...
@@ -609,6 +610,7 @@ class Product extends CommonObject
...
@@ -609,6 +610,7 @@ class Product extends CommonObject
function
getMultiLangs
(
$langue
=
''
)
function
getMultiLangs
(
$langue
=
''
)
{
{
global
$langs
;
global
$langs
;
$langs_available
=
$langs
->
get_available_languages
();
$langs_available
=
$langs
->
get_available_languages
();
if
(
$langue
!=
''
)
if
(
$langue
!=
''
)
...
@@ -1533,45 +1535,44 @@ class Product extends CommonObject
...
@@ -1533,45 +1535,44 @@ class Product extends CommonObject
}
}
/**
/**
* \brief
r
etire le lien entre un sousproduit et un produit/service
* \brief
R
etire le lien entre un sousproduit et un produit/service
* \param
id
_p
e
re
Id du produit auquel ne sera plus li
�
le produit li
* \param
fk
_p
a
re
nt
Id du produit auquel ne sera plus li
e
le produit li
e
* \param
id_fils
Id du produit
�
ne plus li
* \param
fk_child
Id du produit
a
ne plus li
e
* \return int < 0 si erreur, > 0 si ok
* \return int < 0 si erreur, > 0 si ok
*/
*/
function
del_sousproduit
(
$
id
_p
e
re
,
$
id_f
il
s
)
function
del_sousproduit
(
$
fk
_p
a
re
nt
,
$
fk_ch
il
d
)
{
{
$sql
=
'delete from '
.
MAIN_DB_PREFIX
.
'product_association'
;
$sql
=
"DELETE FROM "
.
MAIN_DB_PREFIX
.
"product_association"
;
$sql
.
=
' WHERE fk_product_pere = "'
.
$id_pere
.
'" and fk_product_fils = "'
.
$id_fils
.
'"'
;
$sql
.
=
" WHERE fk_product_pere = '"
.
$fk_parent
.
"'"
;
$sql
.
=
" AND fk_product_fils = '"
.
$fk_child
.
"'"
;
if
(
!
$this
->
db
->
query
(
$sql
))
if
(
!
$this
->
db
->
query
(
$sql
))
{
{
dol_print_error
(
$this
->
db
);
dol_print_error
(
$this
->
db
);
return
-
1
;
return
-
1
;
}
}
else
return
1
;
return
1
;
}
}
/**
/**
* \brief
retire le lien entre
un sousproduit
et un produit/service
* \brief
Verifie si c'est
un sous
-
produit
* \param
id
_p
e
re
Id du produit auquel
ne sera plus li�
le produit li
* \param
fk
_p
a
re
nt
Id du produit auquel le produit
est
li
e
* \param
id_fils
Id du produit
� ne plus
li
* \param
fk_child
Id du produit li
e
* \return int < 0 si erreur, > 0 si ok
* \return int < 0 si erreur, > 0 si ok
*/
*/
function
is_sousproduit
(
$id_pere
,
$id_fils
)
function
is_sousproduit
(
$fk_parent
,
$fk_child
)
{
$sql
=
'select fk_product_pere,qty from '
.
MAIN_DB_PREFIX
.
'product_association'
;
$sql
.
=
' WHERE fk_product_pere = "'
.
$id_pere
.
'" and fk_product_fils = "'
.
$id_fils
.
'"'
;
if
(
!
$this
->
db
->
query
(
$sql
))
{
dol_print_error
(
$this
->
db
);
return
-
1
;
}
else
{
{
$sql
=
"SELECT fk_product_pere, qty"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"product_association"
;
$sql
.
=
" WHERE fk_product_pere = '"
.
$fk_parent
.
"'"
;
$sql
.
=
" AND fk_product_fils = '"
.
$fk_child
.
"'"
;
$result
=
$this
->
db
->
query
(
$sql
);
$result
=
$this
->
db
->
query
(
$sql
);
if
(
$result
)
if
(
$result
)
{
{
$num
=
$this
->
db
->
num_rows
(
$result
);
$num
=
$this
->
db
->
num_rows
(
$result
);
if
(
$num
>
0
)
if
(
$num
>
0
)
{
{
$obj
=
$this
->
db
->
fetch_object
(
$result
);
$obj
=
$this
->
db
->
fetch_object
(
$result
);
...
@@ -1580,9 +1581,15 @@ class Product extends CommonObject
...
@@ -1580,9 +1581,15 @@ class Product extends CommonObject
return
true
;
return
true
;
}
}
else
else
{
return
false
;
return
false
;
}
}
}
}
else
{
dol_print_error
(
$this
->
db
);
return
-
1
;
}
}
}
/**
/**
...
@@ -1594,8 +1601,9 @@ class Product extends CommonObject
...
@@ -1594,8 +1601,9 @@ class Product extends CommonObject
$this
->
subproducts_id
=
array
();
$this
->
subproducts_id
=
array
();
$i
=
0
;
$i
=
0
;
$sql
=
"SELECT fk_product_subproduct FROM "
.
MAIN_DB_PREFIX
.
"product_subproduct"
;
$sql
=
"SELECT fk_product_subproduct"
;
$sql
.
=
" WHERE fk_product=
$this->id
;"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"product_subproduct"
;
$sql
.
=
" WHERE fk_product = "
.
$this
->
id
;
if
(
$result
=
$this
->
db
->
query
(
$sql
))
if
(
$result
=
$this
->
db
->
query
(
$sql
))
{
{
...
@@ -1616,7 +1624,7 @@ class Product extends CommonObject
...
@@ -1616,7 +1624,7 @@ class Product extends CommonObject
/**
/**
* \brief Lie un sous produit au produit/service
* \brief Lie un sous produit au produit/service
* \param id_sub Id du produit
�
lier
* \param id_sub Id du produit
a
lier
* \return int < 0 si erreur, > 0 si ok
* \return int < 0 si erreur, > 0 si ok
*/
*/
function
add_subproduct
(
$id_sub
)
function
add_subproduct
(
$id_sub
)
...
...
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