From dc9d9b47b4c61362138778b7896e28ceefbe3388 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 May 2017 21:35:26 +0200 Subject: [PATCH 01/13] Fix : Missing language key --- htdocs/langs/en_US/banks.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index d98d2b465d0..3c7f8b338c0 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -66,6 +66,7 @@ RemoveFromRubriqueConfirm=Are you sure you want to remove link between the entry ListBankTransactions=List of bank entries IdTransaction=Transaction ID BankTransactions=Bank entries +BankTransaction=Bank entry ListTransactions=List entries ListTransactionsByCategory=List entries/category TransactionsToConciliate=Entries to reconcile From 9d8374693509f237538c490a29dfb15164430f2c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 1 Jun 2017 04:44:05 +0200 Subject: [PATCH 02/13] Fix : Book entry in general ledger for salaries --- htdocs/accountancy/journal/bankjournal.php | 70 ++++++++++++++-------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b42ef34d663..35d4112ebc9 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -223,7 +223,7 @@ if ($result) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation'))) // So we excluded 'company' here + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here { // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; @@ -294,7 +294,7 @@ if ($result) { $paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); - // $tabtp[$obj->rowid][$account_employee] += $obj->amount; + $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; } else if ($links[$key]['type'] == 'payment_expensereport') { $paymentexpensereportstatic->id = $links[$key]['url_id']; $paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id']; @@ -418,14 +418,17 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } - } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; - $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment - } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; - $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation - } - + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->code_tiers = ''; + $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment + } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->code_tiers = ''; + $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation + } else if ($tabtype[$key] == 'payment_salary') { + $bookkeeping->code_tiers = ''; + $bookkeeping->doc_ref = $langs->trans("PaymentSalary") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment + } + $result = $bookkeeping->create($user); if ($result < 0) { if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists @@ -495,19 +498,23 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - $bookkeeping->numero_compte = $k; - } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat - } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation - } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->code_tiers = ''; - $bookkeeping->numero_compte = $k; + $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->numero_compte = $k; + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat + } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation + } else if ($tabtype[$key] == 'payment_salary') { + $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("PaymentSalary") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment + } else if ($tabtype[$key] == 'banktransfert') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; } else { // FIXME Should be a temporary account ??? $bookkeeping->doc_ref = $k; @@ -740,8 +747,9 @@ if (empty($action) || $action == 'view') { $invoicestatic = new Facture($db); $invoicesupplierstatic = new FactureFournisseur($db); $expensereportstatic = new ExpenseReport($db); - $vatstatic = new Tva($db); + $vatstatic = new Tva($db); $donationstatic = new Don($db); + $salarystatic = new PaymentSalary($db); llxHeader('', $langs->trans("FinanceJournal")); @@ -896,6 +904,20 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } + elseif ($tabtype[$key] == 'payment_salary') + { + $sqlmid = 'SELECT s.rowid as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; + $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $salarystatic->fetch($objmid->id); + $ref=$langs->trans("SalaryPayment").' '.$salarystatic->getNomUrl(1); + } + else dol_print_error($db); + } /*$invoicestatic->id = $key; From 90c1a3848698c6bec7203d7e6e4905fb81ef747a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 3 Jun 2017 07:23:14 +0200 Subject: [PATCH 03/13] Accountancy - Activate multijournal on bank_journal --- htdocs/accountancy/journal/bankjournal.php | 46 +++++++----------- htdocs/core/menus/standard/eldy.lib.php | 48 +++++++++---------- .../mysql/tables/llx_accounting_journal.sql | 6 +-- 3 files changed, 43 insertions(+), 57 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b42ef34d663..3fa7d7a1110 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -65,10 +65,8 @@ $langs->load("accountancy"); $langs->load("trips"); $langs->load("hrm"); -// Old system menu -$id_bank_account = GETPOST('id_account', 'int'); // Multi journal -$code_journal = GETPOST('code_journal', 'alpha'); +$id_journal = GETPOST('id_journal', 'int'); $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); @@ -81,7 +79,7 @@ $action = GETPOST('action','aZ09'); $now = dol_now(); // Security check -if ($user->societe_id > 0 && empty($id_bank_account)) +if ($user->societe_id > 0 && empty($id_journal)) accessforbidden(); @@ -112,7 +110,7 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $p[0]; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; -$sql .= " ba.courant, ba.ref as baref, ba.account_number,"; +$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,"; $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as name, u.firstname as firstname, bu2.type as typeop"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; @@ -121,7 +119,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.row $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; -$sql .= " WHERE ba.rowid=" . $id_bank_account; +$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; $sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; @@ -139,20 +137,8 @@ $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); // Get code of finance journal -$journal = ''; -$bankstatic = new Account($db); -$bankstatic->fetch($id_bank_account); -$bankstatic->rowid; -$bankstatic->number; -$bankstatic->label; -$bankstatic->fk_accountancy_journal; - $accountingjournalstatic = new AccountingJournal($db); -if(! empty($id_bank_account)) { - $accountingjournalstatic->fetch($bankstatic->fk_accountancy_journal); -} else { - $accountingjournalstatic->fetch('',$code_journal); -} +$accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); @@ -194,7 +180,7 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_compta' => $compta_soc, + 'code_compta' => $compta_soc, ); $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); @@ -203,7 +189,7 @@ if ($result) { 'id' => $obj->userid, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, - 'accountancy_code' => $compta_user, + 'accountancy_code' => $compta_user, ); // Variable bookkeeping @@ -220,14 +206,14 @@ if ($result) { // get_url may return -1 which is not traversable if (is_array($links)) { - // Now loop on each link of record in bank. + // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation'))) // So we excluded 'company' here - { - // We save tabtype for a future use, to remember what kind of payment it is - $tabtype[$obj->rowid] = $links[$key]['type']; - } + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation'))) // So we excluded 'company' here + { + // We save tabtype for a future use, to remember what kind of payment it is + $tabtype[$obj->rowid] = $links[$key]['type']; + } if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; @@ -740,18 +726,18 @@ if (empty($action) || $action == 'view') { $invoicestatic = new Facture($db); $invoicesupplierstatic = new FactureFournisseur($db); $expensereportstatic = new ExpenseReport($db); - $vatstatic = new Tva($db); + $vatstatic = new Tva($db); $donationstatic = new Don($db); llxHeader('', $langs->trans("FinanceJournal")); - $nom = $langs->trans("FinanceJournal") . ' - ' . $bankstatic->getNomUrl(1); + $nom = $langs->trans("FinanceJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); $builddate = time(); //$description = $langs->trans("DescFinanceJournal") . '
'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - $varlink = 'id_account=' . $id_bank_account; + $varlink = 'id_journal=' . $id_journal; journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6248f294476..9245a481aff 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1008,7 +1008,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $sql = "SELECT rowid, code, label, nature"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY nature"; + $sql.= " ORDER BY label"; $resql = $db->query($sql); if ($resql) @@ -1018,30 +1018,30 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($numr > 0) { - while ($i < $numr) - { - $objp = $db->fetch_object($resql); + while ($i < $numr) + { + $objp = $db->fetch_object($resql); - $nature=''; - // Must match array $sourceList defined into journals_list.php - if ($objp->nature == 2) $nature="sells"; - if ($objp->nature == 3) $nature="purchases"; - if ($objp->nature == 4) $nature="bank"; - if ($objp->nature == 1) $nature="various"; - if ($objp->nature == 9) $nature="hasnew"; - - // To enable when page exists - if (empty($conf->global->MAIN_FEATURES_LEVEL)) - { - if ($nature == 'various' || $nature == 'hasnew') $nature=''; - } - - if ($nature) - { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&code_journal='.$objp->code,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); - } - $i++; - } + $nature=''; + // Must match array $sourceList defined into journals_list.php + if ($objp->nature == 2) $nature="sells"; + if ($objp->nature == 3) $nature="purchases"; + if ($objp->nature == 4) $nature="bank"; + if ($objp->nature == 1) $nature="various"; + if ($objp->nature == 9) $nature="hasnew"; + + // To enable when page exists + if (empty($conf->global->MAIN_FEATURES_LEVEL)) + { + if ($nature == 'various' || $nature == 'hasnew') $nature=''; + } + + if ($nature) + { + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire); + } + $i++; + } } else { diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql index 348654b56dc..dbd9e4d311b 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql @@ -20,9 +20,9 @@ create table llx_accounting_journal ( rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1, - code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, + code varchar(32) NOT NULL, label varchar(128) NOT NULL, - nature smallint DEFAULT 1 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) + nature smallint DEFAULT 1 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) active smallint DEFAULT 0 )ENGINE=innodb; From 74710827b25622c354fa21516a57ef505e3c06e1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 3 Jun 2017 14:15:34 +0200 Subject: [PATCH 04/13] Fix: avoid warning "Undefined property: stdClass::$AGENDA_DEFAULT_FILTER_TYPE" --- htdocs/core/class/conf.class.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 578ed17049e..edac78e9b30 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2003 Xavier Dutoit * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Jean Heimburger * * This program is free software; you can redistribute it and/or modify @@ -320,7 +320,7 @@ class Conf // For backward compatibility $this->user->dir_output=$rootforuser."/users"; $this->user->dir_temp=$rootforuser."/users/temp"; - + // UserGroup $this->usergroup->dir_output=$rootforuser."/usergroups"; $this->usergroup->dir_temp=$rootforuser."/usergroups/temp"; @@ -386,13 +386,13 @@ class Conf $this->global->MAIN_ACTIVATE_HTML5=1; $this->global->MAIN_MAIL_USE_MULTI_PART=1; - + // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard"; if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum"; if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint'; - + // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask @@ -425,7 +425,7 @@ class Conf $this->currency=$this->global->MAIN_MONNAIE; if (empty($conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure - + // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' @@ -434,7 +434,7 @@ class Conf // MAIN_HTML_TITLE if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly'; - + // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25; $this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT; @@ -461,7 +461,7 @@ class Conf $this->mailing->email_from=$this->email_from; if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_EMAIL_FROM; if (! isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID=1; - + // Format for date (used by default when not found or not searched in lang) $this->format_date_short="%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) $this->format_date_short_java="dd/MM/yyyy"; // Format of day with Java tags @@ -485,7 +485,7 @@ class Conf // Default pdf option if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text - + // Set default value to MAIN_SHOW_LOGO if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1; @@ -500,7 +500,7 @@ class Conf // By default, we open card if one found if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1; - + // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. @@ -568,12 +568,12 @@ class Conf $this->expensereport->payment = new stdClass(); $this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60; } - + if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) { $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; } - + // For modules that want to disable top or left menu if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU; if (! empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu=$this->global->MAIN_HIDE_LEFT_MENU; @@ -581,11 +581,11 @@ class Conf if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT=3; // Save inconsistent option - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO') + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && (! isset($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) { $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } - + // For backward compatibility if (isset($this->product)) $this->produit=$this->product; if (isset($this->facture)) $this->invoice=$this->facture; @@ -633,7 +633,7 @@ class Conf $this->loghandlers[$handler] = $loghandlerinstance; } } - + } } From a0b4f8b004f99065b0451b36ddb09036333e9f1e Mon Sep 17 00:00:00 2001 From: philippe grand Date: Sun, 4 Jun 2017 12:09:54 +0200 Subject: [PATCH 05/13] FIX : bug #6943 --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 346f4ea38dc..ba4383e6f8e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2417,7 +2417,7 @@ else if ($user->rights->societe->supprimer) { - print ''; + print ''; } if ($user->rights->societe->supprimer) From 806d25ae4116f5141a0c2f8f6404ed4b738d4979 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 5 Jun 2017 06:44:53 +0200 Subject: [PATCH 06/13] Activate multi-journal on expensereport journal --- .../journal/expensereportsjournal.php | 311 +++++++++--------- htdocs/core/menus/standard/eldy.lib.php | 1 + htdocs/install/mysql/data/llx_accounting.sql | 1 + .../install/mysql/migration/5.0.0-6.0.0.sql | 1 + .../mysql/tables/llx_accounting_journal.sql | 2 +- 5 files changed, 163 insertions(+), 153 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f67224e3996..9bd9f8b7f42 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * @@ -32,10 +32,11 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -45,6 +46,9 @@ $langs->load("main"); $langs->load("accountancy"); $langs->load("trips"); +// Multi journal +$id_journal = GETPOST('id_journal', 'int'); + $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); $date_startyear = GETPOST('date_startyear'); @@ -64,6 +68,10 @@ $action = GETPOST('action','aZ09'); /* * Actions */ +// Get code of finance journal +$accountingjournalstatic = new AccountingJournal($db); +$accountingjournalstatic->fetch($id_journal); +$journal = $accountingjournalstatic->code; $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; @@ -157,161 +165,159 @@ if ($action == 'writebookkeeping') { { $errorforline = 0; - $db->begin(); - - if (! $errorforline) - { - foreach ( $tabttc[$key] as $k => $mt ) { - if ($mt) { - // get compte id and label - - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'expense_report'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; - $bookkeeping->label_compte = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt <= 0) ? $mt : 0; - $bookkeeping->credit = ($mt > 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - - if (! $errorforline) - { - // Fees - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); - if ($mt) { - // get compte id and label - $accountingaccount = new AccountingAccount($db); - if ($accountingaccount->fetch(null, $k, true)) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'expense_report'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->numero_compte = $k; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - } - - if (! $errorforline) - { - // VAT - // var_dump($tabtva); - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - // get compte id and label - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'expense_report'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; - $bookkeeping->numero_compte = $k; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - + $db->begin(); + if (! $errorforline) { - $db->commit(); + foreach ( $tabttc[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt > 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + + if (! $errorforline) + { + // Fees + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k, true); + if ($mt) { + // get compte id and label + $accountingaccount = new AccountingAccount($db); + if ($accountingaccount->fetch(null, $k, true)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + } + + if (! $errorforline) + { + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + + if (! $errorforline) + { + $db->commit(); } else { - $db->rollback(); + $db->rollback(); } - } if (empty($error) && count($tabpay)) { - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } elseif (count($tabpay) == $error) { - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); } else { - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } $action=''; @@ -328,7 +334,6 @@ $userstatic = new User($db); // Export /*if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -448,7 +453,9 @@ if (empty($action) || $action == 'view') { $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); + $varlink = 'id_journal=' . $id_journal; + + journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { print ''; @@ -456,10 +463,10 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; - print '
'; - + print '
'; + print '