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