Some correct
This commit is contained in:
parent
7107354f81
commit
725ef1057d
@ -66,7 +66,7 @@ class modIntracommreport extends DolibarrModules
|
|||||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||||
$this->conflictwith = array(); // List of modules id this module is in conflict with
|
$this->conflictwith = array(); // List of modules id this module is in conflict with
|
||||||
$this->phpmin = array(5,5); // Minimum version of PHP required by module
|
$this->phpmin = array(5,5); // Minimum version of PHP required by module
|
||||||
$this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module
|
$this->need_dolibarr_version = array(10,0); // Minimum version of Dolibarr required by module
|
||||||
$this->langfiles = array("intracommreport");
|
$this->langfiles = array("intracommreport");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
||||||
* Copyright (C) 2019 Open-DSI <support@open-dsi.fr>
|
* Copyright (C) 2019-2020 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
|
||||||
@ -34,7 +34,7 @@ if (! $user->admin) accessforbidden();
|
|||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
|
||||||
// Parameters ACCOUNTING_* and others
|
// Parameters INTRACOMMREPORT_* and others
|
||||||
$list_DEB = array (
|
$list_DEB = array (
|
||||||
'INTRACOMMREPORT_NUM_AGREMENT',
|
'INTRACOMMREPORT_NUM_AGREMENT',
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
||||||
* Copyright (C) 2019 Open-DSI <support@open-dsi.fr>
|
* Copyright (C) 2019-2020 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
|
||||||
|
|||||||
@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
|
||||||
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file class/actions_intracommreport.class.php
|
|
||||||
* \ingroup intracommreport
|
|
||||||
* \brief This file is an example hook overload class file
|
|
||||||
* Put some comments here
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Actionsintracommreport
|
|
||||||
*/
|
|
||||||
class Actionsintracommreport
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
|
|
||||||
*/
|
|
||||||
public $results = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string String displayed by executeHook() immediately after return
|
|
||||||
*/
|
|
||||||
public $resprints;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Errors
|
|
||||||
*/
|
|
||||||
public $errors = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overloading the doActions function : replacing the parent's function with the one below
|
|
||||||
*
|
|
||||||
* @param array() $parameters Hook metadatas (context, etc...)
|
|
||||||
* @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
|
|
||||||
* @param string &$action Current action (if set). Generally create or edit or null
|
|
||||||
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
|
|
||||||
* @return int < 0 on error, 0 on success, 1 to replace standard code
|
|
||||||
*/
|
|
||||||
function doActions($parameters, &$object, &$action, $hookmanager)
|
|
||||||
{
|
|
||||||
$error = 0; // Error counter
|
|
||||||
$myvalue = 'test'; // A result value
|
|
||||||
|
|
||||||
print_r($parameters);
|
|
||||||
echo "action: " . $action;
|
|
||||||
print_r($object);
|
|
||||||
|
|
||||||
if (in_array('somecontext', explode(':', $parameters['context'])))
|
|
||||||
{
|
|
||||||
// do something only for the context 'somecontext'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$this->results = array('myreturn' => $myvalue);
|
|
||||||
$this->resprints = 'A text to show';
|
|
||||||
return 0; // or return 1 to replace standard code
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->errors[] = 'Error message';
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
||||||
* Copyright (C) 2019 Open-DSI <support@open-dsi.fr>
|
* Copyright (C) 2019-2020 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
|
||||||
@ -45,7 +45,6 @@ class IntracommReport extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
*
|
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $ismultientitymanaged = 1;
|
public $ismultientitymanaged = 1;
|
||||||
@ -54,6 +53,7 @@ class IntracommReport extends CommonObject
|
|||||||
* DEB - Product
|
* DEB - Product
|
||||||
*/
|
*/
|
||||||
const TYPE_DEB = 0;
|
const TYPE_DEB = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DES - Service
|
* DES - Service
|
||||||
*/
|
*/
|
||||||
@ -89,10 +89,13 @@ class IntracommReport extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $mode O pour création, R pour régénération (apparemment toujours 0 dans la cadre des échanges XML selon la doc)
|
* Generate XML file
|
||||||
* @param $type introduction ou expedition
|
*
|
||||||
|
* @param int $mode O for create, R for regenerate (Look always 0 ment toujours 0 within the framework of XML exchanges according to documentation)
|
||||||
|
* @param string $type introduction or expedition
|
||||||
|
* @param string $period_reference Period of reference
|
||||||
*/
|
*/
|
||||||
function getXML($mode = 'O', $type = 'introduction', $periode_reference = '')
|
function getXML($mode = 'O', $type = 'introduction', $period_reference = '')
|
||||||
{
|
{
|
||||||
|
|
||||||
global $db, $conf, $mysoc;
|
global $db, $conf, $mysoc;
|
||||||
@ -119,7 +122,7 @@ class IntracommReport extends CommonObject
|
|||||||
$enveloppe->addChild('softwareUsed', 'Dolibarr');
|
$enveloppe->addChild('softwareUsed', 'Dolibarr');
|
||||||
$declaration = $enveloppe->addChild('Declaration');
|
$declaration = $enveloppe->addChild('Declaration');
|
||||||
$declaration->addChild('declarationId', $id_declaration);
|
$declaration->addChild('declarationId', $id_declaration);
|
||||||
$declaration->addChild('referencePeriod', $periode_reference);
|
$declaration->addChild('referencePeriod', $period_reference);
|
||||||
if($conf->global->INTRACOMMREPORT_TYPE_ACTEUR === 'PSI') $psiId = $party_id;
|
if($conf->global->INTRACOMMREPORT_TYPE_ACTEUR === 'PSI') $psiId = $party_id;
|
||||||
else $psiId = 'NA';
|
else $psiId = 'NA';
|
||||||
$declaration->addChild('PSIId', $psiId);
|
$declaration->addChild('PSIId', $psiId);
|
||||||
@ -131,7 +134,7 @@ class IntracommReport extends CommonObject
|
|||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
/**************Ajout des lignes de factures**************************/
|
/**************Ajout des lignes de factures**************************/
|
||||||
$res = self::addItemsFact($declaration, $type, $periode_reference);
|
$res = self::addItemsFact($declaration, $type, $period_reference);
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
$this->errors = array_unique($this->errors);
|
$this->errors = array_unique($this->errors);
|
||||||
@ -148,7 +151,7 @@ class IntracommReport extends CommonObject
|
|||||||
$e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><fichier_des></fichier_des>');
|
$e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><fichier_des></fichier_des>');
|
||||||
|
|
||||||
$declaration_des = $e->addChild('declaration_des');
|
$declaration_des = $e->addChild('declaration_des');
|
||||||
$declaration_des->addChild('num_des', self::getNumeroDeclaration($this->numero_declaration));
|
$declaration_des->addChild('num_des', self::getDeclarationNumber($this->numero_declaration));
|
||||||
$declaration_des->addChild('num_tvaFr', $mysoc->tva_intra); // /^FR[a-Z0-9]{2}[0-9]{9}$/ // Doit faire 13 caractères
|
$declaration_des->addChild('num_tvaFr', $mysoc->tva_intra); // /^FR[a-Z0-9]{2}[0-9]{9}$/ // Doit faire 13 caractères
|
||||||
$declaration_des->addChild('mois_des', $period_month);
|
$declaration_des->addChild('mois_des', $period_month);
|
||||||
$declaration_des->addChild('an_des', $period_year);
|
$declaration_des->addChild('an_des', $period_year);
|
||||||
@ -163,14 +166,14 @@ class IntracommReport extends CommonObject
|
|||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addItemsFact(&$declaration, $type, $periode_reference, $exporttype = 'deb')
|
function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb')
|
||||||
{
|
{
|
||||||
|
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
|
||||||
$sql = $this->getSQLFactLines($type, $periode_reference, $exporttype);
|
$sql = $this->getSQLFactLines($type, $period_reference, $exporttype);
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
@ -216,7 +219,7 @@ class IntracommReport extends CommonObject
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSQLFactLines($type, $periode_reference, $exporttype = 'deb')
|
function getSQLFactLines($type, $period_reference, $exporttype = 'deb')
|
||||||
{
|
{
|
||||||
|
|
||||||
global $mysoc, $conf;
|
global $mysoc, $conf;
|
||||||
@ -250,7 +253,7 @@ class IntracommReport extends CommonObject
|
|||||||
AND l.product_type = '.($exporttype == 'des' ? 1 : 0).'
|
AND l.product_type = '.($exporttype == 'des' ? 1 : 0).'
|
||||||
AND f.entity = '.$conf->entity.'
|
AND f.entity = '.$conf->entity.'
|
||||||
AND (s.fk_pays <> '.$mysoc->country_id.' OR s.fk_pays IS NULL)
|
AND (s.fk_pays <> '.$mysoc->country_id.' OR s.fk_pays IS NULL)
|
||||||
AND f.datef BETWEEN "'.$periode_reference.'-01" AND "'.$periode_reference.'-'.date('t').'"';
|
AND f.datef BETWEEN "'.$period_reference.'-01" AND "'.$period_reference.'-'.date('t').'"';
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
@ -327,7 +330,7 @@ class IntracommReport extends CommonObject
|
|||||||
SELECT fk_product
|
SELECT fk_product
|
||||||
FROM '.MAIN_DB_PREFIX.'categorie_product
|
FROM '.MAIN_DB_PREFIX.'categorie_product
|
||||||
WHERE fk_categorie = '.$categ_fraisdeport->id.'
|
WHERE fk_categorie = '.$categ_fraisdeport->id.'
|
||||||
)
|
)
|
||||||
)';
|
)';
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -339,23 +342,38 @@ class IntracommReport extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNextNumeroDeclaration()
|
/**
|
||||||
|
* Return next reference of declaration not already used (or last reference)
|
||||||
|
*
|
||||||
|
* @return string free ref or last ref
|
||||||
|
*/
|
||||||
|
public function getNextDeclarationNumber()
|
||||||
{
|
{
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$resql = $db->query('SELECT MAX(numero_declaration) as max_numero_declaration FROM '.$this->get_table().' WHERE exporttype="'.$this->exporttype.'"');
|
$resql = $db->query('SELECT MAX(numero_declaration) as max_numero_declaration FROM '.$this->get_table().' WHERE exporttype="'.$this->exporttype.'"');
|
||||||
if($resql) $res = $db->fetch_object($resql);
|
if($resql) $res = $db->fetch_object($resql);
|
||||||
|
|
||||||
return ($res->max_numero_declaration + 1);
|
return ($res->max_numero_declaration + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify declaration number. Positive integer of a maximum of 6 characters recommended by the documentation
|
||||||
|
*
|
||||||
|
* @param int $number Number to verify / convert
|
||||||
|
* @return int Number
|
||||||
|
*/
|
||||||
// La doc impose que le numéro soit un entier positif d'un maximum de 6 caractères
|
// La doc impose que le numéro soit un entier positif d'un maximum de 6 caractères
|
||||||
static function getNumeroDeclaration($numero)
|
static function getDeclarationNumber($number)
|
||||||
{
|
{
|
||||||
|
return str_pad($number, 6, 0, STR_PAD_LEFT);
|
||||||
return str_pad($numero, 6, 0, STR_PAD_LEFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate XML file
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
function generateXMLFile()
|
function generateXMLFile()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
||||||
* Copyright (C) 2019 Open-DSI <support@open-dsi.fr>
|
* Copyright (C) 2019-2020 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
|
||||||
@ -297,11 +297,11 @@ if ($resql)
|
|||||||
|
|
||||||
$newcardbutton='';
|
$newcardbutton='';
|
||||||
$rightskey='DEB';
|
$rightskey='DEB';
|
||||||
if($type == IntracommReport::TYPE_DES) $rightskey='DES';
|
if ($type == IntracommReport::TYPE_DES) $rightskey='DES';
|
||||||
if($user->rights->{$rightskey}->creer)
|
if ($user->rights->{$rightskey}->creer)
|
||||||
{
|
{
|
||||||
$label='NewDEB';
|
$label='NewDEB';
|
||||||
if($type == IntracommReport::TYPE_DES) $label='NewDES';
|
if ($type == IntracommReport::TYPE_DES) $label = 'NewDES';
|
||||||
$newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&type='.$type);
|
$newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&type='.$type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ if ($resql)
|
|||||||
|
|
||||||
if ($sall)
|
if ($sall)
|
||||||
{
|
{
|
||||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
|
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,7 @@ if ($resql)
|
|||||||
print $duration_value;
|
print $duration_value;
|
||||||
print (! empty($duration_unit) && isset($dur[$duration_unit]) ? ' '.$langs->trans($dur[$duration_unit]) : '');
|
print (! empty($duration_unit) && isset($dur[$duration_unit]) ? ' '.$langs->trans($dur[$duration_unit]) : '');
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
print $obj->duration;
|
print $obj->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,8 +577,7 @@ if ($resql)
|
|||||||
print "</div>";
|
print "</div>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user