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';
41$langs->loadLangs(array(
"admin",
"other",
"orders",
"stocks"));
43$action =
GETPOST(
'action',
'aZ09');
45$type =
GETPOST(
'type',
'alpha');
46$value =
GETPOST(
'value',
'alpha');
47$modulepart =
GETPOST(
'modulepart',
'aZ09');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
52$specimenthirdparty =
new Societe($db);
53$specimenthirdparty->initAsSpecimen();
66include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
68if ($action ==
'updateMask') {
69 $maskconstorder =
GETPOST(
'maskconstorder',
'aZ09');
70 $maskvalue =
GETPOST(
'maskorder',
'alpha');
72 if ($maskconstorder && preg_match(
'/_MASK$/', $maskconstorder)) {
73 $res =
dolibarr_set_const($db, $maskconstorder, $maskvalue,
'chaine', 0,
'', $conf->entity);
87if ($action ==
'specimen') {
88 $modele =
GETPOST(
'module',
'alpha');
91 $commande->initAsSpecimen();
92 $commande->thirdparty = $specimenthirdparty;
97 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
98 foreach ($dirmodels as $reldir) {
99 $file =
dol_buildpath($reldir.
"core/modules/supplier_order/doc/pdf_".$modele.
".modules.php", 0);
100 if (file_exists($file)) {
101 $classname =
"pdf_".$modele;
106 if ($classname !==
'') {
109 $module =
new $classname($db, $commande);
110 '@phan-var-force CommonDocGenerator $module';
112 if ($module->write_file($commande, $langs) > 0) {
113 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
121 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
123} elseif ($action ==
'set') {
126} elseif ($action ==
'del') {
129 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$value") {
133} elseif ($action ==
'setdoc') {
135 if (
dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
138 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
146} elseif ($action ==
'unsetdoc') {
148} elseif ($action ==
'setmod') {
152 dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
153} elseif ($action ==
'addcat') {
155 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
156} elseif ($action ==
'set_SUPPLIER_ORDER_OTHER') {
157 $freetext =
GETPOST(
'SUPPLIER_ORDER_FREE_TEXT',
'restricthtml');
158 $doubleapproval =
GETPOST(
'SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED',
'alpha');
159 $doubleapproval =
price2num($doubleapproval);
161 $res1 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
162 $res2 =
dolibarr_set_const($db,
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval,
'chaine', 0,
'', $conf->entity);
165 include_once DOL_DOCUMENT_ROOT.
'/core/modules/modFournisseur.class.php';
168 if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
170 $newmodule->rights = array();
173 $newmodule->rights[$r][0] = 1190;
174 $newmodule->rights[$r][1] = $langs->trans(
"Permission1190");
175 $newmodule->rights[$r][2] =
'w';
176 $newmodule->rights[$r][3] = 0;
177 $newmodule->rights[$r][4] =
'commande';
178 $newmodule->rights[$r][5] =
'approve2';
181 $newmodule->insert_permissions(1);
184 $newmodule->delete_permissions();
187 $newmodule->insert_permissions(1);
189} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') {
191 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value,
'chaine', 0,
'', $conf->entity);
209$form =
new Form($db);
211$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
213llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-supplier_order');
215$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
216print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
229print
'<div class="div-table-responsive-no-min">';
230print
'<table class="noborder centpercent">';
231print
'<tr class="liste_titre">';
232print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
233print
'<td>'.$langs->trans(
"Description").
'</td>';
234print
'<td>'.$langs->trans(
"Example").
'</td>';
235print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
236print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
241foreach ($dirmodels as $reldir) {
242 $dir =
dol_buildpath($reldir.
"core/modules/supplier_order/");
245 $handle = opendir($dir);
246 if (is_resource($handle)) {
247 while (($file = readdir($handle)) !==
false) {
248 if (substr($file, 0, 25) ==
'mod_commande_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
249 $file = substr($file, 0,
dol_strlen($file) - 4);
251 require_once $dir.$file.
'.php';
253 $module =
new $file();
255 if ($module->isEnabled()) {
257 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
260 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
265 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
266 print $module->info($langs);
270 print
'<td class="nowrap">';
271 $tmp = $module->getExample();
272 if (preg_match(
'/^Error/', $tmp)) {
273 $langs->load(
"errors");
274 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
275 } elseif ($tmp ==
'NotConfigured') {
276 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
282 print
'<td class="center">';
283 if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER ==
"$file") {
284 print
img_picto($langs->trans(
"Activated"),
'switch_on');
286 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>';
291 $commande->initAsSpecimen();
295 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
296 $nextval = $module->getNextValue($mysoc, $commande);
297 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
298 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
300 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
301 $nextval = $langs->trans($nextval);
303 $htmltooltip .= $nextval.
'<br>';
305 $htmltooltip .= $langs->trans($module->error).
'<br>';
309 print
'<td class="center">';
310 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
322print
'</table></div><br>';
335$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
336$sql .=
" WHERE type = 'order_supplier'";
337$sql .=
" AND entity = ".$conf->entity;
339$resql = $db->query($sql);
342 $num_rows = $db->num_rows($resql);
343 while ($i < $num_rows) {
344 $array = $db->fetch_array($resql);
345 if (is_array($array)) {
346 array_push($def, $array[0]);
354print
'<div class="div-table-responsive-no-min">';
355print
'<table class="noborder centpercent">'.
"\n";
356print
'<tr class="liste_titre">'.
"\n";
357print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
358print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
359print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
360print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
361print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
362print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
367foreach ($dirmodels as $reldir) {
368 $realpath = $reldir.
"core/modules/supplier_order/doc";
372 $handle = opendir($dir);
373 if (is_resource($handle)) {
374 while (($file = readdir($handle)) !==
false) {
375 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
376 $name = substr($file, 4,
dol_strlen($file) - 16);
377 $classname = substr($file, 0,
dol_strlen($file) - 12);
379 require_once $dir.
'/'.$file;
383 print
"<tr class=\"oddeven\">\n";
385 print(empty($module->name) ? $name : $module->
name);
388 require_once $dir.
'/'.$file;
389 $module =
new $classname($db, $specimenthirdparty);
390 if (method_exists($module,
'info')) {
391 print $module->info($langs);
393 print $module->description;
398 if (in_array($name, $def)) {
399 print
'<td class="center">'.
"\n";
400 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF !=
"$name") {
401 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">';
402 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
405 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
409 print
'<td class="center">'.
"\n";
410 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>';
415 print
'<td class="center">';
416 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$name") {
417 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>';
419 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>';
424 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
425 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
426 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
427 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
429 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
430 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
431 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
432 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
433 print
'<td class="center">';
434 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
436 print
'<td class="center">';
437 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
449print
'</table></div><br>';
455print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
456print
'<input type="hidden" name="token" value="'.newToken().
'">';
457print
'<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
461print
'<div class="div-table-responsive-no-min">';
462print
'<table class="noborder centpercent">';
463print
'<tr class="liste_titre">';
464print
'<td>'.$langs->trans(
"Parameter").
'</td>';
465print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
466print
'<td width="80"> </td>';
469print
'<tr class="oddeven"><td>';
470print $form->textwithpicto($langs->trans(
"UseDoubleApproval"), $langs->trans(
"Use3StepsApproval"), 1,
'help').
'<br>';
471print $langs->trans(
"IfSetToYesDontForgetPermission");
473print
'<input type="text" size="6" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.getDolGlobalString(
"SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED").
'">';
474print
'</td><td class="right">';
475print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
511$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
512$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
513foreach ($substitutionarray as $key => $val) {
514 $htmltext .= $key.
'<br>';
518print
'<tr class="oddeven"><td colspan="2">';
519print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
520$variablename =
'SUPPLIER_ORDER_FREE_TEXT';
522 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
524 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
526 print $doleditor->Create();
528print
'</td><td class="right">';
529print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
533print
'<tr class="oddeven">';
534print
'<td>'.$langs->trans(
"UseDispatchStatus").
'</td>';
536print
'<td class="center">';
537if (isModEnabled(
'reception')) {
538 print
'<span class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableWithReceptionModule").
'</span>';
540 if ($conf->use_javascript_ajax) {
541 print ajax_constantonoff(
'SUPPLIER_ORDER_USE_DISPATCH_STATUS');
543 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
544 print $form->selectarray(
"SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS);
552print
'<tr class="oddeven"><td>'.$langs->trans(
"SupplierOrderClassifyBilledWithoutInvoice").
' ' ;
553print $form->textwithpicto(
'', $langs->trans(
"SupplierOrderClassifyBilledWithoutInvoiceHelp"), 1,
'help') .
'</td>';
554print
'<td class="left" colspan="2">';
555print ajax_constantonoff(
'SUPPLIER_ORDER_DISABLE_CLASSIFY_BILLED_FROM_SUPPLIER_ORDER');
558print
'</table></div><br>';
569print
'<div class="div-table-responsive-no-min">';
570print
'<table class="noborder centpercent">';
571print
'<tr class="liste_titre">';
572print
'<td>'.$langs->trans(
"Parameter").
'</td>';
573print
'<td align="center" width="60"></td>';
574print
'<td width="80"> </td>';
577print
'<tr class="oddeven"><td colspan="2">';
578print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
579print
'</td><td class="right">';
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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.