31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
39 $langs->loadLangs(array(
"admin",
"other",
"orders",
"stocks"));
41 $action =
GETPOST(
'action',
'aZ09');
43 $type =
GETPOST(
'type',
'alpha');
44 $value =
GETPOST(
'value',
'alpha');
45 $modulepart =
GETPOST(
'modulepart',
'aZ09');
47 $label =
GETPOST(
'label',
'alpha');
48 $scandir =
GETPOST(
'scan_dir',
'alpha');
50 $specimenthirdparty =
new Societe($db);
51 $specimenthirdparty->initAsSpecimen();
64 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
66 if ($action ==
'updateMask') {
67 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
68 $maskvalue =
GETPOST(
'maskorder',
'alpha');
70 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
71 $res =
dolibarr_set_const($db, $maskconstorder, $maskvalue,
'chaine', 0,
'', $conf->entity);
85 if ($action ==
'specimen') {
86 $modele =
GETPOST(
'module',
'alpha');
89 $commande->initAsSpecimen();
90 $commande->thirdparty = $specimenthirdparty;
96 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
97 foreach ($dirmodels as $reldir) {
98 $file =
dol_buildpath($reldir.
"core/modules/supplier_order/doc/pdf_".$modele.
".modules.php", 0);
99 if (file_exists($file)) {
101 $classname =
"pdf_".$modele;
109 $module =
new $classname($db, $commande);
111 if ($module->write_file($commande, $langs) > 0) {
112 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
120 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
122 } elseif ($action ==
'set') {
125 } elseif ($action ==
'del') {
128 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$value") {
132 } elseif ($action ==
'setdoc') {
134 if (
dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
137 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
145 } elseif ($action ==
'unsetdoc') {
147 } elseif ($action ==
'setmod') {
151 dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
152 } elseif ($action ==
'addcat') {
154 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
155 } elseif ($action ==
'set_SUPPLIER_ORDER_OTHER') {
156 $freetext =
GETPOST(
'SUPPLIER_ORDER_FREE_TEXT',
'restricthtml');
157 $doubleapproval =
GETPOST(
'SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED',
'alpha');
158 $doubleapproval =
price2num($doubleapproval);
160 $res1 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
161 $res2 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval,
'chaine', 0,
'', $conf->entity);
164 include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFournisseur.class.php';
167 if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
169 $newmodule->rights = array();
172 $newmodule->rights[$r][0] = 1190;
173 $newmodule->rights[$r][1] = $langs->trans(
"Permission1190");
174 $newmodule->rights[$r][2] =
'w';
175 $newmodule->rights[$r][3] = 0;
176 $newmodule->rights[$r][4] =
'commande';
177 $newmodule->rights[$r][5] =
'approve2';
180 $newmodule->insert_permissions(1);
183 $newmodule->delete_permissions();
186 $newmodule->insert_permissions(1);
188 } elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') {
190 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value,
'chaine', 0,
'', $conf->entity);
210 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
214 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
215 print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
228 print
'<div class="div-table-responsive-no-min">';
229 print
'<table class="noborder centpercent">';
230 print
'<tr class="liste_titre">';
231 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
232 print
'<td>'.$langs->trans(
"Description").
'</td>';
233 print
'<td>'.$langs->trans(
"Example").
'</td>';
234 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
235 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
240 foreach ($dirmodels as $reldir) {
241 $dir =
dol_buildpath($reldir.
"core/modules/supplier_order/");
244 $handle = opendir($dir);
245 if (is_resource($handle)) {
246 while (($file = readdir($handle)) !==
false) {
247 if (substr($file, 0, 25) ==
'mod_commande_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
248 $file = substr($file, 0,
dol_strlen($file) - 4);
250 require_once $dir.$file.
'.php';
254 if ($module->isEnabled()) {
256 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
259 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
264 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
265 print $module->info();
269 print
'<td class="nowrap">';
270 $tmp = $module->getExample();
271 if (preg_match(
'/^Error/', $tmp)) {
272 $langs->load(
"errors");
273 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
274 } elseif ($tmp ==
'NotConfigured') {
275 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
281 print
'<td class="center">';
282 if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER ==
"$file") {
283 print
img_picto($langs->trans(
"Activated"),
'switch_on');
285 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
290 $commande->initAsSpecimen();
294 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
295 $nextval = $module->getNextValue($mysoc, $commande);
296 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
297 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
299 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
300 $nextval = $langs->trans($nextval);
302 $htmltooltip .= $nextval.
'<br>';
304 $htmltooltip .= $langs->trans($module->error).
'<br>';
308 print
'<td class="center">';
309 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
321 print
'</table></div><br>';
334 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
335 $sql .=
" WHERE type = 'order_supplier'";
336 $sql .=
" AND entity = ".$conf->entity;
338 $resql = $db->query(
$sql);
341 $num_rows = $db->num_rows($resql);
342 while ($i < $num_rows) {
343 $array = $db->fetch_array($resql);
344 array_push($def, $array[0]);
351 print
'<div class="div-table-responsive-no-min">';
352 print
'<table class="noborder centpercent">'.
"\n";
353 print
'<tr class="liste_titre">'.
"\n";
354 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
355 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
356 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
357 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
358 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
359 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
364 foreach ($dirmodels as $reldir) {
365 $realpath = $reldir.
"core/modules/supplier_order/doc";
369 $handle = opendir($dir);
370 if (is_resource($handle)) {
371 while (($file = readdir($handle)) !==
false) {
372 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
373 $name = substr($file, 4,
dol_strlen($file) - 16);
374 $classname = substr($file, 0,
dol_strlen($file) - 12);
376 require_once $dir.
'/'.$file;
380 print
"<tr class=\"oddeven\">\n";
382 print(empty($module->name) ? $name : $module->name);
385 require_once $dir.
'/'.$file;
386 $module =
new $classname($db, $specimenthirdparty);
387 if (method_exists($module,
'info')) {
388 print $module->info($langs);
390 print $module->description;
395 if (in_array($name, $def)) {
396 print
'<td class="center">'.
"\n";
397 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF !=
"$name") {
398 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=order_supplier">';
399 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
402 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
406 print
'<td class="center">'.
"\n";
407 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=order_supplier">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
412 print
'<td class="center">';
413 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$name") {
414 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=order_supplier" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
416 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=order_supplier" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
421 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
422 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
423 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
424 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
426 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
427 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
428 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
429 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
430 print
'<td class="center">';
431 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
433 print
'<td class="center">';
434 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
446 print
'</table></div><br>';
452 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
453 print
'<input type="hidden" name="token" value="'.newToken().
'">';
454 print
'<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
458 print
'<div class="div-table-responsive-no-min">';
459 print
'<table class="noborder centpercent">';
460 print
'<tr class="liste_titre">';
461 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
462 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
463 print
'<td width="80"> </td>';
466 print
'<tr class="oddeven"><td>';
467 print
$form->textwithpicto($langs->trans(
"UseDoubleApproval"), $langs->trans(
"Use3StepsApproval"), 1,
'help').
'<br>';
468 print $langs->trans(
"IfSetToYesDontForgetPermission");
470 print
'<input type="text" size="6" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.getDolGlobalString(
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED").
'">';
471 print
'</td><td class="right">';
472 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
473 print
"</td></tr>\n";
508 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
509 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
510 foreach ($substitutionarray as $key => $val) {
511 $htmltext .= $key.
'<br>';
515 print
'<tr class="oddeven"><td colspan="2">';
516 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
517 $variablename =
'SUPPLIER_ORDER_FREE_TEXT';
518 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
519 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
521 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
523 print $doleditor->Create();
525 print
'</td><td class="right">';
526 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
527 print
"</td></tr>\n";
530 print
'<tr class="oddeven">';
531 print
'<td>'.$langs->trans(
"UseDispatchStatus").
'</td>';
533 print
'<td class="center">';
535 print
'<span class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableWithReceptionModule").
'</span>';
537 if ($conf->use_javascript_ajax) {
540 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
541 print
$form->selectarray(
"SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS);
547 print
'</table></div><br>';
558 print
'<div class="div-table-responsive-no-min">';
559 print
'<table class="noborder centpercent">';
560 print
'<tr class="liste_titre">';
561 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
562 print
'<td align="center" width="60"></td>';
563 print
'<td width="80"> </td>';
566 print
'<tr class="oddeven"><td colspan="2">';
567 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
568 print
'</td><td class="right">';
569 print
"</td></tr>\n";