Merge remote-tracking branch 'upstream/develop' into 9.0_accountancy

This commit is contained in:
Alexandre SPANGARO 2018-10-22 06:33:34 +02:00
commit 3f79580b19
11 changed files with 86 additions and 51 deletions

View File

@ -344,7 +344,7 @@ if ($action == 'delmouvconfirm') {
}
}
// Export into a file with format defined into setup
// Export into a file with format defined into setup (FEC, CSV, ...)
if ($action == 'export_file') {
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
@ -357,7 +357,9 @@ if ($action == 'export_file') {
{
$accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines);
if (!empty($accountancyexport->errors)) {
if (!empty($accountancyexport->errors))
{
setEventMessages('', $accountancyexport->errors, 'errors');
}
exit;

View File

@ -206,7 +206,7 @@ class AccountancyExport
/**
* Function who chose which export to use with the default config
* Function who chose which export to use with the default config, and make the export into a file
*
* @param array $TData data
* @return void
@ -214,16 +214,16 @@ class AccountancyExport
public function export(&$TData)
{
global $conf, $langs;
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
// Define name of file to save
$filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV);
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) {
case self::$EXPORT_TYPE_NORMAL :
/*$this->exportNormal($TData);
break;*/
case self::$EXPORT_TYPE_CONFIGURABLE :
$this->exportConfigurable($TData);
break;
@ -261,32 +261,6 @@ class AccountancyExport
}
}
/**
* Export format : Normal
*
* @param array $objectLines data
*
* @return void
*/
/* Use $EXPORT_TYPE_CONFIGURABLE instead
public function exportNormal($objectLines)
{
global $conf;
foreach ( $objectLines as $line ) {
// Std export
$date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
print $date . $this->separator;
print $line->doc_ref . $this->separator;
print length_accountg($line->numero_compte) . $this->separator;
print length_accounta($line->subledger_account) . $this->separator;
print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator;
print $line->code_journal . $this->separator;
print $this->end_line;
}
}
*/
/**
* Export format : CEGID

View File

@ -1003,8 +1003,7 @@ class BookKeeping extends CommonObject
}
}
}
$sql.= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')';
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
}

View File

@ -37,7 +37,26 @@ header('Content-Type: text/csv');
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11") // Specific filename for FEC model export
{
$completefilename = $siren . "FEC" . $search_date_end . $endaccountingperiod . "." . $format;
// FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle
if (empty($search_date_end))
{
// TODO Get the max date into bookeeping table
$search_date_end = dol_now();
}
$datetouseforfilename = $search_date_end;
$tmparray=dol_getdate($datetouseforfilename);
$fiscalmonth=empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START;
// Define end of month to use
if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon']=$fiscalmonth;
else {
$tmparray['mon'] = $fiscalmonth;
$tmparray['year']++;
}
$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
$completefilename = $siren . "FEC" . $endaccountingperiod . "." . $format;
}
else
{

View File

@ -468,16 +468,17 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
{
//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
$newselecteddir = $val['fullrelativename'];
$newfullpathselecteddir='';
if ($modulepart == 'ecm')
{
$newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
}
if ($modulepart == 'medias')
elseif ($modulepart == 'medias')
{
$newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
}
treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
}
print "</li>\n";

View File

@ -40,7 +40,7 @@ class box_contracts extends ModeleBoxes
* @var DoliDB Database handler.
*/
public $db;
var $param;
var $info_box_head = array();
@ -83,7 +83,7 @@ class box_contracts extends ModeleBoxes
$contractstatic=new Contrat($db);
$thirdpartytmp=new Societe($db);
$sql = "SELECT s.nom as name, s.rowid as socid,";
$sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -108,6 +108,7 @@ class box_contracts extends ModeleBoxes
while ($line < $num)
{
$objp = $db->fetch_object($resql);
$datec=$db->jdate($objp->datec);
$dateterm=$db->jdate($objp->fin_validite);
$dateclose=$db->jdate($objp->date_cloture);
@ -120,6 +121,13 @@ class box_contracts extends ModeleBoxes
$thirdpartytmp->name = $objp->name;
$thirdpartytmp->id = $objp->socid;
$thirdpartytmp->email = $objp->email;
$thirdpartytmp->client = $objp->client;
$thirdpartytmp->fournisseur = $objp->fournisseur;
$thirdpartytmp->code_client = $objp->code_client;
$thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
$thirdpartytmp->code_compta = $objp->code_compta;
$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
// fin_validite is no more on contract but on services
// if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }

View File

@ -41,7 +41,7 @@ class box_services_contracts extends ModeleBoxes
* @var DoliDB Database handler.
*/
public $db;
var $param;
var $info_box_head = array();
@ -88,8 +88,8 @@ class box_services_contracts extends ModeleBoxes
$thirdpartytmp = new Societe($db);
$productstatic = new Product($db);
$sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " c.rowid, c.ref, c.statut as contract_status,";
$sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,";
$sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s";
@ -127,9 +127,18 @@ class box_services_contracts extends ModeleBoxes
$contractstatic->statut=$objp->contract_status;
$contractstatic->id=$objp->rowid;
$contractstatic->ref=$objp->ref;
$contractstatic->ref_customer=$objp->ref_customer;
$contractstatic->ref_supplier=$objp->ref_supplier;
$thirdpartytmp->name = $objp->name;
$thirdpartytmp->id = $objp->socid;
$thirdpartytmp->email = $objp->email;
$thirdpartytmp->client = $objp->client;
$thirdpartytmp->fournisseur = $objp->fournisseur;
$thirdpartytmp->code_client = $objp->code_client;
$thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
$thirdpartytmp->code_compta = $objp->code_compta;
$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on

View File

@ -39,7 +39,7 @@ class box_services_expired extends ModeleBoxes
* @var DoliDB Database handler.
*/
public $db;
var $param;
var $info_box_head = array();
@ -84,7 +84,7 @@ class box_services_expired extends ModeleBoxes
// Select contracts with at least one expired service
$sql = "SELECT ";
$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,";
$sql.= " s.nom as name, s.rowid as socid,";
$sql.= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -113,8 +113,15 @@ class box_services_expired extends ModeleBoxes
$objp = $db->fetch_object($resql);
$thirdpartytmp->id = $objp->socid;
$thirdpartytmp->name = $objp->name;
$thirdpartytmp->id = $objp->socid;
$thirdpartytmp->email = $objp->email;
$thirdpartytmp->client = $objp->client;
$thirdpartytmp->fournisseur = $objp->fournisseur;
$thirdpartytmp->code_client = $objp->code_client;
$thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
$thirdpartytmp->code_compta = $objp->code_compta;
$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
$contract->id = $objp->rowid;
$contract->ref = $objp->ref;

View File

@ -126,7 +126,7 @@ class Menubase
$this->perms=trim($this->perms);
$this->enabled=trim($this->enabled);
$this->user=trim($this->user);
$this->position=trim($this->position);
if (empty($this->position)) $this->position=0;
if (! $this->level) $this->level=0;
// Check parameters

View File

@ -1,4 +1,4 @@
<<?php
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -1071,10 +1071,26 @@ class Societe extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
unset($this->country_code); // We clean this because it may have been changed after an update of country_id
unset($this->country);
unset($this->state_code);
unset($this->state);
if (is_object($this->oldcopy)) // If we have information on old values
{
if ($this->oldcopy->country_id != $this->country_id)
{
unset($this->country_code);
unset($this->country);
}
if ($this->oldcopy->state_id != $this->state_id)
{
unset($this->state_code);
unset($this->state);
}
}
else
{
unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id
unset($this->country);
unset($this->state_code);
unset($this->state);
}
$nbrowsaffected = $this->db->affected_rows($resql);