This commit is contained in:
Alexandre SPANGARO 2019-05-20 14:52:06 +02:00
parent a239e0e81f
commit ba4bd274c0
4 changed files with 118 additions and 19 deletions

View File

@ -395,3 +395,16 @@ INSERT INTO llx_c_transport_mode (code, libelle, active) VALUES ('PRO', 'Propuls
ALTER TABLE llx_facture ADD COLUMN fk_mode_transport integer after location_incoterms;
ALTER TABLE llx_facture_fourn ADD COLUMN fk_mode_transport integer after location_incoterms;
create table llx_intracommreport
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL, -- report reference number
entity integer DEFAULT 1 NOT NULL, -- multi company id
type_declaration varchar(32),
periode varchar(32),
mode varchar(32),
content_xml text,
exporttype varchar(10)
)ENGINE=innodb;

View File

@ -0,0 +1,30 @@
-- ===================================================================
-- Copyright (C) 2019 Open-DSI <aspangaro@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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ===================================================================
create table llx_intracommreport
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL, -- report reference number
entity integer DEFAULT 1 NOT NULL, -- multi company id
type_declaration varchar(32),
periode varchar(32),
mode varchar(32),
content_xml text,
exporttype varchar(10)
)ENGINE=innodb;

View File

@ -1,16 +1,49 @@
<?php
/* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class TDebProdouane extends TObjetStd {
/**
* \file htdocs/intracommreport/class/intracommreport.class.php
* \ingroup Intracomm report
* \brief File of class to manage intracomm report
*/
/**
* Class to manage intracomm report
*/
class DebProdouane extends CommonObject
{
static $TType = array(
'introduction'=>'Introduction'
,'expedition'=>'Expédition'
);
function __construct(&$ATMdb) {
$this->ATMdb = $ATMdb;
$this->errors = array();
/**
* Constructor
*
* @param DoliDB $db Database handle
*/
public function __construct($db)
{
global $conf;
$this->db = $db;
/*
parent::set_table(MAIN_DB_PREFIX.'deb_prodouane');
parent::add_champs('numero_declaration,entity','type=entier;');
parent::add_champs('type_declaration,periode,mode','type=chaine;');
@ -18,6 +51,7 @@ class TDebProdouane extends TObjetStd {
parent::add_champs('exporttype', array('type'=>'string', 'size'=>'10'));
parent::start();
parent::_init_vars();
*/
$this->exporttype = 'deb';
}
@ -41,25 +75,25 @@ class TDebProdouane extends TObjetStd {
$e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?><INSTAT></INSTAT>');
$enveloppe = $e->addChild('Envelope');
$enveloppe->addChild('envelopeId', $conf->global->EXPORT_PRO_DEB_NUM_AGREMENT);
$enveloppe->addChild('envelopeId', $conf->global->INTRACOMMREPORT_NUM_AGREMENT);
$date_time = $enveloppe->addChild('DateTime');
$date_time->addChild('date', date('Y-m-d'));
$date_time->addChild('time', date('H:i:s'));
$party = $enveloppe->addChild('Party');
$party->addAttribute('partType', $conf->global->EXPORT_PRO_DEB_TYPE_ACTEUR);
$party->addAttribute('partyRole', $conf->global->EXPORT_PRO_DEB_ROLE_ACTEUR);
$party->addAttribute('partType', $conf->global->INTRACOMMREPORT_TYPE_ACTEUR);
$party->addAttribute('partyRole', $conf->global->INTRACOMMREPORT_ROLE_ACTEUR);
$party->addChild('partyId', $party_id);
$party->addChild('partyName', $declarant);
$enveloppe->addChild('softwareUsed', 'Dolibarr');
$declaration = $enveloppe->addChild('Declaration');
$declaration->addChild('declarationId', $id_declaration);
$declaration->addChild('referencePeriod', $periode_reference);
if($conf->global->EXPORT_PRO_DEB_TYPE_ACTEUR === 'PSI') $psiId = $party_id;
if($conf->global->INTRACOMMREPORT_TYPE_ACTEUR === 'PSI') $psiId = $party_id;
else $psiId = 'NA';
$declaration->addChild('PSIId', $psiId);
$function = $declaration->addChild('Function');
$functionCode = $function->addChild('functionCode', $mode);
$declaration->addChild('declarationTypeCode', $conf->global->{'EXPORT_PRO_DEB_NIV_OBLIGATION_'.strtoupper($type)});
$declaration->addChild('declarationTypeCode', $conf->global->{'INTRACOMMREPORT_NIV_OBLIGATION_'.strtoupper($type)});
$declaration->addChild('flowCode', ($type == 'introduction' ? 'A' : 'D'));
$declaration->addChild('currencyCode', $conf->global->MAIN_MONNAIE);
/********************************************************************/
@ -118,9 +152,9 @@ class TDebProdouane extends TObjetStd {
return 0;
}
if($exporttype == 'deb' && $conf->global->EXPORT_PRO_DEB_CATEG_FRAISDEPORT > 0) {
if($exporttype == 'deb' && $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT > 0) {
$categ_fraisdeport = new Categorie($db);
$categ_fraisdeport->fetch($conf->global->EXPORT_PRO_DEB_CATEG_FRAISDEPORT);
$categ_fraisdeport->fetch($conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT);
$TLinesFraisDePort = array();
}
@ -136,7 +170,7 @@ class TDebProdouane extends TObjetStd {
// On n'arrête pas la boucle car on veut savoir quels sont tous les tiers qui n'ont pas de pays renseigné
$this->errors[] = 'Pays non renseigné pour le tiers <a href="'.dol_buildpath('/societe/soc.php',1).'?socid='.$res->id_client.'">'.$res->nom.'</a>';
} else {
if($conf->global->EXPORT_PRO_DEB_CATEG_FRAISDEPORT > 0 && $categ_fraisdeport->containsObject('product', $res->id_prod)) {
if($conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT > 0 && $categ_fraisdeport->containsObject('product', $res->id_prod)) {
$TLinesFraisDePort[] = $res;
} else $this->addItemXMl($declaration, $res, '', $i);
}

View File

@ -1,16 +1,38 @@
<?php
/* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require './config.php';
/**
* \file htdocs/intracommreport/export.php
* \ingroup Intracomm report
* \brief Page to manage intracomm report export
*/
require_once '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
dol_include_once('/intracommreport/class/deb_prodouane.class.php');
require_once DOL_DOCUMENT_ROOT . '/intracommreport/class/intracommreport.class.php';
$action = GETPOST('action');
$exporttype = GETPOST('exporttype'); // DEB ou DES
if (empty($exporttype)) $exporttype = 'deb';
/*
$PDOdb = new TPDOdb;
$ATMform = new TFormCore;
*/
$formother = new FormOther($db);
$year = GETPOST('year');
$month = GETPOST('month');
@ -65,7 +87,7 @@ function _print_form_deb() {
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 $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>';
@ -74,7 +96,7 @@ function _print_form_deb() {
print 'Type de déclaration';
print '</td>';
print '<td>';
print $ATMform->combo('','type', array('introduction'=>'Introduction', 'expedition'=>'Expédition'), $type_declaration);
//print $ATMform->combo('','type', array('introduction'=>'Introduction', 'expedition'=>'Expédition'), $type_declaration);
print '</td>';
print '</tr>';
@ -116,7 +138,7 @@ function _print_form_des()
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 $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>';