diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php
index 52a11e78bdd..f35547523c9 100644
--- a/htdocs/barcode/codeinit.php
+++ b/htdocs/barcode/codeinit.php
@@ -52,27 +52,21 @@ $maxperinit = 1000;
*/
// Define barcode template for products
-if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
-{
+if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
- foreach ($dirbarcodenum as $dirroot)
- {
+ 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))
- {
+ 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)
- {
+ } catch (Exception $e) {
dol_syslog($e->getMessage(), LOG_ERR);
}
@@ -85,28 +79,23 @@ if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
}
}
-if ($action == 'initbarcodeproducts')
-{
- if (!is_object($modBarCodeProduct))
- {
+if ($action == 'initbarcodeproducts') {
+ if (!is_object($modBarCodeProduct)) {
$error++;
setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors');
}
- if (!$error)
- {
+ if (!$error) {
$productstatic = new Product($db);
$db->begin();
$nbok = 0;
- if (!empty($eraseallbarcode))
- {
+ if (!empty($eraseallbarcode)) {
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
$sql .= " SET barcode = NULL";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs');
} else {
$error++;
@@ -121,16 +110,13 @@ if ($action == 'initbarcodeproducts')
dol_syslog("codeinit", LOG_DEBUG);
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0; $nbok = $nbtry = 0;
- while ($i < min($num, $maxperinit))
- {
+ while ($i < min($num, $maxperinit)) {
$obj = $db->fetch_object($resql);
- if ($obj)
- {
+ if ($obj) {
$productstatic->id = $obj->rowid;
$productstatic->ref = $obj->ref;
$productstatic->type = $obj->fk_product_type;
@@ -140,7 +126,9 @@ if ($action == 'initbarcodeproducts')
$result = $productstatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'PRODUCT_MODIFY');
$nbtry++;
- if ($result > 0) $nbok++;
+ if ($result > 0) {
+ $nbok++;
+ }
}
$i++;
@@ -150,14 +138,12 @@ if ($action == 'initbarcodeproducts')
dol_print_error($db);
}
- if (!$error)
- {
+ if (!$error) {
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
}
}
- if (!$error)
- {
+ if (!$error) {
//$db->rollback();
$db->commit();
} else {
@@ -174,8 +160,12 @@ if ($action == 'initbarcodeproducts')
* View
*/
-if (!$user->admin) accessforbidden();
-if (empty($conf->barcode->enabled)) accessforbidden();
+if (!$user->admin) {
+ accessforbidden();
+}
+if (empty($conf->barcode->enabled)) {
+ accessforbidden();
+}
$form = new Form($db);
@@ -198,8 +188,7 @@ print '';
print '
';
// For thirdparty
-if ($conf->societe->enabled)
-{
+if ($conf->societe->enabled) {
$nbno = $nbtotal = 0;
print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"), '', 'company');
@@ -207,19 +196,21 @@ if ($conf->societe->enabled)
print '
'."\n";
$sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
$nbno = $obj->nb;
- } else dol_print_error($db);
+ } else {
+ dol_print_error($db);
+ }
$sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
$nbtotal = $obj->nb;
- } else dol_print_error($db);
+ } else {
+ dol_print_error($db);
+ }
print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ThirdParties")).'
'."\n";
@@ -231,8 +222,7 @@ if ($conf->societe->enabled)
// For products
-if ($conf->product->enabled || $conf->product->service)
-{
+if ($conf->product->enabled || $conf->product->service) {
// Example 1 : Adding jquery code
print '