NEW Can upload a file with drag and drop on social contributions

This commit is contained in:
Laurent Destailleur 2023-05-02 17:04:22 +02:00
parent 3b20d0130c
commit f5d7ac2bc1
5 changed files with 240 additions and 240 deletions

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
if (isModEnabled('project')) { if (isModEnabled('project')) {
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -108,6 +109,7 @@ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} }
if (empty($reshook)) {
// Classify paid // Classify paid
if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') {
$object->fetch($id); $object->fetch($id);
@ -322,8 +324,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
} }
} }
// Actions to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
/* /*
@ -338,6 +341,8 @@ if (isModEnabled('project')) {
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
} }
$now = dol_now();
$title = $langs->trans("SocialContribution").' - '.$langs->trans("Card"); $title = $langs->trans("SocialContribution").' - '.$langs->trans("Card");
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)'; $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("", $title, $help_url); llxHeader("", $title, $help_url);
@ -347,7 +352,7 @@ llxHeader("", $title, $help_url);
if ($action == 'create') { if ($action == 'create') {
print load_fiche_titre($langs->trans("NewSocialContribution")); print load_fiche_titre($langs->trans("NewSocialContribution"));
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form name="charge" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -499,10 +504,17 @@ if ($id > 0) {
$formconfirm = $hookmanager->resPrint; $formconfirm = $hookmanager->resPrint;
} }
/*
* View card
*/
print dol_get_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill', 0, '', '', 0, '', 1);
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
print dol_get_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill');
// Social contribution card
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Ref customer // Ref customer
@ -543,32 +555,21 @@ if ($id > 0) {
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>';
if ($user->rights->tax->charges->creer) { if ($permissiontoadd) {
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.((int) $object->id).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'fk_project', 0, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
} }
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'fk_project' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= ' : '.$proj->getNomUrl(1); $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) { if ($proj->title) {
$morehtmlref .= ' - '.$proj->title; $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
} }
} else {
$morehtmlref .= '';
} }
} }
} }
@ -576,8 +577,6 @@ if ($id > 0) {
$morehtmlright = ''; $morehtmlright = '';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);

View File

@ -124,13 +124,13 @@ if ($object->id) {
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$morehtmlref .= '<br>';
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= ' : '.$proj->getNomUrl(1); $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) { if ($proj->title) {
$morehtmlref .= ' - '.$proj->title; $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
} }
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';

View File

@ -93,13 +93,13 @@ $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $us
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$morehtmlref .= '<br>';
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= ' : '.$proj->getNomUrl(1); $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) { if ($proj->title) {
$morehtmlref .= ' - '.$proj->title; $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
} }
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';

View File

@ -96,11 +96,11 @@ if ($id > 0 || !empty($ref)) {
// Project // Project
if (isModEnabled('project')) { if (isModEnabled('project')) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$morehtmlref .= '<br>';
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= ' : '.$proj->getNomUrl(1); $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) { if ($proj->title) {
$morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>'; $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
} }

View File

@ -69,7 +69,7 @@ if (isModEnabled('incoterm')) {
} }
$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); $id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int'));
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST("confirm"); $confirm = GETPOST("confirm");
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
@ -110,10 +110,11 @@ if ($id > 0 || !empty($ref)) {
} }
// Security check // Security check
$socid = ''; $socid = GETPOST('socid', 'int');
if (!empty($user->socid)) { if (!empty($user->socid)) {
$socid = $user->socid; $socid = $user->socid;
} }
$isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft);