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
86a06de0
Commit
86a06de0
authored
8 years ago
by
Sof
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
New : add confirm on invoice deletion
Alternatively reformated all code
parent
586b2232
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/compta/facture/fiche-rec.php
+520
-471
520 additions, 471 deletions
htdocs/compta/facture/fiche-rec.php
with
520 additions
and
471 deletions
htdocs/compta/facture/fiche-rec.php
+
520
−
471
View file @
86a06de0
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Meziane Sof <aspangaro.dolibarr@gmail.com>
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
...
@@ -242,9 +243,9 @@ if ($action == 'add')
...
@@ -242,9 +243,9 @@ if ($action == 'add')
}
}
// Delete
// Delete
if
(
$action
==
'
delete
'
&&
$user
->
rights
->
facture
->
supprimer
)
if
(
$action
==
'
confirm_deleteinvoice'
&&
$confirm
==
'yes
'
&&
$user
->
rights
->
facture
->
supprimer
)
{
{
$object
->
delete
(
$user
);
$object
->
delete
();
header
(
"Location: "
.
$_SERVER
[
'PHP_SELF'
]
);
header
(
"Location: "
.
$_SERVER
[
'PHP_SELF'
]
);
exit
;
exit
;
}
}
...
@@ -368,7 +369,8 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -368,7 +369,8 @@ if ($action == 'addline' && $user->rights->facture->creer)
$extralabelsline
=
$extrafieldsline
->
fetch_name_optionals_label
(
$object
->
table_element_line
);
$extralabelsline
=
$extrafieldsline
->
fetch_name_optionals_label
(
$object
->
table_element_line
);
$array_options
=
$extrafieldsline
->
getOptionalsFromPost
(
$extralabelsline
,
$predef
);
$array_options
=
$extrafieldsline
->
getOptionalsFromPost
(
$extralabelsline
,
$predef
);
// Unset extrafield
// Unset extrafield
if
(
is_array
(
$extralabelsline
))
{
if
(
is_array
(
$extralabelsline
))
{
// Get extra fields
// Get extra fields
foreach
(
$extralabelsline
as
$key
=>
$value
)
{
foreach
(
$extralabelsline
as
$key
=>
$value
)
{
unset
(
$_POST
[
"options_"
.
$key
.
$predef
]);
unset
(
$_POST
[
"options_"
.
$key
.
$predef
]);
...
@@ -402,7 +404,8 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -402,7 +404,8 @@ if ($action == 'addline' && $user->rights->facture->creer)
$error
++
;
$error
++
;
}
}
if
(
!
$error
&&
(
$qty
>=
0
)
&&
(
!
empty
(
$product_desc
)
||
!
empty
(
$idprod
)))
{
if
(
!
$error
&&
(
$qty
>=
0
)
&&
(
!
empty
(
$product_desc
)
||
!
empty
(
$idprod
)))
{
$ret
=
$object
->
fetch
(
$id
);
$ret
=
$object
->
fetch
(
$id
);
if
(
$ret
<
0
)
{
if
(
$ret
<
0
)
{
dol_print_error
(
$db
,
$object
->
error
);
dol_print_error
(
$db
,
$object
->
error
);
...
@@ -464,8 +467,10 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -464,8 +467,10 @@ if ($action == 'addline' && $user->rights->facture->creer)
$filter
=
array
(
't.fk_product'
=>
$prod
->
id
,
't.fk_soc'
=>
$object
->
thirdparty
->
id
);
$filter
=
array
(
't.fk_product'
=>
$prod
->
id
,
't.fk_soc'
=>
$object
->
thirdparty
->
id
);
$result
=
$prodcustprice
->
fetch_all
(
''
,
''
,
0
,
0
,
$filter
);
$result
=
$prodcustprice
->
fetch_all
(
''
,
''
,
0
,
0
,
$filter
);
if
(
$result
)
{
if
(
$result
)
if
(
count
(
$prodcustprice
->
lines
)
>
0
)
{
{
if
(
count
(
$prodcustprice
->
lines
)
>
0
)
{
$pu_ht
=
price
(
$prodcustprice
->
lines
[
0
]
->
price
);
$pu_ht
=
price
(
$prodcustprice
->
lines
[
0
]
->
price
);
$pu_ttc
=
price
(
$prodcustprice
->
lines
[
0
]
->
price_ttc
);
$pu_ttc
=
price
(
$prodcustprice
->
lines
[
0
]
->
price_ttc
);
$price_base_type
=
$prodcustprice
->
lines
[
0
]
->
price_base_type
;
$price_base_type
=
$prodcustprice
->
lines
[
0
]
->
price_base_type
;
...
@@ -497,27 +502,32 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -497,27 +502,32 @@ if ($action == 'addline' && $user->rights->facture->creer)
$desc
=
''
;
$desc
=
''
;
// Define output language
// Define output language
if
(
!
empty
(
$conf
->
global
->
MAIN_MULTILANGS
)
&&
!
empty
(
$conf
->
global
->
PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE
))
{
if
(
!
empty
(
$conf
->
global
->
MAIN_MULTILANGS
)
&&
!
empty
(
$conf
->
global
->
PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE
))
{
$outputlangs
=
$langs
;
$outputlangs
=
$langs
;
$newlang
=
''
;
$newlang
=
''
;
if
(
empty
(
$newlang
)
&&
GETPOST
(
'lang_id'
))
if
(
empty
(
$newlang
)
&&
GETPOST
(
'lang_id'
))
$newlang
=
GETPOST
(
'lang_id'
);
$newlang
=
GETPOST
(
'lang_id'
);
if
(
empty
(
$newlang
))
if
(
empty
(
$newlang
))
$newlang
=
$object
->
thirdparty
->
default_lang
;
$newlang
=
$object
->
thirdparty
->
default_lang
;
if
(
!
empty
(
$newlang
))
{
if
(
!
empty
(
$newlang
))
{
$outputlangs
=
new
Translate
(
""
,
$conf
);
$outputlangs
=
new
Translate
(
""
,
$conf
);
$outputlangs
->
setDefaultLang
(
$newlang
);
$outputlangs
->
setDefaultLang
(
$newlang
);
}
}
$desc
=
(
!
empty
(
$prod
->
multilangs
[
$outputlangs
->
defaultlang
]
[
"description"
]))
?
$prod
->
multilangs
[
$outputlangs
->
defaultlang
]
[
"description"
]
:
$prod
->
description
;
$desc
=
(
!
empty
(
$prod
->
multilangs
[
$outputlangs
->
defaultlang
]
[
"description"
]))
?
$prod
->
multilangs
[
$outputlangs
->
defaultlang
]
[
"description"
]
:
$prod
->
description
;
}
else
{
}
else
{
$desc
=
$prod
->
description
;
$desc
=
$prod
->
description
;
}
}
$desc
=
dol_concatdesc
(
$desc
,
$product_desc
);
$desc
=
dol_concatdesc
(
$desc
,
$product_desc
);
// Add custom code and origin country into description
// Add custom code and origin country into description
if
(
empty
(
$conf
->
global
->
MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE
)
&&
(
!
empty
(
$prod
->
customcode
)
||
!
empty
(
$prod
->
country_code
)))
{
if
(
empty
(
$conf
->
global
->
MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE
)
&&
(
!
empty
(
$prod
->
customcode
)
||
!
empty
(
$prod
->
country_code
)))
{
$tmptxt
=
'('
;
$tmptxt
=
'('
;
if
(
!
empty
(
$prod
->
customcode
))
if
(
!
empty
(
$prod
->
customcode
))
$tmptxt
.
=
$langs
->
transnoentitiesnoconv
(
"CustomCode"
)
.
': '
.
$prod
->
customcode
;
$tmptxt
.
=
$langs
->
transnoentitiesnoconv
(
"CustomCode"
)
.
': '
.
$prod
->
customcode
;
...
@@ -527,11 +537,15 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -527,11 +537,15 @@ if ($action == 'addline' && $user->rights->facture->creer)
$tmptxt
.
=
$langs
->
transnoentitiesnoconv
(
"CountryOrigin"
)
.
': '
.
getCountry
(
$prod
->
country_code
,
0
,
$db
,
$langs
,
0
);
$tmptxt
.
=
$langs
->
transnoentitiesnoconv
(
"CountryOrigin"
)
.
': '
.
getCountry
(
$prod
->
country_code
,
0
,
$db
,
$langs
,
0
);
$tmptxt
.
=
')'
;
$tmptxt
.
=
')'
;
$desc
=
dol_concatdesc
(
$desc
,
$tmptxt
);
$desc
=
dol_concatdesc
(
$desc
,
$tmptxt
);
}
}
$type
=
$prod
->
type
;
$type
=
$prod
->
type
;
$fk_unit
=
$prod
->
fk_unit
;
$fk_unit
=
$prod
->
fk_unit
;
}
else
{
}
else
{
$pu_ht
=
price2num
(
$price_ht
,
'MU'
);
$pu_ht
=
price2num
(
$price_ht
,
'MU'
);
$pu_ttc
=
price2num
(
GETPOST
(
'price_ttc'
),
'MU'
);
$pu_ttc
=
price2num
(
GETPOST
(
'price_ttc'
),
'MU'
);
$tva_npr
=
(
preg_match
(
'/\*/'
,
$tva_tx
)
?
1
:
0
);
$tva_npr
=
(
preg_match
(
'/\*/'
,
$tva_tx
)
?
1
:
0
);
...
@@ -555,10 +569,13 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -555,10 +569,13 @@ if ($action == 'addline' && $user->rights->facture->creer)
if
(
$tva_npr
)
if
(
$tva_npr
)
$info_bits
|=
0x01
;
$info_bits
|=
0x01
;
if
(
!
empty
(
$price_min
)
&&
(
price2num
(
$pu_ht
)
*
(
1
-
price2num
(
$remise_percent
)
/
100
)
<
price2num
(
$price_min
)))
{
if
(
!
empty
(
$price_min
)
&&
(
price2num
(
$pu_ht
)
*
(
1
-
price2num
(
$remise_percent
)
/
100
)
<
price2num
(
$price_min
)))
{
$mesg
=
$langs
->
trans
(
"CantBeLessThanMinPrice"
,
price
(
price2num
(
$price_min
,
'MU'
),
0
,
$langs
,
0
,
0
,
-
1
,
$conf
->
currency
));
$mesg
=
$langs
->
trans
(
"CantBeLessThanMinPrice"
,
price
(
price2num
(
$price_min
,
'MU'
),
0
,
$langs
,
0
,
0
,
-
1
,
$conf
->
currency
));
setEventMessages
(
$mesg
,
null
,
'errors'
);
setEventMessages
(
$mesg
,
null
,
'errors'
);
}
else
{
}
else
{
// Insert line
// Insert line
$result
=
$object
->
addline
(
$desc
,
$pu_ht
,
$qty
,
$tva_tx
,
$idprod
,
$remise_percent
,
$price_base_type
,
$info_bits
,
''
,
$pu_ttc
,
$type
,
-
1
,
$special_code
,
$label
,
$fk_unit
);
$result
=
$object
->
addline
(
$desc
,
$pu_ht
,
$qty
,
$tva_tx
,
$idprod
,
$remise_percent
,
$price_base_type
,
$info_bits
,
''
,
$pu_ttc
,
$type
,
-
1
,
$special_code
,
$label
,
$fk_unit
);
...
@@ -618,7 +635,9 @@ if ($action == 'addline' && $user->rights->facture->creer)
...
@@ -618,7 +635,9 @@ if ($action == 'addline' && $user->rights->facture->creer)
unset
(
$_POST
[
'situations'
]);
unset
(
$_POST
[
'situations'
]);
unset
(
$_POST
[
'progress'
]);
unset
(
$_POST
[
'progress'
]);
}
else
{
}
else
{
setEventMessages
(
$object
->
error
,
$object
->
errors
,
'errors'
);
setEventMessages
(
$object
->
error
,
$object
->
errors
,
'errors'
);
}
}
...
@@ -661,9 +680,11 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
...
@@ -661,9 +680,11 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
$extralabelsline
=
$extrafieldsline
->
fetch_name_optionals_label
(
$object
->
table_element_line
);
$extralabelsline
=
$extrafieldsline
->
fetch_name_optionals_label
(
$object
->
table_element_line
);
$array_options
=
$extrafieldsline
->
getOptionalsFromPost
(
$extralabelsline
);
$array_options
=
$extrafieldsline
->
getOptionalsFromPost
(
$extralabelsline
);
// Unset extrafield
// Unset extrafield
if
(
is_array
(
$extralabelsline
))
{
if
(
is_array
(
$extralabelsline
))
{
// Get extra fields
// Get extra fields
foreach
(
$extralabelsline
as
$key
=>
$value
)
{
foreach
(
$extralabelsline
as
$key
=>
$value
)
{
unset
(
$_POST
[
"options_"
.
$key
]);
unset
(
$_POST
[
"options_"
.
$key
]);
}
}
}
}
...
@@ -721,12 +742,29 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
...
@@ -721,12 +742,29 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
}
}
// Update line
// Update line
if
(
!
$error
)
{
if
(
!
$error
)
$result
=
$object
->
updateline
(
GETPOST
(
'lineid'
),
$description
,
$pu_ht
,
$qty
,
{
$vat_rate
,
GETPOST
(
'productid'
),
GETPOST
(
'remise_percent'
),
'HT'
,
$info_bits
,
0
,
0
,
$type
,
$result
=
$object
->
updateline
(
0
,
$special_code
,
$label
,
GETPOST
(
'units'
));
GETPOST
(
'lineid'
),
$description
,
$pu_ht
,
$qty
,
$vat_rate
,
GETPOST
(
'productid'
),
GETPOST
(
'remise_percent'
),
'HT'
,
$info_bits
,
0
,
0
,
$type
,
0
,
$special_code
,
$label
,
GETPOST
(
'units'
)
);
if
(
$result
>=
0
)
{
if
(
$result
>=
0
)
{
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
// Define output language
$outputlangs = $langs;
$outputlangs = $langs;
...
@@ -781,7 +819,9 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
...
@@ -781,7 +819,9 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
unset
(
$_POST
[
'situations'
]);
unset
(
$_POST
[
'situations'
]);
unset
(
$_POST
[
'progress'
]);
unset
(
$_POST
[
'progress'
]);
}
else
{
}
else
{
setEventMessages
(
$object
->
error
,
$object
->
errors
,
'errors'
);
setEventMessages
(
$object
->
error
,
$object
->
errors
,
'errors'
);
}
}
}
}
...
@@ -1003,6 +1043,11 @@ else
...
@@ -1003,6 +1043,11 @@ else
$formconfirm
=
$form
->
formconfirm
(
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$object
->
id
.
'&lineid='
.
$lineid
,
$langs
->
trans
(
'DeleteProductLine'
),
$langs
->
trans
(
'ConfirmDeleteProductLine'
),
'confirm_deleteline'
,
''
,
'no'
,
1
);
$formconfirm
=
$form
->
formconfirm
(
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$object
->
id
.
'&lineid='
.
$lineid
,
$langs
->
trans
(
'DeleteProductLine'
),
$langs
->
trans
(
'ConfirmDeleteProductLine'
),
'confirm_deleteline'
,
''
,
'no'
,
1
);
}
}
// Confirm delete of repeatable invoice
if
(
$action
==
'ask_deleteinvoice'
)
{
$formconfirm
=
$form
->
formconfirm
(
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$object
->
id
,
$langs
->
trans
(
'DeleteRepeatableInvoice'
),
$langs
->
trans
(
'ConfirmDeleteRepeatableInvoice'
),
'confirm_deleteinvoice'
,
''
,
'no'
,
1
);
}
print
$formconfirm
;
print
$formconfirm
;
$author
=
new
User
(
$db
);
$author
=
new
User
(
$db
);
...
@@ -1056,9 +1101,12 @@ else
...
@@ -1056,9 +1101,12 @@ else
print
'</td><td colspan="3">'
;
print
'</td><td colspan="3">'
;
if
(
$object
->
type
!=
Facture
::
TYPE_CREDIT_NOTE
)
if
(
$object
->
type
!=
Facture
::
TYPE_CREDIT_NOTE
)
{
{
if
(
$action
==
'editconditions'
)
{
if
(
$action
==
'editconditions'
)
{
$form
->
form_conditions_reglement
(
$_SERVER
[
'PHP_SELF'
]
.
'?facid='
.
$object
->
id
,
$object
->
cond_reglement_id
,
'cond_reglement_id'
);
$form
->
form_conditions_reglement
(
$_SERVER
[
'PHP_SELF'
]
.
'?facid='
.
$object
->
id
,
$object
->
cond_reglement_id
,
'cond_reglement_id'
);
}
else
{
}
else
{
$form
->
form_conditions_reglement
(
$_SERVER
[
'PHP_SELF'
]
.
'?facid='
.
$object
->
id
,
$object
->
cond_reglement_id
,
'none'
);
$form
->
form_conditions_reglement
(
$_SERVER
[
'PHP_SELF'
]
.
'?facid='
.
$object
->
id
,
$object
->
cond_reglement_id
,
'none'
);
}
}
}
else
{
}
else
{
...
@@ -1102,7 +1150,8 @@ else
...
@@ -1102,7 +1150,8 @@ else
print
'</tr>'
;
print
'</tr>'
;
// Project
// Project
if
(
!
empty
(
$conf
->
projet
->
enabled
))
{
if
(
!
empty
(
$conf
->
projet
->
enabled
))
{
$langs
->
load
(
'projects'
);
$langs
->
load
(
'projects'
);
print
'<tr>'
;
print
'<tr>'
;
print
'<td>'
;
print
'<td>'
;
...
@@ -1359,7 +1408,7 @@ else
...
@@ -1359,7 +1408,7 @@ else
//if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
//if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
if
(
$user
->
rights
->
facture
->
supprimer
)
if
(
$user
->
rights
->
facture
->
supprimer
)
{
{
print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'
.
$_SERVER
[
'PHP_SELF'
]
.
'?action=delete&id='
.
$object
->
id
.
'">'
.
$langs
->
trans
(
'Delete'
)
.
'</a></div>'
;
print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'
.
$_SERVER
[
'PHP_SELF'
]
.
'?action=
ask_
delete
invoice
&id='
.
$object
->
id
.
'">'
.
$langs
->
trans
(
'Delete'
)
.
'</a></div>'
;
}
}
print
'</div>'
;
print
'</div>'
;
...
...
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