This commit is contained in:
Alexandre SPANGARO 2019-06-26 17:13:38 +02:00
parent 9da91c06ed
commit 8f0f8f74f7
4 changed files with 288 additions and 112 deletions

View File

@ -36,7 +36,7 @@ function intracommReportAdminPrepareHead()
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = dol_buildpath("/intracommreport/admin/intracommreport.php", 1); $head[$h][0] = DOL_URL_ROOT.'/intracommreport/admin/intracommreport.php';
$head[$h][1] = $langs->trans("Parameters"); $head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'general'; $head[$h][2] = 'general';
$h++; $h++;
@ -50,3 +50,32 @@ function intracommReportAdminPrepareHead()
complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin', 'remove');
return $head; return $head;
} }
/**
* Prepare array with list of tabs
*
* @return array Array of tabs to show
*/
function intracommReportPrepareHead()
{
global $langs, $conf;
$langs->load("intracommreport");
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/intracommreport/card.php?rowid='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport');
complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport', 'remove');
return $head;
}

View File

@ -1369,11 +1369,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Intracomm report // Intracomm report
if (! empty($conf->intracommreport->enabled)) if (! empty($conf->intracommreport->enabled))
{ {
$newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuDeclaration"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1);
if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) {
// DEB / DES // DEB / DES
$newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuDeclarationNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1); $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1);
$newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuDeclarationList"), 1, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1);
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2019 Open-DSI <support@open-dsi.fr> /* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2019 Open-DSI <support@open-dsi.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,7 +17,7 @@
*/ */
/** /**
* \file htdocs/intracommreport/export.php * \file htdocs/intracommreport/card.php
* \ingroup Intracomm report * \ingroup Intracomm report
* \brief Page to manage intracomm report export * \brief Page to manage intracomm report export
*/ */
@ -36,13 +37,91 @@ $formother = new FormOther($db);
$year = GETPOST('year'); $year = GETPOST('year');
$month = GETPOST('month'); $month = GETPOST('month');
$type_declaration = GETPOST('type'); $type_declaration = GETPOST('type');
$backtopage=GETPOST('backtopage', 'alpha');
// Mode creation /*
* Actions
*/
if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes')
{
$result=$object->delete($id, $user);
if ($result > 0)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
else
{
header("Location: list.php");
exit;
}
}
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->subscription = (int) $subscription;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
if (empty($object->label)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
}
else {
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
}
if ($num) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors');
}
}
if (! $error)
{
$id=$object->create($user);
if ($id > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create';
}
}
else
{
$action = 'create';
}
}
/*
* View
*/
// Creation mode
if ($action == 'create') if ($action == 'create')
{ {
$title = $langs->trans("IntracommReportDEBTitle"); $title = $langs->trans("IntracommReportTitle");
llxHeader("", $title); llxHeader("", $title);
print load_fiche_titre($langs->trans("IntracommReportDEBTitle")); 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="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -52,42 +131,107 @@ if ($action == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Label
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 "</td>\n";
// Analysis period // Analysis period
print '<tr>'; print '<tr>';
print '<td class="titlefieldcreate fieldrequired">'; print '<td class="titlefieldcreate fieldrequired">';
print $langs->trans("AnalysisPeriod"); print $langs->trans("AnalysisPeriod");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$TabMonth = array(); print $formother->select_month($month ? date('M') : $month,'month',0, 1, 'widthauto valignmiddle ');
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT)); print $formother->select_year($year ? date('Y') : $year,'year',0, 3, 3);
//print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month);
print $formother->select_month(empty($month) ? date('M') : $month,'month',0, 1);
print $formother->select_year(empty($year) ? date('Y') : $year,'year',0, 3, 3);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Type of declaration // Type of declaration
print '<tr>'; $typeOfDeclaration["introduction"] = $langs->trans("Introduction");
print '<td>'; $typeOfDeclaration["expedition"] = $langs->trans("Expedition");
print $langs->trans("TypeOfDeclaration"); print '<tr><td class="fieldrequired">'.$langs->trans("TypeOfDeclaration")."</td><td>\n";
print '</td>'; print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha')?GETPOST('type_declaration', 'alpha'):$object->type_declaration, 0);
print '<td>'; print "</td>\n";
//print $ATMform->combo('','type', array('introduction'=>'Introduction', 'expedition'=>'Expédition'), $type_declaration);
print $form->selectarray('type', $type, $type_declaration);
print '</td>';
print '</tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center">'; print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="button" value="'.$langs->trans("ExportXML").'">'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} }
if ($id > 0 && $action != 'edit') {
/* ************************************************************************** */
/* */
/* View mode */
/* */
/* ************************************************************************** */
$res = $object->fetch($id);
if ($res < 0) {
dol_print_error($db, $object->error);
exit;
}
/*
* Show tabs
*/
$head = intracommreport_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("IntracommReport"), -1, 'user');
// Confirm remove report
if ($action == 'delete') {
$formquestion = array();
if ($backtopage) {
$formquestion[] = array(
'type' => 'hidden',
'name' => 'backtopage',
'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);
}
$linkback = '<a href="' . DOL_URL_ROOT . '/intracommreport/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';
// Type
print '<tr><td class="titlefield">' . $langs->trans("Type") . '</td><td class="valeur">' . $object->declaration . "</td></tr>\n";
// Analysis Period
print '<tr><td>' . $langs->trans("AnalysisPeriod") . '</td><td class="valeur">' . $object->period . '</td>';
print '</tr>';
// Type of Declaration
print '<tr><td>' . $langs->trans("TypeOfDeclaration") . '</td><td class="valeur">' . $object->type_declaration . '</td>';
print '</tr>';
print "</table>\n";
print "</div></div></div>\n";
print '<div style="clear:both"></div>';
dol_fiche_end();
}
/* /*
switch($action) { switch($action) {
case 'generateXML': case 'generateXML':
@ -185,4 +329,6 @@ function _export_xml_des($type_declaration, $period_year, $period_month) {
} }
*/ */
// End of page
llxFooter(); llxFooter();
$db->close();

View File

@ -7,28 +7,29 @@ IntracommReportAbout = About intracommreport
INTRACOMMREPORT_NUM_AGREMENT=Numéro d'agrément (délivré par le CISD de rattachement) INTRACOMMREPORT_NUM_AGREMENT=Numéro d'agrément (délivré par le CISD de rattachement)
INTRACOMMREPORT_TYPE_ACTEUR=Type d'acteur INTRACOMMREPORT_TYPE_ACTEUR=Type d'acteur
INTRACOMMREPORT_ROLE_ACTEUR=Rôle joué par l'acteur INTRACOMMREPORT_ROLE_ACTEUR=Rôle joué par l'acteur
INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION=Niveau d'oligation sur les introductions INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION=Niveau d'obligation sur les introductions
INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION=Niveau d'obligation sur les expéditions INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION=Niveau d'obligation sur les expéditions
INTRACOMMREPORT_CATEG_FRAISDEPORT=Catégorie de services de type "Frais de port" INTRACOMMREPORT_CATEG_FRAISDEPORT=Catégorie de services de type "Frais de port"
INTRACOMMREPORT_NUM_DECLARATION=Numéro de déclarant INTRACOMMREPORT_NUM_DECLARATION=Numéro de déclarant
#Menu #Menu
MenuDeclaration=Export Pro-Douane MenuIntracommReport=Intracomm report
MenuDeclarationNew=Nouvelle déclaration MenuIntracommReportNew=New declaration
MenuDeclarationList=Liste MenuIntracommReportList=List
# View # View
Declaration=Declaration
AnalysisPeriod=Analysis period AnalysisPeriod=Analysis period
TypeOfDeclaration=Type of declaration TypeOfDeclaration=Type of declaration
DEB=Goods exchange declaration (DEB)
DES=Services exchange declaration (DES)
#Page d'export #Page d'export
IntracommReportDEBTitle=Export d'un fichier XML au format ProDouane - DEB IntracommReportTitle=Preparation of an XML file in ProDouane format
IntracommReportDESTitle=Export d'un fichier XML au format ProDouane - DES
#Liste #Liste
IntracommReportListDEB=Liste des déclarations générées (DEB) IntracommReportList=List of generated declarations
IntracommReportListDES=Liste des déclarations générées (DES)
IntracommReportNumber=Numéro déclaration IntracommReportNumber=Numéro déclaration
IntracommReportPeriod=Période d'analyse IntracommReportPeriod=Période d'analyse
IntracommReportTypeDeclaration=Type de déclaration IntracommReportTypeDeclaration=Type de déclaration