|
@@ -63,7 +63,7 @@ if ($action == 'setcoder')
|
|
|
$resql=$db->query($sqlp);
|
|
|
if (! $resql) dol_print_error($db);
|
|
|
}
|
|
|
-else if ($action == 'update')
|
|
|
+elseif ($action == 'update')
|
|
|
{
|
|
|
$location = GETPOST('GENBARCODE_LOCATION','alpha');
|
|
|
$res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity);
|
|
@@ -71,17 +71,8 @@ else if ($action == 'update')
|
|
|
$res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity);
|
|
|
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha');
|
|
|
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity);
|
|
|
-}
|
|
|
-else if ($action == 'updateengine')
|
|
|
-{
|
|
|
- // TODO Update engines.
|
|
|
-}
|
|
|
-
|
|
|
-if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
|
|
|
-{
|
|
|
- if (! $res > 0) $error++;
|
|
|
|
|
|
- if (! $error)
|
|
|
+ if ($res > 0)
|
|
|
{
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
|
}
|
|
@@ -90,6 +81,42 @@ if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
|
}
|
|
|
}
|
|
|
+elseif ($action == 'updateengine')
|
|
|
+{
|
|
|
+ $sql = "SELECT rowid, coder";
|
|
|
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
|
|
|
+ $sql.= " WHERE entity = ".$conf->entity;
|
|
|
+ $sql.= " ORDER BY code";
|
|
|
+
|
|
|
+ $resql=$db->query($sql);
|
|
|
+ if ($resql)
|
|
|
+ {
|
|
|
+ $num = $db->num_rows($resql);
|
|
|
+ $i = 0;
|
|
|
+
|
|
|
+ while ($i < $num)
|
|
|
+ {
|
|
|
+ $obj = $db->fetch_object($resql);
|
|
|
+
|
|
|
+ if (GETPOST('coder'.$obj->rowid, 'alpha'))
|
|
|
+ {
|
|
|
+ $coder = GETPOST('coder'.$obj->rowid,'alpha');
|
|
|
+ $code_id = $obj->rowid;
|
|
|
+
|
|
|
+ $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
|
|
|
+ $sqlp.= " SET coder = '" . $coder."'";
|
|
|
+ $sqlp.= " WHERE rowid = ". $code_id;
|
|
|
+ $sqlp.= " AND entity = ".$conf->entity;
|
|
|
+
|
|
|
+ $upsql=$db->query($sqlp);
|
|
|
+ if (! $upsql) dol_print_error($db);
|
|
|
+ }
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
/*
|
|
|
* View
|
|
@@ -161,9 +188,12 @@ foreach($dirbarcode as $reldir)
|
|
|
print '<br>';
|
|
|
print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'','');
|
|
|
|
|
|
-//print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
|
|
|
-//print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
-//print "<input type=\"hidden\" name=\"action\" value=\"updateengine\">";
|
|
|
+if (empty($conf->use_javascript_ajax))
|
|
|
+{
|
|
|
+ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
|
|
|
+ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
+ print '<input type="hidden" name="action" value="updateengine">';
|
|
|
+}
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
print '<tr class="liste_titre">';
|
|
@@ -258,10 +288,9 @@ print "</table>\n";
|
|
|
|
|
|
if (empty($conf->use_javascript_ajax))
|
|
|
{
|
|
|
- // TODO Implement code behind action updateengine
|
|
|
- //print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>';
|
|
|
+ print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>';
|
|
|
+ print '</form>';
|
|
|
}
|
|
|
-//print '</form>';
|
|
|
|
|
|
print "<br>";
|
|
|
|