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
16857293
Commit
16857293
authored
11 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
New: Can reset barcode also for barcode already defined.
parent
07ee85b0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/barcode/codeinit.php
+57
-37
57 additions, 37 deletions
htdocs/barcode/codeinit.php
htdocs/langs/en_US/admin.lang
+3
-2
3 additions, 2 deletions
htdocs/langs/en_US/admin.lang
with
60 additions
and
39 deletions
htdocs/barcode/codeinit.php
+
57
−
37
View file @
16857293
...
...
@@ -35,7 +35,7 @@ $month=dol_print_date($now,'%m');
$day
=
dol_print_date
(
$now
,
'%d'
);
$forbarcode
=
GETPOST
(
'forbarcode'
);
$fk_barcode_type
=
GETPOST
(
'fk_barcode_type'
);
$
submitformbarcodeproductgenall
=
GETPOST
(
'submitformbarcodeproductgenall
'
);
$
eraseallbarcode
=
GETPOST
(
'eraseallbarcode
'
);
$mesg
=
''
;
...
...
@@ -46,6 +46,8 @@ $thirdpartytmp=new Societe($db);
$modBarCodeProduct
=
''
;
$maxperinit
=
1000
;
/*
* Actions
...
...
@@ -100,54 +102,71 @@ if ($action == 'initbarcodeproducts')
$db
->
begin
();
if
(
!
empty
(
$submitformbarcodeproductgenall
))
$nbok
=
0
;
if
(
!
empty
(
$eraseallbarcode
))
{
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"product"
;
$sql
.
=
" SET barcode = NULL"
;
$resql
=
$db
->
query
(
$sql
);
if
(
!
$resql
)
dol_print_error
(
$db
);
if
(
$resql
)
{
setEventMessage
(
$langs
->
trans
(
"AllBarcodeReset"
),
'mesgs'
);
}
else
{
$error
++
;
dol_print_error
(
$db
);
}
}
$sql
=
"SELECT rowid, ref, fk_product_type"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"product"
;
$sql
.
=
" WHERE barcode IS NULL or barcode = ''"
;
$sql
.
=
" ORDER BY datec ASC"
;
$resql
=
$db
->
query
(
$sql
);
if
(
$resql
)
else
{
$num
=
$db
->
num_rows
(
$resql
);
$sql
=
"SELECT rowid, ref, fk_product_type"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"product"
;
$sql
.
=
" WHERE barcode IS NULL or barcode = ''"
;
$sql
.
=
$db
->
order
(
"datec"
,
"ASC"
);
$sql
.
=
$db
->
plimit
(
$maxperinit
);
$i
=
0
;
$nbok
=
$nbtry
=
0
;
while
(
$i
<
$num
)
dol_syslog
(
"codeinit sql="
.
$sql
,
LOG_DEBUG
);
$resql
=
$db
->
query
(
$sql
);
if
(
$resql
)
{
$obj
=
$db
->
fetch_object
(
$resql
);
if
(
$obj
)
{
$productstatic
->
id
=
$obj
->
rowid
;
$productstatic
->
ref
=
$obj
->
ref
;
$productstatic
->
type
=
$obj
->
fk_product_type
;
$nextvalue
=
$modBarCodeProduct
->
getNextValue
(
$productstatic
,
''
);
//print 'Set value '.$nextvalue.' to product '.$productstatic->id." ".$productstatic->ref." ".$productstatic->type."<br>\n";
$result
=
$productstatic
->
setValueFrom
(
'barcode'
,
$nextvalue
);
$num
=
$db
->
num_rows
(
$resql
);
$nbtry
++
;
if
(
$result
>
0
)
$nbok
++
;
$i
=
0
;
$nbok
=
$nbtry
=
0
;
while
(
$i
<
min
(
$num
,
$maxperinit
))
{
$obj
=
$db
->
fetch_object
(
$resql
);
if
(
$obj
)
{
$productstatic
->
id
=
$obj
->
rowid
;
$productstatic
->
ref
=
$obj
->
ref
;
$productstatic
->
type
=
$obj
->
fk_product_type
;
$nextvalue
=
$modBarCodeProduct
->
getNextValue
(
$productstatic
,
''
);
//print 'Set value '.$nextvalue.' to product '.$productstatic->id." ".$productstatic->ref." ".$productstatic->type."<br>\n";
$result
=
$productstatic
->
setValueFrom
(
'barcode'
,
$nextvalue
);
$nbtry
++
;
if
(
$result
>
0
)
$nbok
++
;
}
$i
++
;
}
}
else
{
$error
++
;
dol_print_error
(
$db
);
}
$i
++
;
if
(
!
$error
)
{
setEventMessage
(
$langs
->
trans
(
"RecordsModified"
,
$nbok
),
'mesgs'
);
}
}
else
{
$error
++
;
dol_print_error
(
$db
);
}
if
(
!
$error
)
{
setEventMessage
(
$langs
->
trans
(
"RecordsModified"
,
$nbok
),
'mesgs'
);
//$db->rollback();
$db
->
commit
();
}
...
...
@@ -229,7 +248,7 @@ if ($conf->product->enabled || $conf->product->service)
$nbno
=
$nbtotal
=
0
;
print_fiche_titre
(
$langs
->
trans
(
"BarcodeInitForProductsOrServices"
),
''
,
''
)
.
'<br>'
.
"
\n
"
;
$sql
=
"SELECT count(rowid) as nb, fk_product_type"
;
$sql
=
"SELECT count(rowid) as nb, fk_product_type"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"product"
;
$sql
.
=
" WHERE barcode IS NULL OR barcode = ''"
;
$sql
.
=
" GROUP BY fk_product_type"
;
...
...
@@ -284,9 +303,10 @@ if ($conf->product->enabled || $conf->product->service)
print
'<br>'
;
//print '<input type="checkbox" id="erasealreadyset" name="erasealreadyset"> '.$langs->trans("ResetBarcodeForAllRecords").'<br>';
$moretags1
=
((
$disabled
||
$disabled1
)
?
' disabled="disabled" title="'
.
dol_escape_htmltag
(
$titleno
)
.
'"'
:
''
);
print
'<input class="button" type="submit" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'
.
$langs
->
trans
(
"InitEmptyBarCode"
,
$nbno
)
.
'"'
.
$moretags1
.
'>'
;
$moretags2
=
((
$disabled
||
!
$nbtotal
)
?
' disabled="disabled"'
:
''
);
print
'<input class="button" type="submit" name="submitformbarcodeproductgenall" id="submitformbarcodeproductgenall" value="'
.
$langs
->
trans
(
"EraseAndResetBarCode"
,
$nbtotal
)
.
'"'
.
$moretags2
.
'>'
;
print
'<input class="button" type="submit" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'
.
$langs
->
trans
(
"InitEmptyBarCode"
,
min
(
$maxperinit
,
$nbno
))
.
'"'
.
$moretags1
.
'>'
;
$moretags2
=
((
$nbno
==
$nbtotal
)
?
' disabled="disabled"'
:
''
);
print
' '
;
print
'<input class="button" type="submit" name="eraseallbarcode" id="eraseallbarcode" value="'
.
$langs
->
trans
(
"EraseAllCurrentBarCode"
)
.
'"'
.
$moretags2
.
'>'
;
print
'<br><br><br>'
;
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/langs/en_US/admin.lang
+
3
−
2
View file @
16857293
...
...
@@ -382,8 +382,9 @@ ExternalModule=External module - Installed into directory %s
BarcodeInitForThirdparties=Mass barcode init for thirdparties
BarcodeInitForProductsOrServices=Mass barcode init for products or services
CurrentlyNWithoutBarCode=Currently, you have <strong>%s</strong> records on <strong>%s</strong> %s without barcode defined.
InitEmptyBarCode=Init value for the %s empty barcode
EraseAndResetBarCode=Erase and reset barcode for all the %s records
InitEmptyBarCode=Init value for next %s empty records
EraseAllCurrentBarCode=Erase all current barcode values
AllBarcodeReset=All barcode values have been removed
NoBarcodeNumberingTemplateDefined=No numbering barcode template enabled into barcode module setup.
NoRecordWithoutBarcodeDefined=No record with no barcode value defined.
...
...
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