From dc9d9b47b4c61362138778b7896e28ceefbe3388 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 May 2017 21:35:26 +0200 Subject: [PATCH 1/6] 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 2/6] 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 2281850abfb912282aa9e6b7763fabed2ee31e5f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 5 Jun 2017 14:56:14 +0200 Subject: [PATCH 3/6] Fix label and name --- htdocs/accountancy/journal/bankjournal.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 35d4112ebc9..306fa4d2cab 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -63,7 +63,7 @@ $langs->load('bills'); $langs->load('donations'); $langs->load("accountancy"); $langs->load("trips"); -$langs->load("hrm"); +$langs->load("salaries"); // Old system menu $id_bank_account = GETPOST('id_account', 'int'); @@ -114,7 +114,7 @@ $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 .= " 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 .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; @@ -201,9 +201,8 @@ if ($result) { $tabuser[$obj->rowid] = array ( 'id' => $obj->userid, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'accountancy_code' => $compta_user, + 'name' => $obj->firstname.' '.$obj->lastname, + 'accountancy_code' => $compta_user, ); // Variable bookkeeping @@ -426,7 +425,8 @@ if (! $error && $action == 'writebookkeeping') { $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 + $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } $result = $bookkeeping->create($user); @@ -510,8 +510,9 @@ if (! $error && $action == 'writebookkeeping') { $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 + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; From e547aa8aeea8b02c271fa0efc8794e529747db2c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 5 Jun 2017 15:41:33 +0200 Subject: [PATCH 4/6] NEW : VAT payment v6 look and feel --- htdocs/compta/tva/card.php | 33 +++--- htdocs/compta/tva/class/tva.class.php | 100 +++++++++++------- htdocs/compta/tva/info.php | 11 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 1 + htdocs/install/mysql/tables/llx_tva.sql | 1 + 5 files changed, 93 insertions(+), 53 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index cb80f49e790..e33ec6b3d55 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015-2017 Alexandre Spangaro * * 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 @@ -305,16 +305,17 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + + print '
'; + print '
'; print ''; - print ""; - print ''; - // Label - print ''; + print ''; print ""; print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; + print ''; } } - // Other attributes - $reshook=$hookmanager->executeHooks('formObjectOptions','',$object,$action); // Note that $action and $object may have been modified by hook + // Other attributes + $reshook=$hookmanager->executeHooks('formObjectOptions','',$object,$action); // Note that $action and $object may have been modified by hook print '
'.$langs->trans("Ref").''; - print $object->ref; - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("DatePayment").''; @@ -335,23 +336,25 @@ if ($id) { if ($object->fk_account > 0) { - $bankline=new AccountLine($db); - $bankline->fetch($object->fk_bank); + $bankline=new AccountLine($db); + $bankline->fetch($object->fk_bank); - print '
'.$langs->trans('BankTransactionLine').'
'.$langs->trans('BankTransactionLine').''; print $bankline->getNomUrl(1,0,'showall'); - print '
'; + print '
'; + dol_fiche_end(); /* diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 5cf8b6566bd..045284bd47c 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2011-2015 Alexandre Spangaro + * Copyright (C) 2011-2017 Alexandre Spangaro * * 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,6 +34,7 @@ class Tva extends CommonObject { //public $element='tva'; //!< Id that identify managed objects //public $table_element='tva'; //!< Name of table without prefix where object is stored + public $picto='payment'; var $tms; var $datep; @@ -73,6 +74,7 @@ class Tva extends CommonObject global $conf, $langs; $error=0; + $now=dol_now(); // Clean parameters $this->amount=trim($this->amount); @@ -89,7 +91,7 @@ class Tva extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; - $sql.= "tms,"; + $sql.= "datec,"; $sql.= "datep,"; $sql.= "datev,"; $sql.= "amount,"; @@ -101,7 +103,7 @@ class Tva extends CommonObject $sql.= ") VALUES ("; - $sql.= " '".$this->db->idate($this->tms)."',"; + $sql.= " '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datep)."',"; $sql.= " '".$this->db->idate($this->datev)."',"; $sql.= " '".$this->amount."',"; @@ -677,46 +679,70 @@ class Tva extends CommonObject * @param int $id Id of vat payment * @return int <0 if KO, >0 if OK */ - function info($id) - { - $sql = "SELECT t.rowid, t.tms as datec, t.fk_user_creat"; - $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; - $sql.= " WHERE t.rowid = ".$id; + function info($id) + { + $sql = "SELECT t.rowid, t.tms, t.datec, t.fk_user_creat"; + $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql.= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::info", LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } + if ($obj->fk_user_creat) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_creat); + $this->user_creation = $cuser; + } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + if ($obj->fk_user_modif) { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datec); - $this->import_key = $obj->import_key; - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->tms); + $this->import_key = $obj->import_key; + } - $this->db->free($result); + $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + } + else + { + dol_print_error($this->db); + } + } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + function LibStatut($status,$mode=0) + { + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + + return ''; + } } diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 0c6ce29475a..fb932f0f983 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2016-2017 Alexandre Spangaro * * 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 @@ -53,12 +53,21 @@ $head = vat_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("VATPayment"), 0, 'payment'); +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + +print '
'; +print '
'; + print '
'; dol_print_object_info($object); print '
'; print '
'; +dol_fiche_end(); + llxFooter(); $db->close(); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index d7e68346511..8fd64aa596e 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -379,3 +379,4 @@ create table llx_loan_schedule fk_user_modif integer )ENGINE=innodb; +ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index f33280ff511..9abf63d6ad9 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -21,6 +21,7 @@ create table llx_tva ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, + datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur amount real NOT NULL DEFAULT 0, From 6e83e899e20d2a3728b713fd6eac5a29d610602c Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Tue, 6 Jun 2017 08:29:41 +0200 Subject: [PATCH 5/6] Additionnal filter on getProjectsAuthorizedForUser with great list of projects, have more filter is a good thing --- htdocs/projet/class/project.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6a7b130ac0d..c434fa65381 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1095,9 +1095,10 @@ class Project extends CommonObject * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts * @param int $list 0=Return array,1=Return string list * @param int $socid 0=No filter on third party, id of third party + * @param string $filter additionnal filter on project (statut, ref, ...) * @return array or string Array of projects id, or string with projects id separated with "," */ - function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0) + function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0, $filter='') { $projects = array(); $temp = array(); @@ -1149,6 +1150,8 @@ class Project extends CommonObject { // No filter. Use this if user has permission to see all project } + + $sql.= $filter; //print $sql; $resql = $this->db->query($sql); From 0486a18972e42e3b3b4a8d5fa9cdf69d87d8e606 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Jun 2017 11:07:35 +0200 Subject: [PATCH 6/6] Fix: use dolGetFirstLastname --- htdocs/accountancy/journal/bankjournal.php | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 244331b76dc..cb3afb95f5a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -166,7 +166,7 @@ if ($result) { // one line for bank jounral = tabbq // one line for thirdparty journal = tabtp $i = 0; - while ( $i < $num ) + while ( $i < $num ) { $obj = $db->fetch_object($result); @@ -187,7 +187,7 @@ if ($result) { $tabuser[$obj->rowid] = array ( 'id' => $obj->userid, - 'name' => $obj->firstname.' '.$obj->lastname, + 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'accountancy_code' => $compta_user, @@ -212,7 +212,7 @@ if ($result) { 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 + // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; } @@ -296,7 +296,7 @@ if ($result) { $tabbq[$obj->rowid][$compta_bank] += $obj->amount; - + // Check account number is ok /*if ($action == 'writebookkeeping') // Make test now in such a case { @@ -315,7 +315,7 @@ if ($result) { setEventMessages($langs->trans('ErrorAccountancyCodeOnThirdPartyNotDefined'), null, 'errors'); } }*/ - + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; $i ++; @@ -345,7 +345,7 @@ if (! $error && $action == 'writebookkeeping') { if (! $errorforline) { // Line into bank account - foreach ( $tabbq[$key] as $k => $mt ) + foreach ( $tabbq[$key] as $k => $mt ) { if ($mt) { $bookkeeping = new BookKeeping($db); @@ -363,10 +363,10 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - + if ($tabtype[$key] == 'payment') { $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -380,7 +380,7 @@ if (! $error && $action == 'writebookkeeping') { } } else if ($tabtype[$key] == 'payment_supplier') { $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - + $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -394,7 +394,7 @@ if (! $error && $action == 'writebookkeeping') { } } else if ($tabtype[$key] == 'payment_expensereport') { $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; - + $sqlmid = 'SELECT e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; @@ -456,7 +456,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - + if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; @@ -510,7 +510,7 @@ if (! $error && $action == 'writebookkeeping') { //$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = 'CodeNotDef'; } - + $result = $bookkeeping->create($user); if ($result < 0) { if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists @@ -529,7 +529,7 @@ if (! $error && $action == 'writebookkeeping') { } } } - + if (! $errorforline) { $db->commit(); @@ -551,7 +551,7 @@ if (! $error && $action == 'writebookkeeping') { { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - + $action = ''; } @@ -592,7 +592,7 @@ if ($action == 'export_csv') { if ($reflabel == '(ExpenseReportPayment)') { $reflabel = $langs->trans('Employee'); } - + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; @@ -761,7 +761,7 @@ if (empty($action) || $action == 'view') { print '
'; print ''; print '
'; - + // TODO Avoid using js. We can use a direct link with $param print '