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;
$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][2] = 'general';
$h++;
@ -50,3 +50,32 @@ function intracommReportAdminPrepareHead()
complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin', 'remove');
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
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)) {
// 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/list.php?leftmenu=intracommreport", $langs->trans("MenuDeclarationList"), 1, $user->rights->intracommreport->read, '', $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("MenuIntracommReportList"), 1, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1);
}
}

View File

@ -1,5 +1,6 @@
<?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
* 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
* \brief Page to manage intracomm report export
*/
@ -36,13 +37,91 @@ $formother = new FormOther($db);
$year = GETPOST('year');
$month = GETPOST('month');
$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')
{
$title = $langs->trans("IntracommReportDEBTitle");
$title = $langs->trans("IntracommReportTitle");
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 '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -52,137 +131,204 @@ if ($action == 'create')
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
print '<tr>';
print '<td class="titlefieldcreate fieldrequired">';
print $langs->trans("AnalysisPeriod");
print '</td>';
print '<td>';
$TabMonth = array();
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT));
//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 $formother->select_month($month ? date('M') : $month,'month',0, 1, 'widthauto valignmiddle ');
print $formother->select_year($year ? date('Y') : $year,'year',0, 3, 3);
print '</td>';
print '</tr>';
// Type of declaration
print '<tr>';
print '<td>';
print $langs->trans("TypeOfDeclaration");
print '</td>';
print '<td>';
//print $ATMform->combo('','type', array('introduction'=>'Introduction', 'expedition'=>'Expédition'), $type_declaration);
print $form->selectarray('type', $type, $type_declaration);
print '</td>';
print '</tr>';
$typeOfDeclaration["introduction"] = $langs->trans("Introduction");
$typeOfDeclaration["expedition"] = $langs->trans("Expedition");
print '<tr><td class="fieldrequired">'.$langs->trans("TypeOfDeclaration")."</td><td>\n";
print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha')?GETPOST('type_declaration', 'alpha'):$object->type_declaration, 0);
print "</td>\n";
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("ExportXML").'">';
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '</div>';
print '</form>';
}
/*
switch($action) {
case 'generateXML':
$obj = new TDebProdouane($PDOdb);
$obj->load($PDOdb, GETPOST('id_declaration'));
$obj->generateXMLFile();
break;
case 'list':
_liste($exporttype);
break;
case 'export':
if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
default:
if ($exporttype == 'deb') _print_form_deb();
else _print_form_des();
break;
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();
}
function _print_form_des()
{
global $langs, $formother, $year, $month, $type_declaration;
/*
switch($action) {
case 'generateXML':
$obj = new TDebProdouane($PDOdb);
$obj->load($PDOdb, GETPOST('id_declaration'));
$obj->generateXMLFile();
break;
case 'list':
_liste($exporttype);
break;
case 'export':
if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
default:
if ($exporttype == 'deb') _print_form_deb();
else _print_form_des();
break;
}
$title = $langs->trans("IntracommReportDESTitle");
llxHeader("", $title);
print load_fiche_titre($langs->trans("IntracommReportDESTitle"));
function _print_form_des()
{
global $langs, $formother, $year, $month, $type_declaration;
dol_fiche_head();
$title = $langs->trans("IntracommReportDESTitle");
llxHeader("", $title);
print load_fiche_titre($langs->trans("IntracommReportDESTitle"));
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="export" />';
print '<input type="hidden" name="exporttype" value="des" />';
print '<input type="hidden" name="type" value="expedition" />'; // Permet d'utiliser le bon select de la requête sql
dol_fiche_head();
print '<table width="100%" class="noborder">';
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="export" />';
print '<input type="hidden" name="exporttype" value="des" />';
print '<input type="hidden" name="type" value="expedition" />'; // Permet d'utiliser le bon select de la requête sql
print '<tr class="liste_titre"><td colspan="2">';
print 'Paramètres de l\'export';
print '</td></tr>';
print '<table width="100%" class="noborder">';
print '<tr>';
print '<td>Période d\'analyse</td>';
print '<td>';
$TabMonth = array();
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT));
//print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month);
print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5);
print '</td>';
print '</tr>';
print '<tr class="liste_titre"><td colspan="2">';
print 'Paramètres de l\'export';
print '</td></tr>';
print '</table>';
print '<tr>';
print '<td>Période d\'analyse</td>';
print '<td>';
$TabMonth = array();
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT));
//print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month);
print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5);
print '</td>';
print '</tr>';
print '<div class="tabsAction">';
print '<input class="butAction" type="submit" value="Exporter XML" />';
print '</div>';
print '</table>';
print '</form>';
}
print '<div class="tabsAction">';
print '<input class="butAction" type="submit" value="Exporter XML" />';
print '</div>';
function _export_xml_deb($type_declaration, $period_year, $period_month) {
print '</form>';
}
global $db, $conf;
function _export_xml_deb($type_declaration, $period_year, $period_month) {
$obj = new TDebProdouane($db);
$obj->entity = $conf->entity;
$obj->mode = 'O';
$obj->periode = $period_year.'-'.$period_month;
$obj->type_declaration = $type_declaration;
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
$obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month);
if(empty($obj->errors)) {
$obj->save($PDOdb);
$obj->generateXMLFile();
}
else setEventMessage($obj->errors, 'warnings');
}
global $db, $conf;
function _export_xml_des($type_declaration, $period_year, $period_month) {
$obj = new TDebProdouane($db);
$obj->entity = $conf->entity;
$obj->mode = 'O';
$obj->periode = $period_year.'-'.$period_month;
$obj->type_declaration = $type_declaration;
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
$obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month);
if(empty($obj->errors)) {
$obj->save($PDOdb);
$obj->generateXMLFile();
}
else setEventMessage($obj->errors, 'warnings');
}
global $PDOdb, $conf;
function _export_xml_des($type_declaration, $period_year, $period_month) {
$obj = new TDebProdouane($PDOdb);
$obj->entity = $conf->entity;
$obj->periode = $period_year.'-'.$period_month;
$obj->type_declaration = $type_declaration;
$obj->exporttype = 'des';
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
$obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration);
if(empty($obj->errors)) {
$obj->save($PDOdb);
$obj->generateXMLFile();
}
else setEventMessage($obj->errors, 'warnings');
}
*/
global $PDOdb, $conf;
$obj = new TDebProdouane($PDOdb);
$obj->entity = $conf->entity;
$obj->periode = $period_year.'-'.$period_month;
$obj->type_declaration = $type_declaration;
$obj->exporttype = 'des';
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
$obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration);
if(empty($obj->errors)) {
$obj->save($PDOdb);
$obj->generateXMLFile();
}
else setEventMessage($obj->errors, 'warnings');
}
*/
// End of page
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_TYPE_ACTEUR=Type d'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_CATEG_FRAISDEPORT=Catégorie de services de type "Frais de port"
INTRACOMMREPORT_NUM_DECLARATION=Numéro de déclarant
#Menu
MenuDeclaration=Export Pro-Douane
MenuDeclarationNew=Nouvelle déclaration
MenuDeclarationList=Liste
MenuIntracommReport=Intracomm report
MenuIntracommReportNew=New declaration
MenuIntracommReportList=List
# View
Declaration=Declaration
AnalysisPeriod=Analysis period
TypeOfDeclaration=Type of declaration
DEB=Goods exchange declaration (DEB)
DES=Services exchange declaration (DES)
#Page d'export
IntracommReportDEBTitle=Export d'un fichier XML au format ProDouane - DEB
IntracommReportDESTitle=Export d'un fichier XML au format ProDouane - DES
IntracommReportTitle=Preparation of an XML file in ProDouane format
#Liste
IntracommReportListDEB=Liste des déclarations générées (DEB)
IntracommReportListDES=Liste des déclarations générées (DES)
IntracommReportList=List of generated declarations
IntracommReportNumber=Numéro déclaration
IntracommReportPeriod=Période d'analyse
IntracommReportTypeDeclaration=Type de déclaration