This commit is contained in:
Frédéric FRANCE 2020-12-13 10:51:12 +01:00
parent 203fc77e9f
commit 2a9d38575d
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -30,54 +30,57 @@ $langs->loadLangs(array("intracommreport"));
$action = GETPOST('action');
$exporttype = GETPOST('exporttype'); // DEB ou DES
if (empty($exporttype)) $exporttype = 'deb';
if (empty($exporttype)) {
$exporttype = 'deb';
}
$form = new Form($db);
$formother = new FormOther($db);
$year = GETPOST('year');
$month = GETPOST('month');
$type_declaration = GETPOST('type');
$label = (string) GETPOST('label', 'alphanohtml');
$type_declaration = GETPOSTINT('type');
$backtopage = GETPOST('backtopage', 'alpha');
$declaration = array(
"deb" => $langs->trans("DEB"),
"des" => $langs->trans("DES"),
);
/*
* Actions
*/
if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes')
{
if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') {
$result = $object->delete($id, $user);
if ($result > 0)
{
if (!empty($backtopage))
{
if ($result > 0) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
else {
} else {
header("Location: list.php");
exit;
}
}
else {
} else {
$errmesg = $object->error;
}
}
if ($action == 'add' && $user->rights->intracommreport->write) {
$object->label = trim($label);
$object->type = trim($type);
$object->type_declaration = (int) $statut;
$object->type = trim($exporttype);
$object->type_declaration = $type_declaration;
$object->subscription = (int) $subscription;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
if ($ret < 0) {
$error++;
}
if (empty($object->label)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
}
else {
} else {
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
$result = $db->query($sql);
if ($result) {
@ -90,20 +93,16 @@ if ($action == 'add' && $user->rights->intracommreport->write) {
}
}
if (!$error)
{
if (!$error) {
$id = $object->create($user);
if ($id > 0)
{
if ($id > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else {
} else {
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create';
}
}
else {
} else {
$action = 'create';
}
}
@ -113,15 +112,14 @@ if ($action == 'add' && $user->rights->intracommreport->write) {
*/
// Creation mode
if ($action == 'create')
{
if ($action == 'create') {
$title = $langs->trans("IntracommReportTitle");
llxHeader("", $title);
print load_fiche_titre($langs->trans("IntracommReportTitle"));
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="export" />';
print '<input type="hidden" name="action" value="add" />';
print dol_get_fiche_head();
@ -131,10 +129,8 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
// Declaration
$declaration["deb"] = $langs->trans("DEB");
$declaration["des"] = $langs->trans("DES");
print '<tr><td class="fieldrequired">'.$langs->trans("Declaration")."</td><td>\n";
print $form->selectarray("declaration", $declaration, GETPOST('declaration', 'alpha') ?GETPOST('declaration', 'alpha') : $object->declaration, 0);
print $form->selectarray("declaration", $declaration, GETPOST('declaration', 'alpha') ? GETPOST('declaration', 'alpha') : $object->declaration, 0);
print "</td>\n";
// Analysis period
@ -195,8 +191,15 @@ if ($id > 0 && $action != 'edit') {
'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])
);
}
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteReport"),
$langs->trans("ConfirmDeleteReport"), "confirm_delete", $formquestion, 'no', 1);
print $form->formconfirm(
"card.php?rowid=".$id,
$langs->trans("DeleteReport"),
$langs->trans("ConfirmDeleteReport"),
"confirm_delete",
$formquestion,
'no',
1
);
}
$linkback = '<a href="'.DOL_URL_ROOT.'/intracommreport/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';