New: Add an admin page to make a mass init of barcode values for all
products.
This commit is contained in:
parent
5a29b3d546
commit
0b7f623c31
@ -16,11 +16,12 @@ For users:
|
|||||||
to automatically add timestamp and user line into editionf field when editing a note.
|
to automatically add timestamp and user line into editionf field when editing a note.
|
||||||
- New: Add button cancel into edition of notes.
|
- New: Add button cancel into edition of notes.
|
||||||
- New: Improved Opensurvey module and added options to disable comments and disable
|
- New: Improved Opensurvey module and added options to disable comments and disable
|
||||||
public votes
|
public votes.
|
||||||
- New: The box "balance of bank accounts" show all opened accounts.
|
- New: The box "balance of bank accounts" show all opened accounts.
|
||||||
- New: Add option MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE.
|
- New: Add option MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE.
|
||||||
- New: Add warning if supplier payment is higher that due amount.
|
- New: Add warning if supplier payment is higher that due amount.
|
||||||
- New increase length of url into bookmark module.
|
- New: Increase length of url into bookmark module.
|
||||||
|
- New: Add an admin page to make a mass init of barcode values for all products.
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
- New: Predefined product and free product use same form.
|
- New: Predefined product and free product use same form.
|
||||||
|
|||||||
@ -46,16 +46,109 @@ $action=GETPOST('action');
|
|||||||
$producttmp=new Product($db);
|
$producttmp=new Product($db);
|
||||||
$thirdpartytmp=new Societe($db);
|
$thirdpartytmp=new Societe($db);
|
||||||
|
|
||||||
|
$modBarCodeProduct='';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'init')
|
// Define barcode template for products
|
||||||
|
if (! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
|
||||||
{
|
{
|
||||||
|
$dirbarcodenum=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']);
|
||||||
|
|
||||||
|
foreach ($dirbarcodenum as $dirroot)
|
||||||
|
{
|
||||||
|
$dir = dol_buildpath($dirroot,0);
|
||||||
|
|
||||||
|
$handle = @opendir($dir);
|
||||||
|
if (is_resource($handle))
|
||||||
|
{
|
||||||
|
while (($file = readdir($handle))!==false)
|
||||||
|
{
|
||||||
|
if (preg_match('/^mod_barcode_product_.*php$/', $file))
|
||||||
|
{
|
||||||
|
$file = substr($file, 0, dol_strlen($file)-4);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dol_include_once($dirroot.$file.'.php');
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
dol_syslog($e->getMessage(), LOG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
$modBarCodeProduct = new $file();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'initbarcodeproducts')
|
||||||
|
{
|
||||||
|
if (! is_object($modBarCodeProduct))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessage($langs->trans("NoBarcodeNumberingTemplateDefined"),'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$productstatic=new Product($db);
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$sql="SELECT rowid, ref, fk_product_type FROM ".MAIN_DB_PREFIX."product where barcode IS NULL or barcode = ''";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num=$db->num_rows($resql);
|
||||||
|
|
||||||
|
$i=0; $nbok=$nbtry=0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("RecordsModified",$nbok),'mesgs');
|
||||||
|
|
||||||
|
//$db->rollback();
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$action='';
|
$action='';
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +157,9 @@ if ($action == 'init')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!$user->admin) accessforbidden();
|
||||||
|
if (empty($conf->barcode->enabled)) accessforbidden();
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader('',$langs->trans("MassBarcodeInit"));
|
llxHeader('',$langs->trans("MassBarcodeInit"));
|
||||||
@ -81,9 +177,101 @@ dol_htmloutput_errors($mesg);
|
|||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
print '<input type="hidden" name="mode" value="label">';
|
print '<input type="hidden" name="mode" value="label">';
|
||||||
print '<input type="hidden" name="action" value="builddoc">';
|
print '<input type="hidden" name="action" value="initbarcodeproducts">';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
// For thirdparty
|
||||||
|
if ($conf->societe->enabled)
|
||||||
|
{
|
||||||
|
$nbno=$nbtotal=0;
|
||||||
|
|
||||||
|
print_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','').'<br>'."\n";
|
||||||
|
$sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
$nbno=$obj->nb;
|
||||||
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
|
||||||
|
$sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
$nbtotal=$obj->nb;
|
||||||
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
|
||||||
|
print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("Thirdparties")).'<br>'."\n";
|
||||||
|
|
||||||
|
print '<br><input class="button" type="submit" id="submitformbarcodethirdpartygen" '.((GETPOST("selectorforbarcode") && GETPOST("selectorforbarcode"))?'':'disabled="checked" ').'value="'.$langs->trans("InitEmptyBarCode",$nbno).'"';
|
||||||
|
print ' title="'.dol_escape_htmltag($langs->trans("FeatureNotYetAvailable")).'" disabled="disabled"';
|
||||||
|
print '>';
|
||||||
|
print '<br><br><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// For products
|
||||||
|
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 FROM ".MAIN_DB_PREFIX."product where barcode IS NULL or barcode = '' GROUP BY fk_product_type";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num=$db->num_rows($resql);
|
||||||
|
|
||||||
|
$i=0;
|
||||||
|
while($i < $num)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
$nbno+=$obj->nb;
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
|
||||||
|
$sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
$nbtotal=$obj->nb;
|
||||||
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
|
||||||
|
print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'<br>'."\n";
|
||||||
|
|
||||||
|
if (is_object($modBarCodeProduct))
|
||||||
|
{
|
||||||
|
print $langs->trans("BarCodeNumberManager").": ";
|
||||||
|
$objproduct=new Product($db);
|
||||||
|
print '<b>'.$modBarCodeProduct->nom.'</b> - '.$langs->trans("NextValue").': <b>'.$modBarCodeProduct->getNextValue($objproduct).'</b><br>';
|
||||||
|
$disabled=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$disabled=1;
|
||||||
|
$titleno=$langs->trans("NoBarcodeNumberingTemplateDefined");
|
||||||
|
print '<font class="warning">'.$langs->trans("NoBarcodeNumberingTemplateDefined").'</font><br>';
|
||||||
|
}
|
||||||
|
if (empty($nbno))
|
||||||
|
{
|
||||||
|
$disabled=1;
|
||||||
|
$titleno=$langs->trans("NoRecordWithoutBarcodeDefined");
|
||||||
|
print '<font class="ok">'.$langs->trans("NoRecordWithoutBarcodeDefined").'</font><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<br><input class="button" type="submit" id="submitformbarcodeproductgen" value="'.$langs->trans("InitEmptyBarCode",$nbno).'"'.($disabled?' disabled="disabled" title="'.dol_escape_htmltag($titleno).'"':'').'>';
|
||||||
|
print '<br><br><br>';
|
||||||
|
}
|
||||||
|
|
||||||
print '<br><input class="button" type="submit" id="submitformbarcodegen" '.((GETPOST("selectorforbarcode") && GETPOST("selectorforbarcode"))?'':'disabled="checked" ').'value="'.$langs->trans("InitEmptyBarCode").'">';
|
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|||||||
@ -243,6 +243,8 @@ if ($action == 'builddoc')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (empty($conf->barcode->enabled)) accessforbidden();
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader('',$langs->trans("BarCodePrintsheet"));
|
llxHeader('',$langs->trans("BarCodePrintsheet"));
|
||||||
|
|||||||
@ -379,6 +379,12 @@ KeepEmptyToUseDefault=Keep empty to use default value
|
|||||||
DefaultLink=Default link
|
DefaultLink=Default link
|
||||||
ValueOverwrittenByUserSetup=Warning, this value may be overwritten by user specific setup (each user can set his own clicktodial url)
|
ValueOverwrittenByUserSetup=Warning, this value may be overwritten by user specific setup (each user can set his own clicktodial url)
|
||||||
ExternalModule=External module - Installed into directory %s
|
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 the %s barcode
|
||||||
|
NoBarcodeNumberingTemplateDefined=No numbering barcode template enabled into barcode module setup.
|
||||||
|
NoRecordWithoutBarcodeDefined=No record with no barcode value defined.
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
Module0Name=Users & groups
|
Module0Name=Users & groups
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user