35require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
49 require_once DOL_DOCUMENT_ROOT .
'/core/lib/supplier_order.lib.php';
51 require_once DOL_DOCUMENT_ROOT .
'/core/lib/fourn.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
58$langs->loadLangs(array(
"admin",
"other",
"orders",
"stocks"));
60$action =
GETPOST(
'action',
'aZ09');
62$type =
GETPOST(
'type',
'alpha');
63$value =
GETPOST(
'value',
'alpha');
64$modulepart =
GETPOST(
'modulepart',
'aZ09');
66$label =
GETPOST(
'label',
'alpha');
67$scandir =
GETPOST(
'scan_dir',
'alpha');
69$specimenthirdparty =
new Societe($db);
70$specimenthirdparty->initAsSpecimen();
83include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
85if ($action ==
'updateMask') {
86 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
87 $maskvalue =
GETPOST(
'maskorder',
'alpha');
91 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
100 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
102 setEventMessages($langs->trans(
"Error"),
null,
'errors');
106if ($action ==
'specimen') {
107 $modele =
GETPOST(
'module',
'alpha');
110 $commande->initAsSpecimen();
111 $commande->thirdparty = $specimenthirdparty;
116 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
117 foreach ($dirmodels as $reldir) {
118 $file =
dol_buildpath($reldir.
"core/modules/supplier_order/doc/pdf_".$modele.
".modules.php", 0);
119 if (file_exists($file)) {
120 $classname =
"pdf_".$modele;
125 if ($classname !==
'') {
128 $module =
new $classname($db, $commande);
129 '@phan-var-force ModelePDFSuppliersOrders $module';
131 if (
$module->write_file($commande, $langs) > 0) {
132 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
139 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
140 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
142} elseif ($action ==
'set') {
145} elseif ($action ==
'del') {
152} elseif ($action ==
'setdoc') {
157 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
165} elseif ($action ==
'unsetdoc') {
167} elseif ($action ==
'setmod') {
172} elseif ($action ==
'addcat') {
174 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
175} elseif ($action ==
'set_SUPPLIER_ORDER_OTHER') {
176 $freetext =
GETPOST(
'SUPPLIER_ORDER_FREE_TEXT',
'restricthtml');
177 $doubleapproval =
GETPOST(
'SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED',
'alpha');
178 $doubleapproval =
price2num($doubleapproval);
181 $res2 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval,
'chaine', 0,
'',
$conf->entity);
184 include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFournisseur.class.php';
185 $newmodule =
new modFournisseur($db);
187 if (
$conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
189 $newmodule->rights = array();
192 $newmodule->rights[$r][0] = 1190;
193 $newmodule->rights[$r][1] = $langs->trans(
"Permission1190");
194 $newmodule->rights[$r][2] =
'w';
195 $newmodule->rights[$r][3] = 0;
196 $newmodule->rights[$r][4] =
'commande';
197 $newmodule->rights[$r][5] =
'approve2';
200 $newmodule->insert_permissions(1);
203 $newmodule->delete_permissions();
206 $newmodule->insert_permissions(1);
208} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') {
210 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value,
'chaine', 0,
'',
$conf->entity);
217 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
219 setEventMessages($langs->trans(
"Error"),
null,
'errors');
228$form =
new Form($db);
230$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
232llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-supplier_order');
234$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>';
236print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
241 $head = supplier_order_admin_prepare_head();
252$commande->initAsSpecimen();
254printNumberingModuleList(
'supplier_order',
'mod_commande_fournisseur_',
'COMMANDE_SUPPLIER_ADDON_NUMBER', $langs->trans(
"OrdersNumberingModules"), $commande);
269$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
270$sql .=
" WHERE type = 'order_supplier'";
271$sql .=
" AND entity = ".((int)
$conf->entity);
273$resql = $db->query($sql);
276 $num_rows = $db->num_rows($resql);
277 while ($i < $num_rows) {
278 $array = $db->fetch_array($resql);
279 if (is_array($array)) {
280 array_push($def, $array[0]);
285 dol_print_error($db);
288print
'<div class="div-table-responsive-no-min">';
289print
'<table class="noborder centpercent">'.
"\n";
290print
'<tr class="liste_titre">'.
"\n";
291print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
292print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
293print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
294print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
295print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
296print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
301foreach ($dirmodels as $reldir) {
302 $realpath = $reldir.
"core/modules/supplier_order/doc";
306 $handle = opendir($dir);
307 if (is_resource($handle)) {
308 while (($file = readdir($handle)) !==
false) {
309 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
313 require_once $dir.
'/'.$file;
316 '@phan-var-force ModelePDFSuppliersOrders $module';
318 print
"<tr class=\"oddeven\">\n";
323 require_once $dir.
'/'.$file;
324 $module =
new $classname($db, $specimenthirdparty);
325 '@phan-var-force ModelePDFSuppliersOrders $module';
326 if (method_exists(
$module,
'info')) {
334 if (in_array($name, $def)) {
335 print
'<td class="center">'.
"\n";
337 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">';
338 print img_picto($langs->trans(
"Enabled"),
'switch_on');
341 print img_picto($langs->trans(
"Enabled"),
'switch_on');
345 print
'<td class="center">'.
"\n";
346 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>';
351 print
'<td class="center">';
353 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>';
355 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>';
360 $htmltooltip =
''.$langs->trans(
"Name").
': '.
$module->name;
361 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.(
$module->type ?
$module->type : $langs->trans(
"Unknown"));
362 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.
$module->page_largeur.
'/'.
$module->page_hauteur;
363 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
365 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
366 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.yn(
$module->option_logo, 1, 1);
367 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.yn(
$module->option_modereg, 1, 1);
368 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.yn(
$module->option_condreg, 1, 1);
369 print
'<td class="center">';
370 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
372 print
'<td class="center">';
373 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
385print
'</table></div><br>';
391print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
392print
'<input type="hidden" name="token" value="'.newToken().
'">';
393print
'<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
397print
'<div class="div-table-responsive-no-min">';
398print
'<table class="noborder centpercent">';
399print
'<tr class="liste_titre">';
400print
'<td>'.$langs->trans(
"Parameter").
'</td>';
402print
'<td width="80"> </td>';
405print
'<tr class="oddeven"><td>';
406print $form->textwithpicto($langs->trans(
"UseDoubleApproval"), $langs->trans(
"Use3StepsApproval"), 1,
'help').
'<br>';
407print
'<span class="opacitymedium">'.$langs->trans(
"IfSetToYesDontForgetPermission").
'</span>';
409print
'<input type="text" size="6" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.getDolGlobalString(
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED").
'">';
410print
'</td><td class="right">';
411print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
415$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
416$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
417foreach ($substitutionarray as $key => $val) {
418 $htmltext .= $key.
'<br>';
422print
'<tr class="oddeven"><td colspan="2">';
423print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
424$variablename =
'SUPPLIER_ORDER_FREE_TEXT';
426 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
428 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
430 print $doleditor->Create();
432print
'</td><td class="right">';
433print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
437print
'<tr class="oddeven">';
438print
'<td>'.$langs->trans(
"UseDispatchStatus").
'</td>';
439print
'<td colspan="2">';
441 print
'<span class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableWithReceptionModule").
'</span>';
443 if (
$conf->use_javascript_ajax) {
444 print ajax_constantonoff(
'SUPPLIER_ORDER_USE_DISPATCH_STATUS');
446 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
447 print $form->selectarray(
"SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval,
$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS);
455print
'<tr class="oddeven"><td>'.$langs->trans(
"SupplierOrderClassifyBilledWithoutInvoice").
' ' ;
456print $form->textwithpicto(
'', $langs->trans(
"SupplierOrderClassifyBilledWithoutInvoiceHelp"), 1,
'help') .
'</td>';
457print
'<td colspan="2">';
458print ajax_constantonoff(
'SUPPLIER_ORDER_DISABLE_CLASSIFY_BILLED_FROM_SUPPLIER_ORDER');
462print
'<tr class="oddeven">';
463print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
464print
'<td class="left" colspan="2">';
465print ajax_constantonoff(
'SUPPLIER_ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
469print
'<tr class="oddeven">';
470print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
471print
'<td colspan="2">';
472print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
476print
'<tr class="oddeven">';
477print
'<td>'.img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"MoreOptionsRelatedToPDF").
'</td>';
478print
'<td colspan="2">';
479print img_picto(
'',
'url',
'class="pictofixedwidth"').
'<a href="'.DOL_URL_ROOT.
'/admin/pdf_other.php">'.$langs->trans(
"SeeInPDFSetupPage").
'</a>';
483print
'</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...)
if(! $sortfield) if(! $sortorder) $module
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object information.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.