Some correct

This commit is contained in:
Alexandre SPANGARO 2020-07-06 04:19:50 +02:00
parent 7107354f81
commit 725ef1057d
6 changed files with 47 additions and 119 deletions

View File

@ -66,7 +66,7 @@ class modIntracommreport extends DolibarrModules
$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->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");
// Constants

View File

@ -1,6 +1,6 @@
<?php
/* 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
* 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');
// Parameters ACCOUNTING_* and others
// Parameters INTRACOMMREPORT_* and others
$list_DEB = array (
'INTRACOMMREPORT_NUM_AGREMENT',
);

View File

@ -1,6 +1,6 @@
<?php
/* 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
* it under the terms of the GNU General Public License as published by

View File

@ -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;
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/* 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
* 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
*
* @var int
*/
public $ismultientitymanaged = 1;
@ -54,6 +53,7 @@ class IntracommReport extends CommonObject
* DEB - Product
*/
const TYPE_DEB = 0;
/**
* 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)
* @param $type introduction ou expedition
* Generate XML file
*
* @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;
@ -119,7 +122,7 @@ class IntracommReport extends CommonObject
$enveloppe->addChild('softwareUsed', 'Dolibarr');
$declaration = $enveloppe->addChild('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;
else $psiId = 'NA';
$declaration->addChild('PSIId', $psiId);
@ -131,7 +134,7 @@ class IntracommReport extends CommonObject
/********************************************************************/
/**************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);
@ -148,7 +151,7 @@ class IntracommReport extends CommonObject
$e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><fichier_des></fichier_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('mois_des', $period_month);
$declaration_des->addChild('an_des', $period_year);
@ -163,14 +166,14 @@ class IntracommReport extends CommonObject
else return 0;
}
function addItemsFact(&$declaration, $type, $periode_reference, $exporttype = 'deb')
function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb')
{
global $db, $conf;
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);
@ -216,7 +219,7 @@ class IntracommReport extends CommonObject
return 1;
}
function getSQLFactLines($type, $periode_reference, $exporttype = 'deb')
function getSQLFactLines($type, $period_reference, $exporttype = 'deb')
{
global $mysoc, $conf;
@ -250,7 +253,7 @@ class IntracommReport extends CommonObject
AND l.product_type = '.($exporttype == 'des' ? 1 : 0).'
AND f.entity = '.$conf->entity.'
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;
}
@ -327,7 +330,7 @@ class IntracommReport extends CommonObject
SELECT fk_product
FROM '.MAIN_DB_PREFIX.'categorie_product
WHERE fk_categorie = '.$categ_fraisdeport->id.'
)
)
)';
$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;
$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);
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
static function getNumeroDeclaration($numero)
static function getDeclarationNumber($number)
{
return str_pad($numero, 6, 0, STR_PAD_LEFT);
return str_pad($number, 6, 0, STR_PAD_LEFT);
}
/**
* Generate XML file
*
* @return void
*/
function generateXMLFile()
{

View File

@ -1,6 +1,6 @@
<?php
/* 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
* it under the terms of the GNU General Public License as published by
@ -297,11 +297,11 @@ if ($resql)
$newcardbutton='';
$rightskey='DEB';
if($type == IntracommReport::TYPE_DES) $rightskey='DES';
if($user->rights->{$rightskey}->creer)
if ($type == IntracommReport::TYPE_DES) $rightskey='DES';
if ($user->rights->{$rightskey}->creer)
{
$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&amp;type='.$type);
}
@ -326,7 +326,7 @@ if ($resql)
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>';
}
@ -539,8 +539,7 @@ if ($resql)
print $duration_value;
print (! empty($duration_unit) && isset($dur[$duration_unit]) ? ' '.$langs->trans($dur[$duration_unit]) : '');
}
else
{
else {
print $obj->duration;
}
@ -578,8 +577,7 @@ if ($resql)
print "</div>";
print '</form>';
}
else
{
else {
dol_print_error($db);
}