diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 296ef7eb251..bfbe8366139 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -359,7 +359,7 @@ class FormFile * Return a string to show the box with list of available documents for object. * This also set the property $this->numoffiles * - * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:myobject', 'mymodule_temp', ...) + * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:MyObject', 'mymodule_temp', ...) * @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. * @param string $filedir Directory to scan * @param string $urlsource Url of origin page (for return) @@ -719,7 +719,7 @@ class FormFile if (class_exists($class)) { $modellist = call_user_func($class.'::liste_modeles', $this->db); } else { - dol_print_error($this->db, "Bad value for modulepart '".$modulepart."' in showdocuments"); + dol_print_error($this->db, "Bad value for modulepart '".$modulepart."' in showdocuments (class ".$class." for Doc generation not found)"); return -1; } } diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index a493508878c..180ece04fa8 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -548,8 +548,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card + $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content + $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 689a2664c0a..935b8deb83d 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -103,6 +104,10 @@ if ($user->socid) { restrictedArea($user, 'salaries', $object->id, 'salary', ''); +$permissiontoread = $user->rights->salaries->read; +$permissiontoadd = $user->rights->salaries->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->salaries->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); + /** * Actions @@ -434,12 +439,14 @@ if ($action == "update_extras" && !empty($user->rights->salaries->read)) { * View */ +$form = new Form($db); +$formfile = new FormFile($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); + $title = $langs->trans('Salary')." - ".$langs->trans('Card'); $help_url = ""; llxHeader("", $title, $help_url); -$form = new Form($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id > 0) { $result = $object->fetch($id); @@ -1013,6 +1020,7 @@ if ($id) { $resteapayer = price2num($resteapayer, 'MT'); + /* * Action bar */ @@ -1052,6 +1060,64 @@ if ($id) { } } print ""; + + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
'; + print ''; // ancre + + $includedocgeneration = 1; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->salaries->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + //$genallowed = $permissiontoread; // If you can read, you can build the PDF to read content + $genallowed = 0; // If you can read, you can build the PDF to read content + $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + /* + $linktoelem = $form->showLinkToObjectBlock($object, null, array('salaries')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + */ + + print '
'; + + $MAXEVENT = 10; + + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + //$somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + + print '
'; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'salary'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->salaries->dir_output; + $trackid = 'salary'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page