Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
6365bdb35c
@ -55,6 +55,16 @@ if ($action == 'setbarcodeproducton') {
|
|||||||
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
|
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'setbarcodethirdpartyon') {
|
||||||
|
$barcodenumberingmodule = GETPOST('value', 'alpha');
|
||||||
|
$res = dolibarr_set_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
|
||||||
|
if ($barcodenumberingmodule == 'mod_barcode_thirdparty_standard' && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) {
|
||||||
|
$res = dolibarr_set_const($db, "BARCODE_STANDARD_THIRDPARTY_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
} elseif ($action == 'setbarcodethirdpartyoff') {
|
||||||
|
$res = dolibarr_del_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'setcoder') {
|
if ($action == 'setcoder') {
|
||||||
$coder = GETPOST('coder', 'alpha');
|
$coder = GETPOST('coder', 'alpha');
|
||||||
$code_id = GETPOST('code_id', 'int');
|
$code_id = GETPOST('code_id', 'int');
|
||||||
@ -241,6 +251,66 @@ if ($conf->product->enabled) {
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Select barcode numbering module
|
||||||
|
if ($conf->societe->enabled) {
|
||||||
|
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("ThirdParty").")", '', '');
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive-no-min">';
|
||||||
|
print '<table class="noborder centpercent">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td width="140">'.$langs->trans("Name").'</td>';
|
||||||
|
print '<td>'.$langs->trans("Description").'</td>';
|
||||||
|
print '<td>'.$langs->trans("Example").'</td>';
|
||||||
|
print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
|
||||||
|
print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$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_thirdparty_.*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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$modBarCode = new $file();
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n";
|
||||||
|
print $modBarCode->info($langs);
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
||||||
|
|
||||||
|
if (!empty($conf->global->BARCODE_THIRDPARTY_ADDON_NUM) && $conf->global->BARCODE_THIRDPARTY_ADDON_NUM == "$file") {
|
||||||
|
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodethirdpartyoff&token='.newToken().'&value='.urlencode($file).'">';
|
||||||
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
|
print '</a></td>';
|
||||||
|
} else {
|
||||||
|
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodethirdpartyon&token='.newToken().'&value='.urlencode($file).'">';
|
||||||
|
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||||
|
print '</a></td>';
|
||||||
|
}
|
||||||
|
print '<td class="center">';
|
||||||
|
$s = $modBarCode->getToolTip($langs, null, -1);
|
||||||
|
print $form->textwithpicto('', $s, 1);
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "</table>\n";
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CHOIX ENCODAGE
|
* CHOIX ENCODAGE
|
||||||
|
|||||||
@ -104,6 +104,16 @@ if ($action == 'update') {
|
|||||||
dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
|
if (GETPOSTISSET('THEME_DARKMODEENABLED')) {
|
||||||
|
$val = GETPOST('THEME_DARKMODEENABLED');
|
||||||
|
if (!$val) {
|
||||||
|
dolibarr_del_const($db, "THEME_DARKMODEENABLED", $conf->entity);
|
||||||
|
}
|
||||||
|
if ($val) {
|
||||||
|
dolibarr_set_const($db, "THEME_DARKMODEENABLED", $val, 'chaine', 0, '', $conf->entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GETPOSTISSET('THEME_TOPMENU_DISABLE_IMAGE')) {
|
if (GETPOSTISSET('THEME_TOPMENU_DISABLE_IMAGE')) {
|
||||||
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
|
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
|
||||||
if (!$val) {
|
if (!$val) {
|
||||||
|
|||||||
@ -35,7 +35,8 @@ $month = dol_print_date($now, '%m');
|
|||||||
$day = dol_print_date($now, '%d');
|
$day = dol_print_date($now, '%d');
|
||||||
$forbarcode = GETPOST('forbarcode');
|
$forbarcode = GETPOST('forbarcode');
|
||||||
$fk_barcode_type = GETPOST('fk_barcode_type');
|
$fk_barcode_type = GETPOST('fk_barcode_type');
|
||||||
$eraseallbarcode = GETPOST('eraseallbarcode');
|
$eraseallproductbarcode = GETPOST('eraseallproductbarcode');
|
||||||
|
$eraseallthirdpartybarcode = GETPOST('eraseallthirdpartybarcode');
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ $producttmp = new Product($db);
|
|||||||
$thirdpartytmp = new Societe($db);
|
$thirdpartytmp = new Societe($db);
|
||||||
|
|
||||||
$modBarCodeProduct = '';
|
$modBarCodeProduct = '';
|
||||||
|
$modBarCodeThirdparty = '';
|
||||||
|
|
||||||
$maxperinit = 1000;
|
$maxperinit = 1000;
|
||||||
|
|
||||||
@ -51,6 +53,106 @@ $maxperinit = 1000;
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Define barcode template for third-party
|
||||||
|
if (!empty($conf->global->BARCODE_THIRDPARTY_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_thirdparty_.*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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$modBarCodeThirdparty = new $file();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'initbarcodethirdparties') {
|
||||||
|
if (!is_object($modBarCodeThirdparty)) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$thirdpartystatic = new Societe($db);
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$nbok = 0;
|
||||||
|
if (!empty($eraseallthirdpartybarcode)) {
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
|
||||||
|
$sql .= " SET barcode = NULL";
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs');
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sql = "SELECT rowid";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
|
||||||
|
$sql .= " WHERE barcode IS NULL or barcode = ''";
|
||||||
|
$sql .= $db->order("datec", "ASC");
|
||||||
|
$sql .= $db->plimit($maxperinit);
|
||||||
|
|
||||||
|
dol_syslog("codeinit", LOG_DEBUG);
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
$i = 0; $nbok = $nbtry = 0;
|
||||||
|
while ($i < min($num, $maxperinit)) {
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
if ($obj) {
|
||||||
|
$thirdpartystatic->id = $obj->rowid;
|
||||||
|
$nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic, '');
|
||||||
|
|
||||||
|
$result = $thirdpartystatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'THIRDPARTY_MODIFY');
|
||||||
|
|
||||||
|
$nbtry++;
|
||||||
|
if ($result > 0) {
|
||||||
|
$nbok++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
//$db->rollback();
|
||||||
|
$db->commit();
|
||||||
|
} else {
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Define barcode template for products
|
// 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']);
|
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
|
||||||
@ -91,7 +193,7 @@ if ($action == 'initbarcodeproducts') {
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$nbok = 0;
|
$nbok = 0;
|
||||||
if (!empty($eraseallbarcode)) {
|
if (!empty($eraseallproductbarcode)) {
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
||||||
$sql .= " SET barcode = NULL";
|
$sql .= " SET barcode = NULL";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -155,7 +257,6 @@ if ($action == 'initbarcodeproducts') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -180,16 +281,25 @@ print '<br>';
|
|||||||
//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'<br>';
|
//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'<br>';
|
||||||
//print '<br>';
|
//print '<br>';
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
||||||
print '<input type="hidden" name="mode" value="label">';
|
|
||||||
print '<input type="hidden" name="action" value="initbarcodeproducts">';
|
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Example 1 : Adding jquery code
|
||||||
|
print '<script type="text/javascript">
|
||||||
|
function confirm_erase() {
|
||||||
|
return confirm("'.dol_escape_js($langs->trans("ConfirmEraseAllCurrentBarCode")).'");
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
|
||||||
|
|
||||||
// For thirdparty
|
// For thirdparty
|
||||||
if (isModEnabled('societe')) {
|
if (isModEnabled('societe')) {
|
||||||
$nbno = $nbtotal = 0;
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="mode" value="label">';
|
||||||
|
print '<input type="hidden" name="action" value="initbarcodethirdparties">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
$nbthirdpartyno = $nbthirdpartytotal = 0;
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"), '', 'company');
|
print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"), '', 'company');
|
||||||
|
|
||||||
@ -198,7 +308,7 @@ if (isModEnabled('societe')) {
|
|||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$nbno = $obj->nb;
|
$nbthirdpartyno = $obj->nb;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
@ -207,30 +317,47 @@ if (isModEnabled('societe')) {
|
|||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$nbtotal = $obj->nb;
|
$nbthirdpartytotal = $obj->nb;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ThirdParties")).'<br>'."\n";
|
print $langs->trans("CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv("ThirdParties")).'<br>'."\n";
|
||||||
|
|
||||||
print '<br><input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" '.((GETPOST("selectorforbarcode") && GETPOST("selectorforbarcode")) ? '' : 'disabled ').'value="'.$langs->trans("InitEmptyBarCode", $nbno).'"';
|
$disabledthirdparty = $disabledthirdparty1 = 0;
|
||||||
print ' title="'.dol_escape_htmltag($langs->trans("FeatureNotYetAvailable")).'" disabled';
|
|
||||||
print '>';
|
if (is_object($modBarCodeThirdparty)) {
|
||||||
|
print $langs->trans("BarCodeNumberManager").": ";
|
||||||
|
$objthirdparty = new Societe($db);
|
||||||
|
print '<b>'.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).'</b> - '.$langs->trans("NextValue").': <b>'.$modBarCodeThirdparty->getNextValue($objthirdparty).'</b><br>';
|
||||||
|
$disabledthirdparty = 0;
|
||||||
|
} else {
|
||||||
|
$disabledthirdparty = 1;
|
||||||
|
$titleno = $langs->trans("NoBarcodeNumberingTemplateDefined");
|
||||||
|
print '<span class="warning">'.$langs->trans("NoBarcodeNumberingTemplateDefined").'</span> (<a href="'.DOL_URL_ROOT.'/admin/barcode.php">'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").'</a>)<br>';
|
||||||
|
}
|
||||||
|
if (empty($nbthirdpartyno)) {
|
||||||
|
$disabledthirdparty1 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : '');
|
||||||
|
print '<br><input class="button button-add" type="submit" id="submitformbarcodethirdpartygen" value="'.$langs->trans("InitEmptyBarCode", $nbno).'"'.$moretagsthirdparty1.'>';
|
||||||
|
$moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ? ' disabled' : '');
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button butActionDelete" name="eraseallthirdpartybarcode" id="eraseallthirdpartybarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretagsthirdparty2.' onClick="return confirm_erase();">';
|
||||||
print '<br><br><br><br>';
|
print '<br><br><br><br>';
|
||||||
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// For products
|
// For products
|
||||||
if ($conf->product->enabled || $conf->product->service) {
|
if ($conf->product->enabled || $conf->product->service) {
|
||||||
// Example 1 : Adding jquery code
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
print '<script type="text/javascript">
|
print '<input type="hidden" name="mode" value="label">';
|
||||||
function confirm_erase() {
|
print '<input type="hidden" name="action" value="initbarcodeproducts">';
|
||||||
return confirm("'.dol_escape_js($langs->trans("ConfirmEraseAllCurrentBarCode")).'");
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
}
|
|
||||||
</script>';
|
|
||||||
|
|
||||||
$nbno = $nbtotal = 0;
|
$nbproductno = $nbproducttotal = 0;
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"), '', 'product');
|
print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"), '', 'product');
|
||||||
print '<br>'."\n";
|
print '<br>'."\n";
|
||||||
@ -247,7 +374,7 @@ if ($conf->product->enabled || $conf->product->service) {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$nbno += $obj->nb;
|
$nbproductno += $obj->nb;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -259,35 +386,38 @@ if ($conf->product->enabled || $conf->product->service) {
|
|||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$nbtotal = $obj->nb;
|
$nbproducttotal = $obj->nb;
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'<br>'."\n";
|
print $langs->trans("CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'<br>'."\n";
|
||||||
|
|
||||||
|
$disabledproduct = $disabledproduct1 = 0;
|
||||||
|
|
||||||
if (is_object($modBarCodeProduct)) {
|
if (is_object($modBarCodeProduct)) {
|
||||||
print $langs->trans("BarCodeNumberManager").": ";
|
print $langs->trans("BarCodeNumberManager").": ";
|
||||||
$objproduct = new Product($db);
|
$objproduct = new Product($db);
|
||||||
print '<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).'</b> - '.$langs->trans("NextValue").': <b>'.$modBarCodeProduct->getNextValue($objproduct).'</b><br>';
|
print '<b>'.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).'</b> - '.$langs->trans("NextValue").': <b>'.$modBarCodeProduct->getNextValue($objproduct).'</b><br>';
|
||||||
$disabled = 0;
|
$disabledproduct = 0;
|
||||||
} else {
|
} else {
|
||||||
$disabled = 1;
|
$disabledproduct = 1;
|
||||||
$titleno = $langs->trans("NoBarcodeNumberingTemplateDefined");
|
$titleno = $langs->trans("NoBarcodeNumberingTemplateDefined");
|
||||||
print '<span class="warning">'.$langs->trans("NoBarcodeNumberingTemplateDefined").'</span> (<a href="'.DOL_URL_ROOT.'/admin/barcode.php">'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").'</a>)<br>';
|
print '<span class="warning">'.$langs->trans("NoBarcodeNumberingTemplateDefined").'</span> (<a href="'.DOL_URL_ROOT.'/admin/barcode.php">'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").'</a>)<br>';
|
||||||
}
|
}
|
||||||
if (empty($nbno)) {
|
if (empty($nbproductno)) {
|
||||||
$disabled1 = 1;
|
$disabledproduct1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
//print '<input type="checkbox" id="erasealreadyset" name="erasealreadyset"> '.$langs->trans("ResetBarcodeForAllRecords").'<br>';
|
//print '<input type="checkbox" id="erasealreadyset" name="erasealreadyset"> '.$langs->trans("ResetBarcodeForAllRecords").'<br>';
|
||||||
$moretags1 = (($disabled || $disabled1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : '');
|
$moretagsproduct1 = (($disabledproduct || $disabledproduct1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : '');
|
||||||
print '<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans("InitEmptyBarCode", min($maxperinit, $nbno)).'"'.$moretags1.'>';
|
print '<input type="submit" class="button" name="submitformbarcodeproductgen" id="submitformbarcodeproductgen" value="'.$langs->trans("InitEmptyBarCode", min($maxperinit, $nbno)).'"'.$moretagsproduct1.'>';
|
||||||
$moretags2 = (($nbno == $nbtotal) ? ' disabled' : '');
|
$moretagsproduct2 = (($nbproductno == $nbproducttotal) ? ' disabled' : '');
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input type="submit" class="button butActionDelete" name="eraseallbarcode" id="eraseallbarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretags2.' onClick="return confirm_erase();">';
|
print '<input type="submit" class="button butActionDelete" name="eraseallproductbarcode" id="eraseallproductbarcode" value="'.$langs->trans("EraseAllCurrentBarCode").'"'.$moretagsproduct2.' onClick="return confirm_erase();">';
|
||||||
print '<br><br><br><br>';
|
print '<br><br><br><br>';
|
||||||
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -297,7 +427,6 @@ print $langs->trans("ClickHereToGoTo").' : <a href="'.DOL_URL_ROOT.'/barcode/pri
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
print '</form>';
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
|
|||||||
@ -5569,6 +5569,9 @@ abstract class CommonObject
|
|||||||
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||||
$setsharekey = true;
|
$setsharekey = true;
|
||||||
}
|
}
|
||||||
|
if ($this->element == 'product' && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||||
|
$setsharekey = true;
|
||||||
|
}
|
||||||
if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||||
$setsharekey = true;
|
$setsharekey = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1717,7 +1717,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
|
|||||||
|
|
||||||
// Update index table of files (llx_ecm_files)
|
// Update index table of files (llx_ecm_files)
|
||||||
if ($donotupdatesession == 1) {
|
if ($donotupdatesession == 1) {
|
||||||
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0, $object);
|
$sharefile = 0;
|
||||||
|
if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1;
|
||||||
|
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', $sharefile, $object);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
if ($allowoverwrite) {
|
if ($allowoverwrite) {
|
||||||
// Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS
|
// Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS
|
||||||
|
|||||||
@ -455,6 +455,28 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
|
|||||||
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Dark mode
|
||||||
|
if ($foruserprofile) {
|
||||||
|
//Nothing
|
||||||
|
} else {
|
||||||
|
$listofdarkmodes = array(
|
||||||
|
'0' => $langs->trans("AlwaysDisabled"),
|
||||||
|
'1' => $langs->trans("AccordingToBrowser"),
|
||||||
|
'2' => $langs->trans("AlwaysEnabled")
|
||||||
|
);
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
print '<td>'.$langs->trans("DarkThemeMode").'</td>';
|
||||||
|
print '<td colspan="'.($colspan - 1).'">';
|
||||||
|
if ($edit) {
|
||||||
|
print $form->selectarray('THEME_DARKMODEENABLED', $listofdarkmodes, isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0);
|
||||||
|
} else {
|
||||||
|
print $listofdarkmodes[isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0];
|
||||||
|
}
|
||||||
|
print $form->textwithpicto('', $langs->trans("DoesNotWorkWithAllThemes"));
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TopMenuDisableImages
|
// TopMenuDisableImages
|
||||||
if ($foruserprofile) {
|
if ($foruserprofile) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -301,7 +301,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
|
|||||||
* @param string $format "rss"
|
* @param string $format "rss"
|
||||||
* @param string $title Title of export
|
* @param string $title Title of export
|
||||||
* @param string $desc Description of export
|
* @param string $desc Description of export
|
||||||
* @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") or Array of WebsitePage
|
* @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category","image") or Array of WebsitePage
|
||||||
* @param string $outputfile Output file
|
* @param string $outputfile Output file
|
||||||
* @param string $filter (optional) Filter
|
* @param string $filter (optional) Filter
|
||||||
* @param string $url Url (If empty, forge URL for agenda RSS export)
|
* @param string $url Url (If empty, forge URL for agenda RSS export)
|
||||||
@ -377,7 +377,7 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
|
|||||||
$tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown';
|
$tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown';
|
||||||
//$tmpevent['category'] = '';
|
//$tmpevent['category'] = '';
|
||||||
$tmpevent['desc'] = $event->description;
|
$tmpevent['desc'] = $event->description;
|
||||||
|
$tmpevent['image'] = $GLOBALS['website']->virtualhost.'/medias/'.$event->image;
|
||||||
$event = $tmpevent;
|
$event = $tmpevent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,9 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
|
|||||||
$url = $event["url"];
|
$url = $event["url"];
|
||||||
$author = $event["author"];
|
$author = $event["author"];
|
||||||
$category = $event["category"];
|
$category = $event["category"];
|
||||||
|
if (!empty($event["image"])) {
|
||||||
|
$image = $event["image"];
|
||||||
|
}
|
||||||
/* No place inside a RSS
|
/* No place inside a RSS
|
||||||
$priority = $event["priority"];
|
$priority = $event["priority"];
|
||||||
$fulldayevent = $event["fulldayevent"];
|
$fulldayevent = $event["fulldayevent"];
|
||||||
@ -404,6 +406,10 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
|
|||||||
fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
|
fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
|
||||||
fwrite($fichier, "<description><![CDATA[");
|
fwrite($fichier, "<description><![CDATA[");
|
||||||
|
|
||||||
|
if (!empty($image)) {
|
||||||
|
fwrite($fichier, '<p><img class="center" src="'.$image.'"/></p>');
|
||||||
|
}
|
||||||
|
|
||||||
if ($description) {
|
if ($description) {
|
||||||
fwrite($fichier, $description);
|
fwrite($fichier, $description);
|
||||||
}
|
}
|
||||||
|
|||||||
358
htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php
Normal file
358
htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php
Normal file
@ -0,0 +1,358 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2007-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2022 Faustin Boitel <fboitel@enseirb-matmeca.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
* or see https://www.gnu.org/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php
|
||||||
|
* \ingroup barcode
|
||||||
|
* \brief File of class to manage barcode numbering with standard rule
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to manage barcode with standard rule
|
||||||
|
*/
|
||||||
|
class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
|
||||||
|
{
|
||||||
|
public $name = 'Standard'; // Model Name
|
||||||
|
|
||||||
|
public $code_modifiable; // Editable code
|
||||||
|
|
||||||
|
public $code_modifiable_invalide; // Modified code if it is invalid
|
||||||
|
|
||||||
|
public $code_modifiable_null; // Modified code if it is null
|
||||||
|
|
||||||
|
public $code_null; // Optional code
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dolibarr version of the loaded document
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Automatic numbering
|
||||||
|
*/
|
||||||
|
public $code_auto;
|
||||||
|
|
||||||
|
public $searchcode; // Search string
|
||||||
|
|
||||||
|
public $numbitcounter; // Number of digits the counter
|
||||||
|
|
||||||
|
public $prefixIsRequired; // The prefix field of third party must be filled when using {pre}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->code_null = 0;
|
||||||
|
$this->code_modifiable = 1;
|
||||||
|
$this->code_modifiable_invalide = 1;
|
||||||
|
$this->code_modifiable_null = 1;
|
||||||
|
$this->code_auto = 1;
|
||||||
|
$this->prefixIsRequired = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Return description of module
|
||||||
|
*
|
||||||
|
* @param Translate $langs Object langs
|
||||||
|
* @return string Description of module
|
||||||
|
*/
|
||||||
|
public function info($langs)
|
||||||
|
{
|
||||||
|
global $conf, $mc;
|
||||||
|
global $form;
|
||||||
|
|
||||||
|
$langs->load("thirdparties");
|
||||||
|
|
||||||
|
$disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
|
||||||
|
|
||||||
|
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
|
||||||
|
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
$texte .= '<input type="hidden" name="page_y" value="">';
|
||||||
|
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
|
||||||
|
$texte .= '<input type="hidden" name="param1" value="BARCODE_STANDARD_THIRDPARTY_MASK">';
|
||||||
|
$texte .= '<table class="nobordernopadding" width="100%">';
|
||||||
|
|
||||||
|
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode"));
|
||||||
|
$tooltip .= $langs->trans("GenericMaskCodes3EAN");
|
||||||
|
$tooltip .= '<strong>'.$langs->trans("Example").':</strong><br>';
|
||||||
|
$tooltip .= '020{000000000}? (for internal use)<br>';
|
||||||
|
$tooltip .= '9771234{00000}? (example of ISSN code with prefix 1234)<br>';
|
||||||
|
$tooltip .= '9791234{00000}? (example of ISMN code with prefix 1234)<br>';
|
||||||
|
//$tooltip.=$langs->trans("GenericMaskCodes5");
|
||||||
|
|
||||||
|
// Mask parameter
|
||||||
|
//$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>';
|
||||||
|
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
|
||||||
|
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK) ? $conf->global->BARCODE_STANDARD_THIRDPARTY_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
|
||||||
|
$texte .= '<td class="left" rowspan="2"> <input type="submit" class="button button-edit reposition" name="modify" value="'.$langs->trans("Modify").'"'.$disabled.'></td>';
|
||||||
|
$texte .= '</tr>';
|
||||||
|
|
||||||
|
$texte .= '</table>';
|
||||||
|
$texte .= '</form>';
|
||||||
|
|
||||||
|
return $texte;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an example of result returned by getNextValue
|
||||||
|
*
|
||||||
|
* @param Translate $langs Object langs
|
||||||
|
* @param Societe $objthirdparty Object third-party
|
||||||
|
* @return string Return string example
|
||||||
|
*/
|
||||||
|
public function getExample($langs, $objthirdparty = 0)
|
||||||
|
{
|
||||||
|
$examplebarcode = $this->getNextValue($objthirdparty, '');
|
||||||
|
if (!$examplebarcode) {
|
||||||
|
$examplebarcode = $langs->trans('NotConfigured');
|
||||||
|
}
|
||||||
|
if ($examplebarcode == "ErrorBadMask") {
|
||||||
|
$langs->load("errors");
|
||||||
|
$examplebarcode = $langs->trans($examplebarcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $examplebarcode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return literal barcode type code from numerical rowid type of barcode
|
||||||
|
*
|
||||||
|
* @param Database $db Database
|
||||||
|
* @param int $type Type of barcode (EAN, ISBN, ...) as rowid
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function literalBarcodeType($db, $type = '')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$out = '';
|
||||||
|
|
||||||
|
$sql = "SELECT rowid, code, libelle as label";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
|
||||||
|
$sql .= " WHERE rowid = '".$db->escape($type)."'";
|
||||||
|
$sql .= " AND entity = ".((int) $conf->entity);
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
|
if ($num > 0) {
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
$out .= $obj->label; //take the label corresponding to the type rowid in the database
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return next value
|
||||||
|
*
|
||||||
|
* @param Societe $objthirdparty Object third-party
|
||||||
|
* @param string $type Type of barcode (EAN, ISBN, ...)
|
||||||
|
* @return string Value if OK, '' if module not configured, <0 if KO
|
||||||
|
*/
|
||||||
|
public function getNextValue($objthirdparty, $type = '')
|
||||||
|
{
|
||||||
|
global $db, $conf;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // to be able to call function barcode_gen_ean_sum($ean)
|
||||||
|
|
||||||
|
if (empty($type)) {
|
||||||
|
$type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY;
|
||||||
|
} //get barcode type configuration for companies if $type not set
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// Get Mask value
|
||||||
|
$mask = '';
|
||||||
|
if (!empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) {
|
||||||
|
$mask = $conf->global->BARCODE_STANDARD_THIRDPARTY_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($mask)) {
|
||||||
|
$this->error = 'NotConfigured';
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$field = 'barcode';
|
||||||
|
$where = '';
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
|
||||||
|
$numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now);
|
||||||
|
//Begin barcode with key: for barcode with key (EAN13...) calculate and substitute the last character (* or ?) used in the mask by the key
|
||||||
|
if ((substr($numFinal, -1)=='*') or (substr($numFinal, -1)=='?')) { // if last mask character is * or ? a joker, probably we have to calculate a key as last character (EAN13...)
|
||||||
|
$literaltype = '';
|
||||||
|
$literaltype = $this->literalBarcodeType($db, $type);//get literal_Barcode_Type
|
||||||
|
switch ($literaltype) {
|
||||||
|
case 'EAN13': //EAN13 rowid = 2
|
||||||
|
if (strlen($numFinal)==13) {// be sure that the mask length is correct for EAN13
|
||||||
|
$ean = substr($numFinal, 0, 12); //take first 12 digits
|
||||||
|
$eansum = barcode_gen_ean_sum($ean);
|
||||||
|
$ean .= $eansum; //substitute the las character by the key
|
||||||
|
$numFinal = $ean;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// Other barcode cases with key could be written here
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//End barcode with key
|
||||||
|
return $numFinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check validity of code according to its rules
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
* @param string $code Code to check/correct
|
||||||
|
* @param Societe $thirdparty Object third-party
|
||||||
|
* @param int $thirdparty_type 0 = customer/prospect , 1 = supplier
|
||||||
|
* @param string $type type of barcode (EAN, ISBN, ...)
|
||||||
|
* @return int 0 if OK
|
||||||
|
* -1 ErrorBadCustomerCodeSyntax
|
||||||
|
* -2 ErrorCustomerCodeRequired
|
||||||
|
* -3 ErrorCustomerCodeAlreadyUsed
|
||||||
|
* -4 ErrorPrefixRequired
|
||||||
|
*/
|
||||||
|
public function verif($db, &$code, $thirdparty, $thirdparty_type, $type)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
//var_dump($code.' '.$thirdparty->ref.' '.$thirdparty_type);exit;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
|
||||||
|
$result = 0;
|
||||||
|
$code = strtoupper(trim($code));
|
||||||
|
|
||||||
|
if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) {
|
||||||
|
$result = 0;
|
||||||
|
} elseif (empty($code) && (!$this->code_null || !empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK))) {
|
||||||
|
$result = -2;
|
||||||
|
} else {
|
||||||
|
if ($this->verif_syntax($code, $type) >= 0) {
|
||||||
|
$is_dispo = $this->verif_dispo($db, $code, $thirdparty);
|
||||||
|
if ($is_dispo <> 0) {
|
||||||
|
$result = -3;
|
||||||
|
} else {
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dol_strlen($code) == 0) {
|
||||||
|
$result = -2;
|
||||||
|
} else {
|
||||||
|
$result = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
/**
|
||||||
|
* Return if a code is used (by other element)
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Handler acces base
|
||||||
|
* @param string $code Code to check
|
||||||
|
* @param Societe $thirdparty Objet third-party
|
||||||
|
* @return int 0 if available, <0 if KO
|
||||||
|
*/
|
||||||
|
public function verif_dispo($db, $code, $thirdparty)
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."societe";
|
||||||
|
$sql .= " WHERE barcode = '".$db->escape($code)."'";
|
||||||
|
if ($thirdparty->id > 0) {
|
||||||
|
$sql .= " AND rowid <> ".$thirdparty->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
if ($db->num_rows($resql) == 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
/**
|
||||||
|
* Return if a barcode value match syntax
|
||||||
|
*
|
||||||
|
* @param string $codefortest Code to check syntax
|
||||||
|
* @param string $typefortest Type of barcode (ISBN, EAN, ...)
|
||||||
|
* @return int 0 if OK, <0 if KO
|
||||||
|
*/
|
||||||
|
public function verif_syntax($codefortest, $typefortest)
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$result = 0;
|
||||||
|
|
||||||
|
// Get Mask value
|
||||||
|
$mask = empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK) ? '' : $conf->global->BARCODE_STANDARD_THIRDPARTY_MASK;
|
||||||
|
if (!$mask) {
|
||||||
|
$this->error = 'NotConfigured';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
|
||||||
|
|
||||||
|
$newcodefortest = $codefortest;
|
||||||
|
|
||||||
|
// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
|
||||||
|
if (in_array($typefortest, array('EAN13', 'ISBN'))) { // We remove the CRC char not included into mask
|
||||||
|
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) {
|
||||||
|
if (strlen($reg[1]) == 12) {
|
||||||
|
$newcodefortest = substr($newcodefortest, 0, 12);
|
||||||
|
}
|
||||||
|
dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = check_value($mask, $newcodefortest);
|
||||||
|
if (is_string($result)) {
|
||||||
|
$this->error = $result;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -897,7 +897,7 @@ Permission701=Read donations
|
|||||||
Permission702=Create/modify donations
|
Permission702=Create/modify donations
|
||||||
Permission703=Delete donations
|
Permission703=Delete donations
|
||||||
Permission771=Read expense reports (yours and your subordinates)
|
Permission771=Read expense reports (yours and your subordinates)
|
||||||
Permission772=Create/modify expense reports (for you and your subordinates)
|
Permission772=Create/modify expense reports (for you and your subordinates)
|
||||||
Permission773=Delete expense reports
|
Permission773=Delete expense reports
|
||||||
Permission775=Approve expense reports
|
Permission775=Approve expense reports
|
||||||
Permission776=Pay expense reports
|
Permission776=Pay expense reports
|
||||||
@ -2169,7 +2169,7 @@ EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax
|
|||||||
PDF_SHOW_PROJECT=Show project on document
|
PDF_SHOW_PROJECT=Show project on document
|
||||||
ShowProjectLabel=Project Label
|
ShowProjectLabel=Project Label
|
||||||
PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME=Include alias in thirdparty name
|
PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME=Include alias in thirdparty name
|
||||||
THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty
|
THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty
|
||||||
ALIAS_THIRDPARTY=Alias thirdparty - Name thirdparty
|
ALIAS_THIRDPARTY=Alias thirdparty - Name thirdparty
|
||||||
PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF.
|
PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF.
|
||||||
PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF
|
PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF
|
||||||
@ -2277,4 +2277,9 @@ INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their i
|
|||||||
INVOICE_ADD_SWISS_QR_CODE=Show the swiss QR-Bill code on invoices
|
INVOICE_ADD_SWISS_QR_CODE=Show the swiss QR-Bill code on invoices
|
||||||
UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID.
|
UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID.
|
||||||
IfThisCategoryIsChildOfAnother=If this category is a child of another one
|
IfThisCategoryIsChildOfAnother=If this category is a child of another one
|
||||||
|
DarkThemeMode=Dark theme mode
|
||||||
|
AlwaysDisabled=Always disabled
|
||||||
|
AccordingToBrowser=According to browser
|
||||||
|
AlwaysEnabled=Always Enabled
|
||||||
|
DoesNotWorkWithAllThemes=Will not work with all themes
|
||||||
NoName=No name
|
NoName=No name
|
||||||
|
|||||||
@ -190,7 +190,7 @@ Compression=Compression
|
|||||||
CommandsToDisableForeignKeysForImport=Commande pour désactiver les clés étrangères à l'importation
|
CommandsToDisableForeignKeysForImport=Commande pour désactiver les clés étrangères à l'importation
|
||||||
CommandsToDisableForeignKeysForImportWarning=Requis si vous voulez être en mesure de restaurer votre « dump » SQL plus tard
|
CommandsToDisableForeignKeysForImportWarning=Requis si vous voulez être en mesure de restaurer votre « dump » SQL plus tard
|
||||||
ExportCompatibility=Compatibilité du fichier d'exportation généré
|
ExportCompatibility=Compatibilité du fichier d'exportation généré
|
||||||
ExportUseMySQLQuickParameter=Utiliser le paramètre --quick
|
ExportUseMySQLQuickParameter=Utiliser le paramètre --quick
|
||||||
ExportUseMySQLQuickParameterHelp=Le paramètre '--quick' aide à réduire la consommation de RAM pour les longues listes
|
ExportUseMySQLQuickParameterHelp=Le paramètre '--quick' aide à réduire la consommation de RAM pour les longues listes
|
||||||
MySqlExportParameters=Paramètres de l'exportation MySQL
|
MySqlExportParameters=Paramètres de l'exportation MySQL
|
||||||
PostgreSqlExportParameters= Paramètres de l'exportation PostgreSQL
|
PostgreSqlExportParameters= Paramètres de l'exportation PostgreSQL
|
||||||
@ -338,7 +338,7 @@ MenuHandlers=Gestionnaires de menu
|
|||||||
MenuAdmin=Édition menu
|
MenuAdmin=Édition menu
|
||||||
DoNotUseInProduction=Ne pas utiliser en production
|
DoNotUseInProduction=Ne pas utiliser en production
|
||||||
ThisIsProcessToFollow=Procédure de mise à jour:
|
ThisIsProcessToFollow=Procédure de mise à jour:
|
||||||
ThisIsAlternativeProcessToFollow=Voici une procédure de configuration alternative
|
ThisIsAlternativeProcessToFollow=Voici une procédure de configuration alternative
|
||||||
StepNb=Étape %s
|
StepNb=Étape %s
|
||||||
FindPackageFromWebSite=Rechercher le paquet qui répond à votre besoin (par exemple sur le site web %s).
|
FindPackageFromWebSite=Rechercher le paquet qui répond à votre besoin (par exemple sur le site web %s).
|
||||||
DownloadPackageFromWebSite=Télécharger le package (par exemple depuis le site web officiel %s)
|
DownloadPackageFromWebSite=Télécharger le package (par exemple depuis le site web officiel %s)
|
||||||
@ -1377,7 +1377,7 @@ NumberingModules=Modèles de numérotation
|
|||||||
DocumentModules=Modèles de documents
|
DocumentModules=Modèles de documents
|
||||||
##### Module password generation
|
##### Module password generation
|
||||||
PasswordGenerationStandard=Renvoie un mot de passe généré selon l'algorythme interne de Dolibarr :%s caractères contenant chiffres et minuscules
|
PasswordGenerationStandard=Renvoie un mot de passe généré selon l'algorythme interne de Dolibarr :%s caractères contenant chiffres et minuscules
|
||||||
PasswordGenerationNone=Ne pas suggérer un mot de passe généré. Le mot de passe doit être entré manuellement.
|
PasswordGenerationNone=Ne pas suggérer un mot de passe généré. Le mot de passe doit être entré manuellement.
|
||||||
PasswordGenerationPerso=Renvoie un mot de passe en fonction d'une configuration personnalisée.
|
PasswordGenerationPerso=Renvoie un mot de passe en fonction d'une configuration personnalisée.
|
||||||
SetupPerso=Selon votre configuration
|
SetupPerso=Selon votre configuration
|
||||||
PasswordPatternDesc=Description du masque du mot de passe
|
PasswordPatternDesc=Description du masque du mot de passe
|
||||||
@ -1455,7 +1455,7 @@ OrdersNumberingModules=Modèles de numérotation des commandes
|
|||||||
OrdersModelModule=Modèles de document des commandes
|
OrdersModelModule=Modèles de document des commandes
|
||||||
FreeLegalTextOnOrders=Mention complémentaire sur les commandes
|
FreeLegalTextOnOrders=Mention complémentaire sur les commandes
|
||||||
WatermarkOnDraftOrders=Filigrane sur les brouillons de commandes (aucun si vide)
|
WatermarkOnDraftOrders=Filigrane sur les brouillons de commandes (aucun si vide)
|
||||||
ShippableOrderIconInList=Ajouter une icône dans la liste des commandes qui indique si la commande est expédiable.
|
ShippableOrderIconInList=Ajouter une icône dans la liste des commandes qui indique si la commande est expédiable.
|
||||||
BANK_ASK_PAYMENT_BANK_DURING_ORDER=Demander le compte bancaire cible durant la commande
|
BANK_ASK_PAYMENT_BANK_DURING_ORDER=Demander le compte bancaire cible durant la commande
|
||||||
##### Interventions #####
|
##### Interventions #####
|
||||||
InterventionsSetup=Configuration du module Interventions
|
InterventionsSetup=Configuration du module Interventions
|
||||||
@ -1645,7 +1645,7 @@ TestNotPossibleWithCurrentBrowsers=Une détection automatique n'est pas possible
|
|||||||
DefaultValuesDesc=Vous pouvez définir/forcer ici la valeur par défaut que vous voulez obtenir lorsque vous créez un nouvel enregistrement, et/ou les filtres par défaut ou ordre de tri des listes.
|
DefaultValuesDesc=Vous pouvez définir/forcer ici la valeur par défaut que vous voulez obtenir lorsque vous créez un nouvel enregistrement, et/ou les filtres par défaut ou ordre de tri des listes.
|
||||||
DefaultCreateForm=Valeurs par défaut (sur les formulaires de création)
|
DefaultCreateForm=Valeurs par défaut (sur les formulaires de création)
|
||||||
DefaultSearchFilters=Filtres de recherche par défaut
|
DefaultSearchFilters=Filtres de recherche par défaut
|
||||||
DefaultSortOrder=Ordre de tri par défaut
|
DefaultSortOrder=Ordre de tri par défaut
|
||||||
DefaultFocus=Champs par défaut ayant le focus
|
DefaultFocus=Champs par défaut ayant le focus
|
||||||
DefaultMandatory=Champs de formulaire obligatoires
|
DefaultMandatory=Champs de formulaire obligatoires
|
||||||
##### Products #####
|
##### Products #####
|
||||||
@ -1864,7 +1864,7 @@ ChequeReceiptsNumberingModule=Module de numérotation des bordereaux de remises
|
|||||||
MultiCompanySetup=Configuration du module Multi-société
|
MultiCompanySetup=Configuration du module Multi-société
|
||||||
##### Suppliers #####
|
##### Suppliers #####
|
||||||
SuppliersSetup=Configuration du module Fournisseurs
|
SuppliersSetup=Configuration du module Fournisseurs
|
||||||
SuppliersCommandModel=Modèle de commande fournisseur complet
|
SuppliersCommandModel=Modèle de commande fournisseur complet
|
||||||
SuppliersCommandModelMuscadet=Modèle de commande fournisseur complet (ancienne implémentation du modèle Cornas)
|
SuppliersCommandModelMuscadet=Modèle de commande fournisseur complet (ancienne implémentation du modèle Cornas)
|
||||||
SuppliersInvoiceModel=Modèle de facture fournisseur complet
|
SuppliersInvoiceModel=Modèle de facture fournisseur complet
|
||||||
SuppliersInvoiceNumberingModel=Modèles de numérotation des factures fournisseur
|
SuppliersInvoiceNumberingModel=Modèles de numérotation des factures fournisseur
|
||||||
@ -1899,7 +1899,7 @@ NbMajMin=Nombre minimal de caractères majuscules
|
|||||||
NbNumMin=Nombre minimal de caractères numériques
|
NbNumMin=Nombre minimal de caractères numériques
|
||||||
NbSpeMin=Nombre minimal de caractères spéciaux
|
NbSpeMin=Nombre minimal de caractères spéciaux
|
||||||
NbIteConsecutive=Nombre maximal de répétition des mêmes caractères
|
NbIteConsecutive=Nombre maximal de répétition des mêmes caractères
|
||||||
NoAmbiCaracAutoGeneration=Ne pas utiliser des caractères ambigus ("1","l","i","|","0","O") pour la génération automatique
|
NoAmbiCaracAutoGeneration=Ne pas utiliser des caractères ambigus ("1","l","i","|","0","O") pour la génération automatique
|
||||||
SalariesSetup=Configuration du module salaires
|
SalariesSetup=Configuration du module salaires
|
||||||
SortOrder=Ordre de tri
|
SortOrder=Ordre de tri
|
||||||
Format=Format
|
Format=Format
|
||||||
@ -1920,7 +1920,7 @@ GoOntoContactCardToAddMore=Rendez-vous sur l'onglet "Notifications" d'un tiers p
|
|||||||
Threshold=Seuil
|
Threshold=Seuil
|
||||||
BackupDumpWizard=Assistant pour créer le fichier dump de la base de données
|
BackupDumpWizard=Assistant pour créer le fichier dump de la base de données
|
||||||
BackupZipWizard=Assistant pour générer l'archive du répertoire documents
|
BackupZipWizard=Assistant pour générer l'archive du répertoire documents
|
||||||
SomethingMakeInstallFromWebNotPossible=L'installation de module externe est impossible depuis l'interface web pour la raison suivante :
|
SomethingMakeInstallFromWebNotPossible=L'installation de module externe est impossible depuis l'interface web pour la raison suivante :
|
||||||
SomethingMakeInstallFromWebNotPossible2=Pour cette raison, le processus de mise à jour décrit ici est une processus manuel que seul un utilisateur ayant des droits privilégiés peut réaliser.
|
SomethingMakeInstallFromWebNotPossible2=Pour cette raison, le processus de mise à jour décrit ici est une processus manuel que seul un utilisateur ayant des droits privilégiés peut réaliser.
|
||||||
InstallModuleFromWebHasBeenDisabledByFile=L'installation de module externe depuis l'application a été désactivé par l'administrator. Vous devez lui demander de supprimer le fichier <strong>%s</strong> pour permettre cette fonctionnalité.
|
InstallModuleFromWebHasBeenDisabledByFile=L'installation de module externe depuis l'application a été désactivé par l'administrator. Vous devez lui demander de supprimer le fichier <strong>%s</strong> pour permettre cette fonctionnalité.
|
||||||
ConfFileMustContainCustom=Installer ou créer un module externe à partir de l'application nécessite de sauvegarder les fichiers du module dans le répertoire <strong>%s</strong>. Pour que ce répertoire soit reconnu par Dolibarr, vous devez paramétrer le fichier de configuration <strong>conf/conf.php</strong> en ajoutant les 2 lignes suivantes :<br><strong>$dolibarr_main_url_root_alt='/custom'</strong><br><strong>$dolibarr_main_document_root_alt='%s/custom';</strong>
|
ConfFileMustContainCustom=Installer ou créer un module externe à partir de l'application nécessite de sauvegarder les fichiers du module dans le répertoire <strong>%s</strong>. Pour que ce répertoire soit reconnu par Dolibarr, vous devez paramétrer le fichier de configuration <strong>conf/conf.php</strong> en ajoutant les 2 lignes suivantes :<br><strong>$dolibarr_main_url_root_alt='/custom'</strong><br><strong>$dolibarr_main_document_root_alt='%s/custom';</strong>
|
||||||
@ -2263,3 +2263,8 @@ IconOnly=Icon only - Text on tooltip only
|
|||||||
INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices
|
INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices
|
||||||
INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices
|
INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices
|
||||||
UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID.
|
UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID.
|
||||||
|
DarkThemeMode=Mode thème sombre
|
||||||
|
AlwaysDisabled=Toujours désactivé
|
||||||
|
AccordingToBrowser=Selon le navigateur
|
||||||
|
AlwaysEnabled=Toujours activé
|
||||||
|
DoesNotWorkWithAllThemes=Ne fonctionne pas avec tous les thèmes
|
||||||
Loading…
Reference in New Issue
Block a user