29require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer.lib.php';
45$langs->loadLangs(array(
"admin",
"stocks"));
53$action =
GETPOST(
'action',
'alpha');
54$backtopage =
GETPOST(
'backtopage',
'alpha');
56$value =
GETPOST(
'value',
'alpha');
57$label =
GETPOST(
'label',
'alpha');
58$scandir =
GETPOST(
'scan_dir',
'alpha');
60$arrayofparameters = array(
61 'STOCKTRANSFER_MYPARAM1' => array(
'css' =>
'minwidth200',
'enabled' => 1),
62 'STOCKTRANSFER_MYPARAM2' => array(
'css' =>
'minwidth500',
'enabled' => 1)
72include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
75if ($action ==
'updateMask') {
76 $maskconststocktransfer =
GETPOST(
'maskconststocktransfer',
'aZ09');
77 $maskstocktransfer =
GETPOST(
'maskStockTransfer',
'alpha');
79 if ($maskconststocktransfer && preg_match(
'/_MASK$/', $maskconststocktransfer)) {
80 $res =
dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer,
'chaine', 0,
'', $conf->entity);
91} elseif ($action ==
'specimen') {
92 $modele =
GETPOST(
'module',
'alpha');
93 $tmpobjectkey =
'StockTransfer';
95 $tmpobject =
new $tmpobjectkey($db);
96 $tmpobject->initAsSpecimen();
101 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
102 foreach ($dirmodels as $reldir) {
103 $file =
dol_buildpath($reldir.
"core/modules/stocktransfer/doc/pdf_".$modele.
".modules.php", 0);
104 if (file_exists($file)) {
105 $classname =
"pdf_".$modele;
110 if ($classname !==
'') {
113 $module =
new $classname($db);
114 '@phan-var-force ModelePDFStockTransfer $module';
117 if ($module->write_file($tmpobject, $langs) > 0) {
118 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
126 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
128} elseif ($action ==
'set') {
130} elseif ($action ==
'del') {
131 $tmpobjectkey =
'StockTransfer';
135 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
140} elseif ($action ==
'setdoc') {
141 $tmpobjectkey =
'StockTransfer';
142 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
146 $conf->global->$constforval = $value;
154} elseif ($action ==
'setmod') {
157 $tmpobjectkey =
'StockTransfer';
158 $constforval =
'STOCKTRANSFER_'.strtoupper($tmpobjectkey).
"_ADDON";
168$form =
new Form($db);
170$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
172$page_name =
"StockTransferSetup";
173llxHeader(
'', $langs->trans($page_name),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-stocktransfer');
176$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>';
184$moduledir =
'stocktransfer';
185$myTmpObjects = array();
186$myTmpObjects[$moduledir] = array(
'includerefgeneration' => 1,
'includedocgeneration' => 1,
'class' =>
'StockTransfer');
188foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
190 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
192 print
'<div class="div-table-responsive-no-min">';
193 print
'<table class="noborder centpercent">';
194 print
'<tr class="liste_titre">';
195 print
'<td>'.$langs->trans(
"Name").
'</td>';
196 print
'<td>'.$langs->trans(
"Description").
'</td>';
197 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
198 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
199 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
204 foreach ($dirmodels as $reldir) {
208 $handle = opendir($dir);
209 if (is_resource($handle)) {
210 while (($file = readdir($handle)) !==
false) {
211 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
212 $file = substr($file, 0,
dol_strlen($file) - 4);
214 require_once $dir.
'/'.$file.
'.php';
216 $module =
new $file($db);
218 '@phan-var-force ModeleNumRefStockTransfer $module';
221 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
224 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
228 if ($module->isEnabled()) {
229 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
231 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
232 print $module->info($langs);
236 print
'<td class="nowrap">';
237 $tmp = $module->getExample();
238 if (preg_match(
'/^Error/', $tmp)) {
239 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
240 } elseif ($tmp ==
'NotConfigured') {
241 print $langs->trans($tmp);
247 print
'<td class="center">';
248 $constforvar =
'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).
'_ADDON';
250 print
img_picto($langs->trans(
"Activated"),
'switch_on');
252 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
253 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
258 $nameofclass = $myTmpObjectArray[
'class'];
259 $mytmpinstance =
new $nameofclass($db);
260 $mytmpinstance->initAsSpecimen();
264 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
266 $nextval = $module->getNextValue($mytmpinstance);
267 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
268 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
270 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
271 $nextval = $langs->trans($nextval);
273 $htmltooltip .= $nextval.
'<br>';
275 $htmltooltip .= $langs->trans($module->error).
'<br>';
279 print
'<td class="center">';
280 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
291 print
"</table></div><br>\n";
294 $type = strtolower($myTmpObjectKey);
296 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
301 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
302 $sql .=
" WHERE type = '".$db->escape($type).
"'";
303 $sql .=
" AND entity = ".((int) $conf->entity);
304 $resql = $db->query($sql);
307 $num_rows = $db->num_rows($resql);
308 while ($i < $num_rows) {
309 $array = $db->fetch_array($resql);
310 if (is_array($array)) {
311 array_push($def, $array[0]);
319 print
'<div class="div-table-responsive">';
320 print
'<table class="noborder centpercent">'.
"\n";
321 print
'<tr class="liste_titre">'.
"\n";
322 print
'<td>'.$langs->trans(
"Name").
'</td>';
323 print
'<td>'.$langs->trans(
"Description").
'</td>';
324 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
325 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
326 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
327 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
332 foreach ($dirmodels as $reldir) {
333 foreach (array(
'',
'/doc') as $valdir) {
334 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
338 $handle = opendir($dir);
339 if (is_resource($handle)) {
341 while (($file = readdir($handle)) !==
false) {
347 foreach ($filelist as $file) {
348 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
349 if (file_exists($dir.
'/'.$file)) {
350 $name = substr($file, 4,
dol_strlen($file) - 16);
351 $classname = substr($file, 0,
dol_strlen($file) - 12);
353 require_once $dir.
'/'.$file;
354 $module =
new $classname($db);
356 '@phan-var-force ModelePDFStockTransfer $module';
358 $modulequalified = 1;
359 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
360 $modulequalified = 0;
362 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
363 $modulequalified = 0;
366 if ($modulequalified) {
367 print
'<tr class="oddeven"><td>';
368 print(empty($module->name) ? $name : $module->
name);
370 if (method_exists($module,
'info')) {
371 print $module->info($langs);
373 print $module->description;
378 if (in_array($name, $def)) {
379 print
'<td class="center">'.
"\n";
380 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.urlencode($name).
'&token='.
newToken().
'">';
381 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
385 print
'<td class="center">'.
"\n";
386 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>';
391 print
'<td class="center">';
392 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
394 print
img_picto($langs->trans(
"Default"),
'on');
396 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&object='.urlencode($myTmpObjectKey).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
401 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
402 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
403 if ($module->type ==
'pdf') {
404 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
406 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
408 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
409 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
410 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
412 print
'<td class="center">';
413 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
417 print
'<td class="center">';
418 if ($module->type ==
'pdf') {
419 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
421 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
435 print
'</table></div>';
442print
'<div class="div-table-responsive-no-min">';
443print
'<table class="noborder centpercent">';
445print
'<tr class="liste_titre">';
446print
'<td>'.$langs->trans(
"Parameter").
'</td>';
460print
'<tr class="oddeven">';
461print
'<td>'.img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"MoreOptionsRelatedToPDF").
'</td>';
462print
'<td colspan="2">';
463print
img_picto(
'',
'url',
'class="pictofixedwidth"').
'<a href="'.DOL_URL_ROOT.
'/admin/pdf_other.php">'.$langs->trans(
"SeeInPDFSetupPage").
'</a>';
466print
'</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.
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)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
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.
$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.
stocktransferAdminPrepareHead()
Prepare admin pages header.