Fix SticklerCi

This commit is contained in:
Alexandre SPANGARO 2020-07-06 04:47:27 +02:00
parent 1855d54019
commit 82c96a4f83
5 changed files with 34 additions and 40 deletions

View File

@ -71,7 +71,7 @@ class Form
// Cache arrays // Cache arrays
public $cache_types_paiements = array(); public $cache_types_paiements = array();
public $cache_conditions_paiements = array(); public $cache_conditions_paiements = array();
public $cache_transport_mode=array(); public $cache_transport_mode = array();
public $cache_availability = array(); public $cache_availability = array();
public $cache_demand_reason = array(); public $cache_demand_reason = array();
public $cache_types_fees = array(); public $cache_types_fees = array();
@ -3608,8 +3608,7 @@ class Form
return $num; return $num;
} }
else else {
{
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
@ -3638,7 +3637,7 @@ class Form
print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">'; print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">';
if ($empty) print '<option value="">&nbsp;</option>'; if ($empty) print '<option value="">&nbsp;</option>';
foreach($this->cache_transport_mode as $id => $arraytypes) foreach ($this->cache_transport_mode as $id => $arraytypes)
{ {
// If not good status // If not good status
if ($active >= 0 && $arraytypes['active'] != $active) continue; if ($active >= 0 && $arraytypes['active'] != $active) continue;
@ -4721,8 +4720,7 @@ class Form
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
} }
else else {
{
if ($selected) if ($selected)
{ {
$this->load_cache_transport_mode(); $this->load_cache_transport_mode();

View File

@ -36,7 +36,7 @@ class modIntracommreport extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $langs; global $conf, $langs;

View File

@ -2661,8 +2661,7 @@ if ($action == 'create')
{ {
$form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1); $form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1);
} }
else else {
{
$form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'none'); $form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'none');
} }
print '</td></tr>'; print '</td></tr>';

View File

@ -53,14 +53,12 @@ if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $co
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
else else {
{
header("Location: list.php"); header("Location: list.php");
exit; exit;
} }
} }
else else {
{
$errmesg=$object->error; $errmesg=$object->error;
} }
} }
@ -100,14 +98,12 @@ if ($action == 'add' && $user->rights->intracommreport->write) {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
else else {
{
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'create'; $action = 'create';
} }
} }
else else {
{
$action = 'create'; $action = 'create';
} }
} }

View File

