30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
38 $langs->loadLangs(array(
"admin",
"other",
"orders",
"stocks"));
44 $type =
GETPOST(
'type',
'alpha');
45 $value =
GETPOST(
'value',
'alpha');
46 $modulepart =
GETPOST(
'modulepart',
'aZ09');
48 $label =
GETPOST(
'label',
'alpha');
49 $action =
GETPOST(
'action',
'aZ09');
50 $scandir =
GETPOST(
'scan_dir',
'alpha');
52 $specimenthirdparty =
new Societe($db);
53 $specimenthirdparty->initAsSpecimen();
60 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
62 if ($action ==
'updateMask') {
63 $maskconstorder =
GETPOST(
'maskconstorder',
'alpha');
64 $maskvalue =
GETPOST(
'maskorder',
'alpha');
66 if ($maskconstorder) {
67 $res =
dolibarr_set_const($db, $maskconstorder, $maskvalue,
'chaine', 0,
'', $conf->entity);
79 } elseif ($action ==
'specimen') {
80 $modele =
GETPOST(
'module',
'alpha');
83 $commande->initAsSpecimen();
84 $commande->thirdparty = $specimenthirdparty;
87 $file =
''; $classname =
''; $filefound = 0;
88 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
89 foreach ($dirmodels as $reldir) {
90 $file =
dol_buildpath($reldir.
"core/modules/supplier_order/doc/pdf_".$modele.
".modules.php", 0);
91 if (file_exists($file)) {
93 $classname =
"pdf_".$modele;
101 $module =
new $classname($db, $commande);
103 if ($module->write_file($commande, $langs) > 0) {
104 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
112 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
114 } elseif ($action ==
'set') {
117 } elseif ($action ==
'del') {
120 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$value") {
124 } elseif ($action ==
'setdoc') {
126 if (
dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
129 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
137 } elseif ($action ==
'unsetdoc') {
139 } elseif ($action ==
'setmod') {
143 dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
144 } elseif ($action ==
'addcat') {
146 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
147 } elseif ($action ==
'set_SUPPLIER_ORDER_OTHER') {
148 $freetext =
GETPOST(
'SUPPLIER_ORDER_FREE_TEXT',
'restricthtml');
149 $doubleapproval =
GETPOST(
'SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED',
'alpha');
150 $doubleapproval =
price2num($doubleapproval);
152 $res1 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
153 $res2 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval,
'chaine', 0,
'', $conf->entity);
156 include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFournisseur.class.php';
159 if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
161 $newmodule->rights = array();
164 $newmodule->rights[$r][0] = 1190;
165 $newmodule->rights[$r][1] = $langs->trans(
"Permission1190");
166 $newmodule->rights[$r][2] =
'w';
167 $newmodule->rights[$r][3] = 0;
168 $newmodule->rights[$r][4] =
'commande';
169 $newmodule->rights[$r][5] =
'approve2';
172 $newmodule->insert_permissions(1);
175 $newmodule->delete_permissions();
178 $newmodule->insert_permissions(1);
180 } elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') {
182 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value,
'chaine', 0,
'', $conf->entity);
202 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
206 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
207 print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
220 print
'<table class="noborder centpercent">';
221 print
'<tr class="liste_titre">';
222 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
223 print
'<td>'.$langs->trans(
"Description").
'</td>';
224 print
'<td>'.$langs->trans(
"Example").
'</td>';
225 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
226 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
231 foreach ($dirmodels as $reldir) {
232 $dir =
dol_buildpath($reldir.
"core/modules/supplier_order/");
235 $handle = opendir($dir);
236 if (is_resource($handle)) {
237 while (($file = readdir($handle)) !==
false) {
238 if (substr($file, 0, 25) ==
'mod_commande_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
239 $file = substr($file, 0,
dol_strlen($file) - 4);
241 require_once $dir.$file.
'.php';
245 if ($module->isEnabled()) {
247 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
250 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
255 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
256 print $module->info();
260 print
'<td class="nowrap">';
261 $tmp = $module->getExample();
262 if (preg_match(
'/^Error/', $tmp)) {
263 $langs->load(
"errors");
264 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
265 } elseif ($tmp ==
'NotConfigured') {
266 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
272 print
'<td class="center">';
273 if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER ==
"$file") {
274 print
img_picto($langs->trans(
"Activated"),
'switch_on');
276 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>';
281 $commande->initAsSpecimen();
285 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
286 $nextval = $module->getNextValue($mysoc, $commande);
287 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
288 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
290 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
291 $nextval = $langs->trans($nextval);
293 $htmltooltip .= $nextval.
'<br>';
295 $htmltooltip .= $langs->trans($module->error).
'<br>';
299 print
'<td class="center">';
300 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
312 print
'</table><br>';
325 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
326 $sql .=
" WHERE type = 'order_supplier'";
327 $sql .=
" AND entity = ".$conf->entity;
329 $resql = $db->query($sql);
332 $num_rows = $db->num_rows(
$resql);
333 while ($i < $num_rows) {
334 $array = $db->fetch_array(
$resql);
335 array_push($def, $array[0]);
342 print
'<table class="noborder centpercent">'.
"\n";
343 print
'<tr class="liste_titre">'.
"\n";
344 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
345 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
346 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
347 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
348 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
349 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
354 foreach ($dirmodels as $reldir) {
355 $realpath = $reldir.
"core/modules/supplier_order/doc";
359 $handle = opendir($dir);
360 if (is_resource($handle)) {
361 while (($file = readdir($handle)) !==
false) {
362 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
363 $name = substr($file, 4,
dol_strlen($file) - 16);
364 $classname = substr($file, 0,
dol_strlen($file) - 12);
366 require_once $dir.
'/'.$file;
370 print
"<tr class=\"oddeven\">\n";
372 print (empty($module->name) ? $name : $module->name);
375 require_once $dir.
'/'.$file;
376 $module =
new $classname($db, $specimenthirdparty);
377 if (method_exists($module,
'info')) {
378 print $module->info($langs);
380 print $module->description;
385 if (in_array($name, $def)) {
386 print
'<td class="center">'.
"\n";
387 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF !=
"$name") {
388 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=order_supplier">';
389 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
392 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
396 print
'<td class="center">'.
"\n";
397 print
'<a 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>';
402 print
'<td class="center">';
403 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$name") {
404 print
'<a 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>';
406 print
'<a 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>';
411 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
412 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
413 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
414 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
416 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
417 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
418 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
419 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
420 print
'<td class="center">';
421 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
423 print
'<td class="center">';
424 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
436 print
'</table><br>';
442 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
443 print
'<input type="hidden" name="token" value="'.newToken().
'">';
444 print
'<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
447 print
'<table class="noborder centpercent">';
448 print
'<tr class="liste_titre">';
449 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
450 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
451 print
'<td width="80"> </td>';
454 print
'<tr class="oddeven"><td>';
455 print
$form->textwithpicto($langs->trans(
"UseDoubleApproval"), $langs->trans(
"Use3StepsApproval"), 1,
'help').
'<br>';
456 print $langs->trans(
"IfSetToYesDontForgetPermission");
458 print
'<input type="text" size="6" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.$conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED.
'">';
459 print
'</td><td class="right">';
460 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
461 print
"</td></tr>\n";
496 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
497 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
498 foreach ($substitutionarray as $key => $val) {
499 $htmltext .= $key.
'<br>';
503 print
'<tr class="oddeven"><td colspan="2">';
504 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
505 $variablename =
'SUPPLIER_ORDER_FREE_TEXT';
506 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
507 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
509 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
511 print $doleditor->Create();
513 print
'</td><td class="right">';
514 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
515 print
"</td></tr>\n";
518 print
'<tr class="oddeven">';
519 print
'<td>'.$langs->trans(
"UseDispatchStatus").
'</td>';
521 print
'<td class="center">';
523 print
'<span class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableWithReceptionModule").
'</span>';
525 if ($conf->use_javascript_ajax) {
528 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
529 print
$form->selectarray(
"SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS);
535 print
'</table><br>';
545 print
'<table class="noborder centpercent">';
546 print
'<tr class="liste_titre">';
547 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
548 print
'<td align="center" width="60"></td>';
549 print
'<td width="80"> </td>';
552 print
'<tr class="oddeven"><td colspan="2">';
553 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
554 print
'</td><td class="right">';
555 print
"</td></tr>\n";