FIX ODT management inverted between purchase invoice and order

This commit is contained in:
Laurent Destailleur 2023-03-08 02:08:25 +01:00
parent b6012e07d8
commit 16257a0e74
3 changed files with 45 additions and 25 deletions

View File

@ -38,9 +38,11 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "other", "orders"));
$action = GETPOST('action', 'aZ09');
$type = GETPOST('type', 'alpha');
$value = GETPOST('value', 'alpha');
$action = GETPOST('action', 'aZ09');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
@ -96,7 +98,9 @@ if ($action == 'specimen') { // For invoices
$facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier)
// Search template files
$file = ''; $classname = ''; $filefound = 0;
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0);
@ -183,12 +187,12 @@ if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') {
* View
*/
$form = new Form($db);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", "");
$form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup');
@ -203,6 +207,7 @@ print dol_get_fiche_head($head, 'invoice', $langs->trans("Suppliers"), -1, 'comp
print load_fiche_titre($langs->trans("SuppliersInvoiceNumberingModel"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="100">'.$langs->trans("Name").'</td>';
@ -242,7 +247,7 @@ foreach ($dirmodels as $reldir) {
print $module->info();
print '</td>';
// Show example of numbering model
// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
@ -295,13 +300,13 @@ foreach ($dirmodels as $reldir) {
}
}
print '</table><br>';
print '</table></div><br>';
/*
* Modeles documents for supplier invoices
* Documents models for supplier invoices
*/
print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
@ -327,6 +332,7 @@ if ($resql) {
dol_print_error($db);
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
@ -378,7 +384,7 @@ foreach ($dirmodels as $reldir) {
//if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name")
//{
// Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type=invoice_supplier">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type=invoice_supplier">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
/*}
@ -389,7 +395,7 @@ foreach ($dirmodels as $reldir) {
print "</td>";
} else {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
@ -398,9 +404,9 @@ foreach ($dirmodels as $reldir) {
if (getDolGlobalString("INVOICE_SUPPLIER_ADDON_PDF") == "$name") {
//print img_picto($langs->trans("Default"),'on');
// Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';
@ -418,7 +424,7 @@ foreach ($dirmodels as $reldir) {
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
print '<td class="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.urlencode($name).'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
print '</td>';
print "</tr>\n";
@ -430,7 +436,7 @@ foreach ($dirmodels as $reldir) {
}
}
print '</table><br>';
print '</table></div><br>';
/*
* Other options
@ -441,6 +447,8 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
@ -470,7 +478,7 @@ print '</td><td class="right">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</table><br>';
print '</table></div><br>';
print '</form>';
@ -480,6 +488,8 @@ print '</form>';
*/
print load_fiche_titre($langs->trans("Notifications"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
@ -493,6 +503,7 @@ print '</td><td class="right">';
print "</td></tr>\n";
print '</table>';
print '</div>';
// End of page
llxFooter();

View File

@ -38,25 +38,28 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "other", "orders", "stocks"));
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
$type = GETPOST('type', 'alpha');
$value = GETPOST('value', 'alpha');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$label = GETPOST('label', 'alpha');
$action = GETPOST('action', 'aZ09');
$scandir = GETPOST('scan_dir', 'alpha');
$specimenthirdparty = new Societe($db);
$specimenthirdparty->initAsSpecimen();
$error = 0;
if (!$user->admin) {
accessforbidden();
}
/*
* Actions
*/
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
@ -77,7 +80,9 @@ if ($action == 'updateMask') {
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'specimen') { // For orders
}
if ($action == 'specimen') { // For orders
$modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db);
@ -317,8 +322,8 @@ print '</table></div><br>';
/*
* Documents models for supplier orders
*/
* Documents models for supplier orders
*/
print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');

View File

@ -119,7 +119,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="page_y" value="">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
@ -181,7 +181,11 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
}
$texte .= '</div>';
}
// Add input to upload a new template file.
$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte .= '<input type="hidden" value="SUPPLIER_ORDER_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte .= '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
$texte .= '</div>';
$texte .= '</td>';
$texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';