25require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/inventory/class/inventory.class.php';
39$langs->loadLangs(array(
"admin",
"errors",
"stocks"));
47$action =
GETPOST(
'action',
'aZ09');
48$value =
GETPOST(
'value',
'alpha');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
59if ($action ==
'updateMask') {
60 $maskconstinventory =
GETPOST(
'maskconstinventory',
'aZ09');
61 $maskinventory =
GETPOST(
'maskInventory',
'alpha');
63 if ($maskconstinventory && preg_match(
'/_MASK$/', $maskconstinventory)) {
75} elseif ($action ==
'specimen') {
76 $modele =
GETPOST(
'module',
'alpha');
79 $tmpobject->initAsSpecimen();
84 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
85 foreach ($dirmodels as $reldir) {
86 $file =
dol_buildpath($reldir.
"core/modules/inventory/doc/pdf_".$modele.
".modules.php", 0);
87 if (file_exists($file)) {
88 $classname =
"pdf_".$modele;
93 if ($classname !==
'') {
96 $module =
new $classname(
$db);
97 '@phan-var-force ModelePDFInventory $module';
100 if ($module->write_file($tmpobject, $langs) > 0) {
101 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=inventory&file=SPECIMEN.pdf");
109 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
111} elseif ($action ==
'set') {
113} elseif ($action ==
'del') {
120} elseif ($action ==
'setdoc') {
124 $conf->global->INVENTORY_ADDON_PDF = $value;
132} elseif ($action ==
'setmod') {
144$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
146$page_name =
"StockSetup";
147llxHeader(
'', $langs->trans($page_name),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-inventory');
150$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
159print
load_fiche_titre($langs->trans(
"NumberingModules", $langs->transnoentities(
"Inventory")),
'',
'');
161print
'<div class="div-table-responsive-no-min">';
162print
'<table class="noborder centpercent">';
163print
'<tr class="liste_titre">';
164print
'<td>'.$langs->trans(
"Name").
'</td>';
165print
'<td>'.$langs->trans(
"Description").
'</td>';
166print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
167print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
168print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
173foreach ($dirmodels as $reldir) {
177 $handle = opendir($dir);
178 if (is_resource($handle)) {
179 while (($file = readdir($handle)) !==
false) {
180 if (strpos($file,
'mod_inventory_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
181 $file = substr($file, 0,
dol_strlen($file) - 4);
183 require_once $dir.
'/'.$file.
'.php';
185 $module =
new $file(
$db);
187 '@phan-var-force ModeleNumRefInventory $module';
190 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
193 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
197 if ($module->isEnabled()) {
198 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
199 print $module->info($langs);
203 print
'<td class="nowrap">';
204 $tmp = $module->getExample();
205 if (preg_match(
'/^Error/', $tmp)) {
206 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
207 } elseif ($tmp ==
'NotConfigured') {
208 print $langs->trans($tmp);
214 print
'<td class="center">';
216 print
img_picto($langs->trans(
"Activated"),
'switch_on');
218 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
219 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
225 $mytmpinstance->initAsSpecimen();
229 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
231 $nextval = $module->getNextValue($mytmpinstance);
232 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
233 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
235 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
236 $nextval = $langs->trans($nextval);
238 $htmltooltip .= $nextval.
'<br>';
240 $htmltooltip .= $langs->trans(
"InventoryRefTypedManually").
'<br>';
244 print
'<td class="center">';
245 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
256print
"</table></div><br>\n";
259print
load_fiche_titre($langs->trans(
"DocumentModules", $langs->transnoentities(
"Inventory")),
'',
'');
264$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
265$sql .=
" WHERE type = 'inventory'";
266$sql .=
" AND entity = ".((int)
$conf->entity);
267$resql =
$db->query($sql);
270 $num_rows =
$db->num_rows($resql);
271 while ($i < $num_rows) {
272 $array =
$db->fetch_array($resql);
273 if (is_array($array)) {
274 array_push($def, $array[0]);
282print
'<div class="div-table-responsive">';
283print
'<table class="noborder centpercent">'.
"\n";
284print
'<tr class="liste_titre">'.
"\n";
285print
'<td>'.$langs->trans(
"Name").
'</td>';
286print
'<td>'.$langs->trans(
"Description").
'</td>';
287print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
288print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
289print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
290print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
295foreach ($dirmodels as $reldir) {
296 foreach (array(
'',
'/doc') as $valdir) {
297 $realpath = $reldir.
"core/modules/inventory".$valdir;
301 $handle = opendir($dir);
302 if (is_resource($handle)) {
304 while (($file = readdir($handle)) !==
false) {
310 foreach ($filelist as $file) {
311 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
312 if (file_exists($dir.
'/'.$file)) {
313 $name = substr($file, 4,
dol_strlen($file) - 16);
314 $classname = substr($file, 0,
dol_strlen($file) - 12);
316 require_once $dir.
'/'.$file;
317 $module =
new $classname(
$db);
319 '@phan-var-force ModelePDFInventory $module';
321 $modulequalified = 1;
322 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
323 $modulequalified = 0;
325 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
326 $modulequalified = 0;
329 if ($modulequalified) {
330 print
'<tr class="oddeven"><td>';
331 print(empty($module->name) ? $name : $module->
name);
333 if (method_exists($module,
'info')) {
334 print $module->info($langs);
336 print $module->description;
341 if (in_array($name, $def)) {
342 print
'<td class="center">'.
"\n";
343 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.urlencode($name).
'&token='.
newToken().
'">';
344 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
348 print
'<td class="center">'.
"\n";
349 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&token='.
newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
354 print
'<td class="center">';
356 print
img_picto($langs->trans(
"Default"),
'on');
358 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
363 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
364 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
365 if ($module->type ==
'pdf') {
366 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
368 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
370 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
371 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
372 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
374 print
'<td class="center">';
375 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
379 print
'<td class="center">';
380 if ($module->type ==
'pdf') {
381 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&token='.
newToken().
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
383 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
397print
'</table></div>';
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
stock_admin_prepare_head()
Return array head with list of tabs to view object information.