diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 9425cbc667b65af09cf91cb621b90efe6f80c6ec..72d50cebd2826486ca114d7d8526fecd709526fb 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -39,7 +39,15 @@ $action = GETPOST('action','alpha'); * Actions */ -if ($action == 'setcoder') +if ($action == 'setbarcodeon') +{ + $res=dolibarr_set_const($db, "BARCODE_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity); +} +elseif ($action == 'setbarcodeoff') +{ + $res=dolibarr_del_const($db, "BARCODE_ADDON_NUM", $conf->entity); +} +else if ($action == 'setcoder') { $coder = GETPOST('coder','alpha'); $code_id = GETPOST('code_id','alpha'); @@ -49,33 +57,54 @@ if ($action == 'setcoder') $sqlp.= " AND entity = ".$conf->entity; $resql=$db->query($sqlp); - //print $sqlp; + if (! $resql) dol_print_error($db); } -else if ($action == 'setgenbarcodelocation') +else if ($action == 'update') { - $location = GETPOST('genbarcodelocation','alpha'); - $res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity); -} -else if ($action == 'setdefaultbarcodetype') -{ - $coder_id = GETPOST('coder_id','alpha'); - $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity); + if (GETPOST('submit_GENBARCODE_LOCATION')) + { + $location = GETPOST('genbarcodelocation','alpha'); + $res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity); + } + if (GETPOST('submit_PRODUIT_DEFAULT_BARCODE_TYPE')) + { + $coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE','alpha'); + $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity); + } + if (GETPOST('submit_GENBARCODE_BARCODETYPE_THIRDPARTY')) + { + $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha'); + $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); + } } -else if ($action == 'GENBARCODE_BARCODETYPE_THIRDPARTY') + +// define constants for models generator that need parameters +if ($action == 'setModuleOptions') { - $coder_id = GETPOST('coder_id','alpha'); - $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); + $post_size=count($_POST); + + for($i=0;$i < $post_size;$i++) + { + if (array_key_exists('param'.$i,$_POST)) + { + $param=GETPOST("param".$i,'alpha'); + $value=GETPOST("value".$i,'alpha'); + if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + } + } + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } } -/* - else if ($_POST["action"] == 'setproductusebarcode') - { - dolibarr_set_const($db, "PRODUIT_USE_BARCODE",$_POST["value"],'chaine',0,'',$conf->entity); - header("Location: barcode.php"); - exit; - } - */ -if($action && $action!='setcoder') +if ($action && $action != 'setcoder' && $action != 'setModuleOptions') { if (! $res > 0) $error++; @@ -259,6 +288,10 @@ print "<br>"; */ print_titre($langs->trans("OtherOptions")); +print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">"; +print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; +print "<input type=\"hidden\" name=\"action\" value=\"update\">"; + $var=true; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; @@ -271,20 +304,17 @@ print '</tr>'; if (! isset($_SERVER['WINDIR'])) { $var=!$var; - print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="setgenbarcodelocation">'; print '<tr '.$bc[$var].'>'; print '<td>'.$langs->trans("GenbarcodeLocation").'</td>'; print '<td width="60" align="center">'; - print '<input type="text" size="40" name="genbarcodelocation" value="'.$conf->global->GENBARCODE_LOCATION.'">'; + print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">'; if (! empty($conf->global->GENBARCODE_LOCATION) && ! @file_exists($conf->global->GENBARCODE_LOCATION)) { $langs->load("errors"); print '<br><font class="error">'.$langs->trans("ErrorFileNotFound",$conf->global->GENBARCODE_LOCATION).'</font>'; } print '</td>'; - print '<td width="60" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; + print '<td width="60" align="center"><input type="submit" class="button" name="submit_GENBARCODE_LOCATION" value="'.$langs->trans("Modify").'"></td>'; print '</tr>'; print '</form>'; } @@ -293,43 +323,108 @@ if (! isset($_SERVER['WINDIR'])) if (! empty($conf->product->enabled)) { $var=!$var; - print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">"; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print "<input type=\"hidden\" name=\"action\" value=\"setdefaultbarcodetype\">"; print "<tr ".$bc[$var].">"; print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>'; print '<td width="60" align="right">'; - print $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"coder_id",1); + print $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"PRODUIT_DEFAULT_BARCODE_TYPE",1); print '</td><td align="right">'; - print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; + print '<input type="submit" class="button" name="submit_PRODUIT_DEFAULT_BARCODE_TYPE" value="'.$langs->trans("Modify").'">'; print "</td>"; print '</tr>'; - print '</form>'; } // Module thirdparty if (! empty($conf->societe->enabled)) { $var=!$var; - print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">"; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print "<input type=\"hidden\" name=\"action\" value=\"GENBARCODE_BARCODETYPE_THIRDPARTY\">"; print "<tr ".$bc[$var].">"; print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>'; print '<td width="60" align="right">'; - print $formbarcode->select_barcode_type($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,"coder_id",1); + print $formbarcode->select_barcode_type($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,"GENBARCODE_BARCODETYPE_THIRDPARTY",1); print '</td><td align="right">'; - print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; + print '<input type="submit" class="button" name="submit_GENBARCODE_BARCODETYPE_THIRDPARTY" value="'.$langs->trans("Modify").'">'; print "</td>"; print '</tr>'; - print '</form>'; } -print '</table>'; +print "</table>\n"; + +print '<br>'; + +// Select barcode numbering module + +print_titre($langs->trans("BarCodeNumberManager")); + +print '<table class="noborder" width="100%">'; +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 align="center" width="80">'.$langs->trans("Status").'</td>'; +print '<td align="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_.*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(); + $var = !$var; + + print '<tr '.$bc[$var].'>'; + print '<td>'.$modBarCode->nom."</td><td>\n"; + print $modBarCode->info($langs); + print '</td>'; + print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n"; + + if ($conf->global->BARCODE_ADDON_NUM == "$file") + { + print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeoff&value='.$file.'">'; + print img_picto($langs->trans("Activated"),'switch_on'); + print '</a></td>'; + } + else + { + print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeon&value='.$file.'">'; + print img_picto($langs->trans("Disabled"),'switch_off'); + print '</a></td>'; + } + print '<td align="center">'; + $s=$modBarCode->getToolTip($langs,null,-1); + print $form->textwithpicto('',$s,1); + print '</td>'; + print "</tr>\n"; + } + } + closedir($handle); + } +} +print "</table>\n"; + +print '</form>'; print "<br>"; $db->close(); llxFooter(); -?> +?> \ No newline at end of file diff --git a/htdocs/core/modules/barcode/mod_barcode_standard.php b/htdocs/core/modules/barcode/mod_barcode_standard.php index d1963c992f869634722610e321e89db4e232d0c0..b543c1d3221bb95c9db729c86ae00ab03611e7ff 100644 --- a/htdocs/core/modules/barcode/mod_barcode_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_standard.php @@ -81,14 +81,15 @@ class mod_barcode_standard extends ModeleNumRefBarCode $texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_MASK">'; $texte.= '<table class="nobordernopadding" width="100%">'; - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Product"),$langs->transnoentities("Product")); + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode")); $tooltip.=$langs->trans("GenericMaskCodes3"); $tooltip.=$langs->trans("GenericMaskCodes4c"); $tooltip.=$langs->trans("GenericMaskCodes5"); // Mask parameter - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; + //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_MASK)?$conf->global->BARCODE_STANDARD_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>'; $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; $texte.= '</tr>'; @@ -102,43 +103,24 @@ class mod_barcode_standard extends ModeleNumRefBarCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs + * @param Translate $langs Object langs * @param product $objproduct Object product - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example + * @return string Return string example */ - function getExample($langs,$objproduct=0,$type=-1) + function getExample($langs,$objproduct=0) { - if ($type == 0 || $type == -1) + $examplebarcode = $this->getNextValue($objproduct,0); + if (! $examplebarcode) { - $exampleproduct = $this->getNextValue($objproduct,0); - if (! $exampleproduct) - { - $exampleproduct = $langs->trans('NotConfigured'); - } - if($exampleproduct=="ErrorBadMask") - { - $langs->load("errors"); - $exampleproduct=$langs->trans($exampleproduct); - } + $examplebarcode = $langs->trans('NotConfigured'); } - if ($type == 1 || $type == -1) + if($examplebarcode=="ErrorBadMask") { - $exampleservice = $this->getNextValue($objproduct,1); - if (! $exampleservice) - { - $exampleservice = $langs->trans('NotConfigured'); - } - if($exampleservice=="ErrorBadMask") - { - $langs->load("errors"); - $exampleservice=$langs->trans($exampleservice); - } + $langs->load("errors"); + $examplebarcode=$langs->trans($examplebarcode); } - if ($type == 0) return $exampleproduct; - if ($type == 1) return $exampleservice; - return $exampleproduct.'<br>'.$exampleservice; + return $examplebarcode; } /** @@ -175,7 +157,7 @@ class mod_barcode_standard extends ModeleNumRefBarCode return $numFinal; } - + /** * Check if mask/numbering use prefix * diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 6e84a65a6aa6509ec3bcad609796c48fc37d3a4d..888d714d63aa6aff593292530c4621f6989128cd 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -52,8 +52,125 @@ abstract class ModeleNumRefBarCode { var $error=''; + /** Renvoi la description par defaut du modele de numerotation + * + * @param Translate $langs Object langs + * @return string Texte descripif + */ + function info($langs) + { + $langs->load("bills"); + return $langs->trans("NoDescription"); + } + + /** Renvoi nom module + * + * @param Translate $langs Object langs + * @return string Nom du module + */ + function getNom($langs) + { + return $this->nom; + } + + /** Renvoi un exemple de numerotation + * + * @param Translate $langs Object langs + * @return string Example + */ + function getExample($langs) + { + $langs->load("bills"); + return $langs->trans("NoExample"); + } + /** + * Return next value available + * + * @param Societe $objsoc Object thirdparty + * @param int $type Type + * @return string Value + */ + function getNextValue($objsoc=0,$type=-1) + { + global $langs; + return $langs->trans("Function_getNextValue_InModuleNotWorking"); + } + + /** Return version of module + * + * @return string Version + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + return $langs->trans("NotAvailable"); + } + + /** + * Return description of module parameters + * + * @param Translate $langs Output language + * @param Societe $soc Third party object + * @param int $type -1=Nothing, 0=Product, 1=Service + * @return string HTML translated description + */ + function getToolTip($langs,$soc,$type) + { + global $conf; + + $langs->load("admin"); + + $s=''; + $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; + if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; + $s.='<br>'; + $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; + if ($type == 0) + { + $s.=$langs->trans("RequiredIfProduct").': '; + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; + $s.=yn(!$this->code_null,1,2); + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; + $s.='<br>'; + } + if ($type == 1) + { + $s.=$langs->trans("RequiredIfService").': '; + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; + $s.=yn(!$this->code_null,1,2); + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; + $s.='<br>'; + } + if ($type == -1) + { + $s.=$langs->trans("Required").': '; + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; + $s.=yn(!$this->code_null,1,2); + if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; + $s.='<br>'; + } + /*$s.=$langs->trans("CanBeModifiedIfOk").': '; + $s.=yn($this->code_modifiable,1,2); + $s.='<br>'; + $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; + */ + $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; + $s.='<br>'; + + $nextval=$this->getNextValue($soc,0); + if (empty($nextval)) $nextval=$langs->trans("Undefined"); + $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>'; + + return $s; + } + } ?> diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index da9ac62aaf8251ccdb89185a5dd2b25f47c28763..dfcd5c5d27c5c5f65bb8c29698481e7651d6c0f4 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1325,6 +1325,7 @@ BarcodeDescC39=Barcode of type C39 BarcodeDescC128=Barcode of type C128 GenbarcodeLocation=Bar code generation command line tool (used by internal engine for some bar code types) BarcodeInternalEngine=Internal engine +BarCodeNumberManager=Manager to auto define barcode numbers ##### Prelevements ##### WithdrawalsSetup=Withdrawal module setup ##### ExternalRSS ##### @@ -1366,17 +1367,6 @@ OSCommerceErrorConnectOkButWrongDatabase=Connection succeeded but database doesn OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' successfull. OSCommerceTestKo1=Connection to server '%s' succeed but database '%s' could not be reached. OSCommerceTestKo2=Connection to server '%s' with user '%s' failed. -##### Mantis ##### -MantisSetup=Mantis link setup -MantisURL=URL for Mantis access -MantisServer=Server hosting Mantis database -MantisDatabaseName=Database name -MantisUser=User to access database -MantisSetupSaved=Mantis setup saved successfully. -MantisTestOk=Connection to server '%s' on database '%s' with user '%s' successfull. -MantisTestKo1=Connection to server '%s' succeed but database '%s' could not be reached. -MantisTestKo2=Connection to server '%s' with user '%s' failed. -MantisErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to be a Mantis database. ##### Stock ##### StockSetup=Configuration module stock UserWarehouse=Use user personal stocks