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"));
43 $type =
GETPOST(
'type',
'alpha');
44 $value =
GETPOST(
'value',
'alpha');
45 $label =
GETPOST(
'label',
'alpha');
46 $action =
GETPOST(
'action',
'aZ09');
47 $scandir =
GETPOST(
'scan_dir',
'alpha');
49 $specimenthirdparty =
new Societe($db);
50 $specimenthirdparty->initAsSpecimen();
57 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
59 if ($action ==
'updateMask')
61 $maskconstorder =
GETPOST(
'maskconstorder',
'alpha');
62 $maskvalue =
GETPOST(
'maskorder',
'alpha');
64 if ($maskconstorder) $res =
dolibarr_set_const($db, $maskconstorder, $maskvalue,
'chaine', 0,
'', $conf->entity);
66 if (!($res > 0)) $error++;
74 } elseif ($action ==
'specimen')
76 $modele =
GETPOST(
'module',
'alpha');
79 $commande->initAsSpecimen();
80 $commande->thirdparty = $specimenthirdparty;
83 $file =
''; $classname =
''; $filefound = 0;
84 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
85 foreach ($dirmodels as $reldir)
87 $file =
dol_buildpath($reldir.
"core/modules/supplier_order/doc/pdf_".$modele.
".modules.php", 0);
88 if (file_exists($file))
91 $classname =
"pdf_".$modele;
100 $module =
new $classname($db, $commande);
102 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);
117 elseif ($action ==
'set')
120 } elseif ($action ==
'del')
125 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity);
130 elseif ($action ==
'setdoc')
132 if (
dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
136 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
145 } elseif ($action ==
'setmod')
150 dolibarr_set_const($db,
"COMMANDE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
151 } elseif ($action ==
'addcat')
154 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
155 } 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)
171 $newmodule->rights = array();
174 $newmodule->rights[$r][0] = 1190;
175 $newmodule->rights[$r][1] = $langs->trans(
"Permission1190");
176 $newmodule->rights[$r][2] =
'w';
177 $newmodule->rights[$r][3] = 0;
178 $newmodule->rights[$r][4] =
'commande';
179 $newmodule->rights[$r][5] =
'approve2';
182 $newmodule->insert_permissions(1);
185 $newmodule->delete_permissions();
188 $newmodule->insert_permissions(1);
193 elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER')
195 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value,
'chaine', 0,
'', $conf->entity);
197 if (!($res > 0)) $error++;
212 $form =
new Form($db);
214 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
218 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
232 print
'<table class="noborder centpercent">';
233 print
'<tr class="liste_titre">';
234 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
235 print
'<td>'.$langs->trans(
"Description").
'</td>';
236 print
'<td>'.$langs->trans(
"Example").
'</td>';
237 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
238 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
243 foreach ($dirmodels as $reldir)
245 $dir =
dol_buildpath($reldir.
"core/modules/supplier_order/");
249 $handle = opendir($dir);
250 if (is_resource($handle))
252 while (($file = readdir($handle)) !==
false)
254 if (substr($file, 0, 25) ==
'mod_commande_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php')
256 $file = substr($file, 0,
dol_strlen($file) - 4);
258 require_once $dir.$file.
'.php';
262 if ($module->isEnabled())
265 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
266 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
269 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
270 print $module->info();
274 print
'<td class="nowrap">';
275 $tmp = $module->getExample();
276 if (preg_match(
'/^Error/', $tmp)) {
277 $langs->load(
"errors");
278 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
279 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
283 print '<td class="center">';
284 if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file")
286 print
img_picto($langs->trans(
"Activated"),
'switch_on');
288 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>';
293 $commande->initAsSpecimen();
297 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
298 $nextval = $module->getNextValue($mysoc, $commande);
299 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
300 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
302 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
303 $nextval = $langs->trans($nextval);
304 $htmltooltip .= $nextval.
'<br>';
306 $htmltooltip .= $langs->trans($module->error).
'<br>';
310 print
'<td class="center">';
311 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
323 print
'</table><br>';
336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
337 $sql .=
" WHERE type = 'order_supplier'";
338 $sql .=
" AND entity = ".$conf->entity;
340 $resql = $db->query($sql);
344 $num_rows = $db->num_rows(
$resql);
345 while ($i < $num_rows)
347 $array = $db->fetch_array(
$resql);
348 array_push($def, $array[0]);
355 print
'<table class="noborder centpercent">'.
"\n";
356 print
'<tr class="liste_titre">'.
"\n";
357 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
358 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
359 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
360 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
361 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
362 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
367 foreach ($dirmodels as $reldir)
369 $realpath = $reldir.
"core/modules/supplier_order/doc";
374 $handle = opendir($dir);
375 if (is_resource($handle))
377 while (($file = readdir($handle)) !==
false)
379 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
381 $name = substr($file, 4,
dol_strlen($file) - 16);
382 $classname = substr($file, 0,
dol_strlen($file) - 12);
384 require_once $dir.
'/'.$file;
388 print
"<tr class=\"oddeven\">\n";
390 print (empty($module->name) ? $name : $module->name);
393 require_once $dir.
'/'.$file;
394 $module =
new $classname($db, $specimenthirdparty);
395 if (method_exists($module,
'info')) print $module->info($langs);
396 else print $module->description;
400 if (in_array($name, $def))
402 print
'<td class="center">'.
"\n";
403 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF !=
"$name")
405 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=order_supplier">';
406 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
409 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
413 print
'<td class="center">'.
"\n";
414 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=order_supplier">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
419 print
'<td class="center">';
420 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF ==
"$name")
422 print
img_picto($langs->trans(
"Default"),
'on');
424 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=order_supplier"" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
429 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
430 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
431 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
432 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
434 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
435 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
436 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
437 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
438 print
'<td class="center">';
439 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
441 print
'<td class="center">';
442 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
454 print
'</table><br>';
460 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
461 print
'<input type="hidden" name="token" value="'.newToken().
'">';
462 print
'<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
465 print
'<table class="noborder centpercent">';
466 print
'<tr class="liste_titre">';
467 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
468 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
469 print
'<td width="80"> </td>';
472 print
'<tr class="oddeven"><td>';
473 print $form->textwithpicto($langs->trans(
"UseDoubleApproval"), $langs->trans(
"Use3StepsApproval"), 1,
'help').
'<br>';
474 print $langs->trans(
"IfSetToYesDontForgetPermission");
476 print
'<input type="text" size="6" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.$conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED.
'">';
477 print
'</td><td class="right">';
478 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
479 print
"</td></tr>\n";
515 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
516 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
517 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
520 print
'<tr class="oddeven"><td colspan="2">';
521 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnOrders"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
522 $variablename =
'SUPPLIER_ORDER_FREE_TEXT';
523 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
525 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
527 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
528 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
529 print $doleditor->Create();
531 print
'</td><td class="right">';
532 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
533 print
"</td></tr>\n";
536 print
'<tr class="oddeven">';
537 print
'<td>'.$langs->trans(
"UseDispatchStatus").
'</td>';
539 print
'<td class="center">';
540 if ($conf->reception->enabled)
542 print
'<span class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableWithReceptionModule").
'</span>';
544 if ($conf->use_javascript_ajax) {
547 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
548 print $form->selectarray(
"SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS);
554 print
'</table><br>';
564 print
'<table class="noborder centpercent">';
565 print
'<tr class="liste_titre">';
566 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
567 print
'<td align="center" width="60"></td>';
568 print
'<td width="80"> </td>';
571 print
'<tr class="oddeven"><td colspan="2">';
572 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
573 print
'</td><td class="right">';
574 print
"</td></tr>\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object informations.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Class to manage suppliers.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0)
On/off button for constant.
Description and activation class for module Fournisseur.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage predefined suppliers products.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.