33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
50$langs->loadLangs(array(
"admin",
"other",
"orders",
"stocks"));
52$action =
GETPOST(
'action',
'aZ09');
54$type =
GETPOST(
'type',
'alpha');
55$value =
GETPOST(
'value',
'alpha');
56$modulepart =
GETPOST(
'modulepart',
'aZ09');
58$label =
GETPOST(
'label',
'alpha');
59$scandir =
GETPOST(
'scan_dir',
'alpha');
61$specimenthirdparty =
new Societe($db);
62$specimenthirdparty->initAsSpecimen();
75include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
77if ($action ==
'updateMask') {
78 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
79 $maskvalue =
GETPOST(
'maskorder',
'alpha');
83 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
84 $res =
dolibarr_set_const($db, $maskconstorder, $maskvalue,
'chaine', 0,
'', $conf->entity);
98if ($action ==
'specimen') {
99 $modele =
GETPOST(
'module',
'alpha');
102 $commande->initAsSpecimen();
103 $commande->thirdparty = $specimenthirdparty;
108 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
109 foreach ($dirmodels as $reldir) {
110 $file =
dol_buildpath($reldir.
"core/modules/supplier_order/doc/pdf_".$modele.
".modules.php", 0);
111 if (file_exists($file)) {
112 $classname =
"pdf_".$modele;
117 if ($classname !==
'') {
120 $module =
new $classname($db, $commande);
121 '@phan-var-force ModelePDFSuppliersOrders $module';
123 if ($module->write_file($commande, $langs) > 0) {
124 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
132 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
134} elseif ($action ==
'set') {
137} elseif ($action ==
'del') {
144} elseif ($action ==
'setdoc') {
146 if (
dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
149 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
157} elseif ($action ==
'unsetdoc') {
159} elseif ($action ==
'setmod') {
163 dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
164} elseif ($action ==
'addcat') {
166 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
167} elseif ($action ==
'set_SUPPLIER_ORDER_OTHER') {
168 $freetext =
GETPOST(
'SUPPLIER_ORDER_FREE_TEXT',
'restricthtml');
169 $doubleapproval =
GETPOST(
'SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED',
'alpha');
170 $doubleapproval =
price2num($doubleapproval);
172 $res1 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
173 $res2 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval,
'chaine', 0,
'', $conf->entity);
176 include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFournisseur.class.php';
179 if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
181 $newmodule->rights = array();
184 $newmodule->rights[$r][0] = 1190;
185 $newmodule->rights[$r][1] = $langs->trans(
"Permission1190");
186 $newmodule->rights[$r][2] =
'w';
187 $newmodule->rights[$r][3] = 0;
188 $newmodule->rights[$r][4] =
'commande';
189 $newmodule->rights[$r][5] =
'approve2';
192 $newmodule->insert_permissions(1);
195 $newmodule->delete_permissions();
198 $newmodule->insert_permissions(1);
200} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') {
202 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value,
'chaine', 0,
'', $conf->entity);
220$form =
new Form($db);
222$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
224llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-supplier_order');
226$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>';
228print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
241print
'<div class="div-table-responsive-no-min">';
242print
'<table class="noborder centpercent">';
243print
'<tr class="liste_titre">';
244print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
245print
'<td>'.$langs->trans(
"Description").
'</td>';
246print
'<td>'.$langs->trans(
"Example").
'</td>';
247print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
248print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
253foreach ($dirmodels as $reldir) {
254 $dir =
dol_buildpath($reldir.
"core/modules/supplier_order/");
257 $handle = opendir($dir);
258 if (is_resource($handle)) {
259 while (($file = readdir($handle)) !==
false) {
260 if (substr($file, 0, 25) ==
'mod_commande_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
261 $file = substr($file, 0,
dol_strlen($file) - 4);
263 require_once $dir.$file.
'.php';
265 $module =
new $file();
267 '@phan-var-force ModeleNumRefSuppliersOrders $module';
269 if ($module->isEnabled()) {
271 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
274 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
279 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
280 print $module->info($langs);
284 print
'<td class="nowrap">';
285 $tmp = $module->getExample();
286 if (preg_match(
'/^Error/', $tmp)) {
287 $langs->load(
"errors");
288 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
289 } elseif ($tmp ==
'NotConfigured') {
290 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
296 print
'<td class="center">';
298 print
img_picto($langs->trans(
"Activated"),
'switch_on');
300 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>';
305 $commande->initAsSpecimen();
309 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
310 $nextval = $module->getNextValue(
$mysoc, $commande);
311 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
312 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
314 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
315 $nextval = $langs->trans($nextval);
317 $htmltooltip .= $nextval.
'<br>';
319 $htmltooltip .= $langs->trans($module->error).
'<br>';
323 print
'<td class="center">';
324 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
336print
'</table></div><br>';
349$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
350$sql .=
" WHERE type = 'order_supplier'";
351$sql .=
" AND entity = ".((int) $conf->entity);
353$resql = $db->query($sql);
356 $num_rows = $db->num_rows($resql);
357 while ($i < $num_rows) {
358 $array = $db->fetch_array($resql);
359 if (is_array($array)) {
360 array_push($def, $array[0]);
368print
'<div class="div-table-responsive-no-min">';
369print
'<table class="noborder centpercent">'.
"\n";
370print
'<tr class="liste_titre">'.
"\n";
371print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
372print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
373print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
374print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
375print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
376print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
381foreach ($dirmodels as $reldir) {
382 $realpath = $reldir.
"core/modules/supplier_order/doc";
386 $handle = opendir($dir);
387 if (is_resource($handle)) {
388 while (($file = readdir($handle)) !==
false) {
389 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
390 $name = substr($file, 4,
dol_strlen($file) - 16);
391 $classname = substr($file, 0,
dol_strlen($file) - 12);
393 require_once $dir.
'/'.$file;
396 '@phan-var-force ModelePDFSuppliersOrders $module';
398 print
"<tr class=\"oddeven\">\n";
400 print(empty($module->name) ? $name : $module->
name);
403 require_once $dir.
'/'.$file;
404 $module =
new $classname($db, $specimenthirdparty);
405 '@phan-var-force ModelePDFSuppliersOrders $module';
406 if (method_exists($module,
'info')) {
407 print $module->info($langs);
409 print $module->description;
414 if (in_array($name, $def)) {
415 print
'<td class="center">'.
"\n";
417 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">';
418 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
421 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
425 print
'<td class="center">'.
"\n";
426 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>';
431 print
'<td class="center">';
433 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>';
435 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>';
440 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
441 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
442 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
443 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
445 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
446 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
447 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
448 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
449 print
'<td class="center">';
450 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
452 print
'<td class="center">';
453 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
465print
'</table></div><br>';
471print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
472print
'<input type="hidden" name="token" value="'.newToken().
'">';
473print
'<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
477print
'<div class="div-table-responsive-no-min">';
478print
'<table class="noborder centpercent">';
479print
'<tr class="liste_titre">';
480print
'<td>'.$langs->trans(
"Parameter").
'</td>';
482print
'<td width="80"> </td>';
485print
'<tr class="oddeven"><td>';
486print $form->textwithpicto($langs->trans(
"UseDoubleApproval"), $langs->trans(
"Use3StepsApproval"), 1,
'help').
'<br>';
487print
'<span class="opacitymedium">'.$langs->trans(
"IfSetToYesDontForgetPermission").
'</span>';
489print
'<input type="text" size="6" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.getDolGlobalString(
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED").
'">';
490print
'</td><td class="right">';
491print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
495$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
496$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
497foreach ($substitutionarray as $key => $val) {
498 $htmltext .= $key.
'<br>';
502print
'<tr class="oddeven"><td colspan="2">';
503print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
504$variablename =
'SUPPLIER_ORDER_FREE_TEXT';
506 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
508 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
510 print $doleditor->Create();
512print
'</td><td class="right">';
513print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
517print
'<tr class="oddeven">';
518print
'<td>'.$langs->trans(
"UseDispatchStatus").
'</td>';
519print
'<td colspan="2">';
521 print
'<span class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableWithReceptionModule").
'</span>';
523 if ($conf->use_javascript_ajax) {
524 print ajax_constantonoff(
'SUPPLIER_ORDER_USE_DISPATCH_STATUS');
526 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
527 print $form->selectarray(
"SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS);
535print
'<tr class="oddeven"><td>'.$langs->trans(
"SupplierOrderClassifyBilledWithoutInvoice").
' ' ;
536print $form->textwithpicto(
'', $langs->trans(
"SupplierOrderClassifyBilledWithoutInvoiceHelp"), 1,
'help') .
'</td>';
537print
'<td colspan="2">';
538print ajax_constantonoff(
'SUPPLIER_ORDER_DISABLE_CLASSIFY_BILLED_FROM_SUPPLIER_ORDER');
543print
'<tr class="oddeven">';
544print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
545print
'<td colspan="2">';
546print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
550print
'<tr class="oddeven">';
551print
'<td>'.img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"MoreOptionsRelatedToPDF").
'</td>';
552print
'<td colspan="2">';
553print
img_picto(
'',
'url',
'class="pictofixedwidth"').
'<a href="'.DOL_URL_ROOT.
'/admin/pdf_other.php">'.$langs->trans(
"SeeInPDFSetupPage").
'</a>';
557print
'</table></div><br>';
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.
Class to manage predefined suppliers products.
Class to manage a WYSIWYG editor.
Class to manage suppliers.
Class to manage third parties objects (customers, suppliers, prospects...)
Description and activation class for module Fournisseur.
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object information.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
$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.