@ -94,8 +94,9 @@ class IntracommReport extends CommonObject
* @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 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 $type introduction or expedition
* @param string $period_reference Period of reference * @param string $period_reference Period of reference
* @return void
*/ */
function getXML($mode = 'O', $type = 'introduction', $period_reference = '') public function getXML($mode = 'O', $type = 'introduction', $period_reference = '')
{ {
global $db, $conf, $mysoc; global $db, $conf, $mysoc;
@ -123,7 +124,7 @@ class IntracommReport extends CommonObject
$declaration = $enveloppe->addChild('Declaration'); $declaration = $enveloppe->addChild('Declaration');
$declaration->addChild('declarationId', $id_declaration); $declaration->addChild('declarationId', $id_declaration);
$declaration->addChild('referencePeriod', $period_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);
$function = $declaration->addChild('Function'); $function = $declaration->addChild('Function');
@ -139,12 +140,12 @@ class IntracommReport extends CommonObject
$this->errors = array_unique($this->errors); $this->errors = array_unique($this->errors);
if(!empty($res)) return $e->asXML(); if (!empty($res)) return $e->asXML();
else return 0; else return 0;
} }
// $type_declaration tjrs = "expedition" à voir si ça évolue // $type_declaration tjrs = "expedition" à voir si ça évolue
function getXMLDes($period_year, $period_month, $type_declaration = 'expedition') public function getXMLDes($period_year, $period_month, $type_declaration = 'expedition')
{ {
global $db, $conf, $mysoc; global $db, $conf, $mysoc;
@ -162,11 +163,11 @@ class IntracommReport extends CommonObject
$this->errors = array_unique($this->errors); $this->errors = array_unique($this->errors);
if(!empty($res)) return $e->asXML(); if (!empty($res)) return $e->asXML();
else return 0; else return 0;
} }
function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb') public function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb')
{ {
global $db, $conf; global $db, $conf;
@ -177,15 +178,15 @@ class IntracommReport extends CommonObject
$resql = $db->query($sql); $resql = $db->query($sql);
if($resql) { if ($resql) {
$i=1; $i=1;
if(empty($resql->num_rows)) { if (empty($resql->num_rows)) {
$this->errors[] = 'Aucune donnée pour cette période'; $this->errors[] = 'Aucune donnée pour cette période';
return 0; return 0;
} }
if($exporttype == 'deb' && $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT > 0) { if ($exporttype == 'deb' && $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT > 0) {
$categ_fraisdeport = new Categorie($db); $categ_fraisdeport = new Categorie($db);
$categ_fraisdeport->fetch($conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT); $categ_fraisdeport->fetch($conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT);
$TLinesFraisDePort = array(); $TLinesFraisDePort = array();
@ -198,11 +199,11 @@ class IntracommReport extends CommonObject
} }
else else
{ {
if(empty($res->fk_pays)) { if (empty($res->fk_pays)) {
// On n'arrête pas la boucle car on veut savoir quels sont tous les tiers qui n'ont pas de pays renseigné // 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>'; $this->errors[] = 'Pays non renseigné pour le tiers <a href="'.dol_buildpath('/societe/soc.php', 1).'?socid='.$res->id_client.'">'.$res->nom.'</a>';
} else { } else {
if($conf->global->INTRACOMMREPORT_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; $TLinesFraisDePort[] = $res;
} else $this->addItemXMl($declaration, $res, '', $i); } else $this->addItemXMl($declaration, $res, '', $i);
} }
@ -211,20 +212,20 @@ class IntracommReport extends CommonObject
$i++; $i++;
} }
if(!empty($TLinesFraisDePort)) $this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i); if (!empty($TLinesFraisDePort)) $this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i);
if(count($this->errors) > 0) return 0; if (count($this->errors) > 0) return 0;
} }
return 1; return 1;
} }
function getSQLFactLines($type, $period_reference, $exporttype = 'deb') public function getSQLFactLines($type, $period_reference, $exporttype = 'deb')
{ {
global $mysoc, $conf; global $mysoc, $conf;
if($type=='expedition' || $exporttype=='des') { if ($type=='expedition' || $exporttype=='des') {
$sql = 'SELECT f.facnumber, f.total as total_ht'; $sql = 'SELECT f.facnumber, f.total as total_ht';
$table = 'facture'; $table = 'facture';
$table_extraf = 'facture_extrafields'; $table_extraf = 'facture_extrafields';
@ -258,16 +259,16 @@ class IntracommReport extends CommonObject
return $sql; return $sql;
} }
function addItemXMl(&$declaration, &$res, $code_douane_spe = '', $i) public function addItemXMl(&$declaration, &$res, $code_douane_spe = '', $i)
{ {
$item = $declaration->addChild('Item'); $item = $declaration->addChild('Item');
$item->addChild('ItemNumber', $i); $item->addChild('ItemNumber', $i);
$cn8 = $item->addChild('CN8'); $cn8 = $item->addChild('CN8');
if(empty($code_douane_spe)) $code_douane = $res->customcode; if (empty($code_douane_spe)) $code_douane = $res->customcode;
else $code_douane = $code_douane_spe; else $code_douane = $code_douane_spe;
$cn8->addChild('CN8Code', $code_douane); $cn8->addChild('CN8Code', $code_douane);
if(!empty($res->tva_intra)) $item->addChild('partnerId', $res->tva_intra); if (!empty($res->tva_intra)) $item->addChild('partnerId', $res->tva_intra);
$item->addChild('MSConsDestCode', $res->code); // code iso pays client $item->addChild('MSConsDestCode', $res->code); // code iso pays client
$item->addChild('netMass', $res->weight * $res->qty); // Poids du produit $item->addChild('netMass', $res->weight * $res->qty); // Poids du produit
$item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne $item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne
@ -281,7 +282,7 @@ class IntracommReport extends CommonObject
$item->addChild('regionCode', substr($res->zip, 0, 2)); $item->addChild('regionCode', substr($res->zip, 0, 2));
} }
function addItemXMlDes($declaration, &$res, $code_douane_spe = '', $i) public function addItemXMlDes($declaration, &$res, $code_douane_spe = '', $i)
{ {
$item = $declaration->addChild('ligne_des'); $item = $declaration->addChild('ligne_des');
$item->addChild('numlin_des', $i); $item->addChild('numlin_des', $i);
@ -292,12 +293,12 @@ class IntracommReport extends CommonObject
/** /**
* Cette fonction ajoute un item en récupérant le code douane du produit ayant le plus haut montant dans la facture * Cette fonction ajoute un item en récupérant le code douane du produit ayant le plus haut montant dans la facture
*/ */
function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i) public function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i)
{ {
global $db, $conf; global $db, $conf;
if($type=='expedition') { if ($type=='expedition') {
$table = 'facture'; $table = 'facture';
$tabledet = 'facturedet'; $tabledet = 'facturedet';
$field_link = 'fk_facture'; $field_link = 'fk_facture';
@ -310,7 +311,7 @@ class IntracommReport extends CommonObject
$more_sql = 'f.ref_supplier'; $more_sql = 'f.ref_supplier';
} }
foreach($TLinesFraisDePort as $res) { foreach ($TLinesFraisDePort as $res) {
$sql = 'SELECT p.customcode $sql = 'SELECT p.customcode
FROM '.MAIN_DB_PREFIX.$tabledet.' d FROM '.MAIN_DB_PREFIX.$tabledet.' d
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.') INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.')
@ -352,7 +353,7 @@ class IntracommReport extends CommonObject
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);
} }