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
ba422615
Commit
ba422615
authored
8 years ago
by
florian HENRY
Browse files
Options
Downloads
Patches
Plain Diff
better trigger management on supplier order
parent
888c8005
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/fourn/class/fournisseur.commande.class.php
+81
-21
81 additions, 21 deletions
htdocs/fourn/class/fournisseur.commande.class.php
with
81 additions
and
21 deletions
htdocs/fourn/class/fournisseur.commande.class.php
+
81
−
21
View file @
ba422615
...
...
@@ -1987,28 +1987,58 @@ class CommandeFournisseur extends CommonOrder
*
* @param User $user Objet user making change
* @param timestamp $date_livraison Planned delivery date
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/
function
set_date_livraison
(
$user
,
$date_livraison
)
function
set_date_livraison
(
$user
,
$date_livraison
,
$notrigger
=
0
)
{
if
(
$user
->
rights
->
fournisseur
->
commande
->
creer
)
{
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"commande_fournisseur"
;
$error
=
0
;
$this
->
db
->
begin
();
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"commande_fournisseur"
;
$sql
.
=
" SET date_livraison = "
.
(
$date_livraison
?
"'"
.
$this
->
db
->
idate
(
$date_livraison
)
.
"'"
:
'null'
);
$sql
.
=
" WHERE rowid = "
.
$this
->
id
;
dol_syslog
(
get_class
(
$this
)
.
"::set_date_livraison"
,
LOG_DEBUG
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
$resql
)
{
$this
->
date_livraison
=
$date_livraison
;
return
1
;
}
else
{
$this
->
error
=
$this
->
db
->
error
();
return
-
1
;
}
dol_syslog
(
__METHOD__
,
LOG_DEBUG
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
!
$resql
)
{
$this
->
errors
[]
=
$this
->
db
->
error
();
$error
++
;
}
if
(
!
$error
)
{
$this
->
oldcopy
=
clone
$this
;
$this
->
date_livraison
=
$date_livraison
;
}
if
(
!
$notrigger
&&
empty
(
$error
))
{
// Call trigger
$result
=
$this
->
call_trigger
(
'ORDER_SUPPLIER_MODIFY'
,
$user
);
if
(
$result
<
0
)
$error
++
;
// End call triggers
}
if
(
!
$error
)
{
$this
->
db
->
commit
();
return
1
;
}
else
{
foreach
(
$this
->
errors
as
$errmsg
)
{
dol_syslog
(
__METHOD__
.
' Error: '
.
$errmsg
,
LOG_ERR
);
$this
->
error
.
=
(
$this
->
error
?
', '
.
$errmsg
:
$errmsg
);
}
$this
->
db
->
rollback
();
return
-
1
*
$error
;
}
}
else
{
...
...
@@ -2021,27 +2051,57 @@ class CommandeFournisseur extends CommonOrder
*
* @param User $user Objet utilisateur qui modifie
* @param int $id_projet Date de livraison
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 si ko, >0 si ok
*/
function
set_id_projet
(
$user
,
$id_projet
)
function
set_id_projet
(
$user
,
$id_projet
,
$notrigger
=
0
)
{
if
(
$user
->
rights
->
fournisseur
->
commande
->
creer
)
{
$error
=
0
;
$this
->
db
->
begin
();
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"commande_fournisseur"
;
$sql
.
=
" SET fk_projet = "
.
(
$id_projet
>
0
?
(
int
)
$id_projet
:
'null'
);
$sql
.
=
" WHERE rowid = "
.
$this
->
id
;
dol_syslog
(
get_class
(
$this
)
.
"::set_id_projet"
,
LOG_DEBUG
);
dol_syslog
(
__METHOD__
,
LOG_DEBUG
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
$resql
)
if
(
!
$resql
)
{
$this
->
fk_projet
=
$id_projet
;
return
1
;
$this
->
errors
[]
=
$this
->
db
->
error
();
$error
++
;
}
if
(
!
$error
)
{
$this
->
oldcopy
=
clone
$this
;
$this
->
fk_projet
=
$id_projet
;
}
if
(
!
$notrigger
&&
empty
(
$error
))
{
// Call trigger
$result
=
$this
->
call_trigger
(
'ORDER_SUPPLIER_MODIFY'
,
$user
);
if
(
$result
<
0
)
$error
++
;
// End call triggers
}
if
(
!
$error
)
{
$this
->
db
->
commit
();
return
1
;
}
else
{
$this
->
error
=
$this
->
db
->
error
();
return
-
1
;
foreach
(
$this
->
errors
as
$errmsg
)
{
dol_syslog
(
__METHOD__
.
' Error: '
.
$errmsg
,
LOG_ERR
);
$this
->
error
.
=
(
$this
->
error
?
', '
.
$errmsg
:
$errmsg
);
}
$this
->
db
->
rollback
();
return
-
1
*
$error
;
}
}
else
...
...
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