develop_transverse
This commit is contained in:
Regis Houssin 2017-06-06 13:54:33 +02:00
commit bb37c2f980
8 changed files with 169 additions and 102 deletions

View File

@ -63,7 +63,7 @@ $langs->load('bills');
$langs->load('donations'); $langs->load('donations');
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("trips"); $langs->load("trips");
$langs->load("hrm"); $langs->load("salaries");
// Multi journal // Multi journal
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
@ -112,7 +112,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 = "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, ba.fk_accountancy_journal,"; $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 .= " 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 .= " FROM " . MAIN_DB_PREFIX . "bank as b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $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'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
@ -187,6 +187,7 @@ if ($result) {
$tabuser[$obj->rowid] = array ( $tabuser[$obj->rowid] = array (
'id' => $obj->userid, 'id' => $obj->userid,
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'lastname' => $obj->lastname, 'lastname' => $obj->lastname,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'accountancy_code' => $compta_user, 'accountancy_code' => $compta_user,
@ -209,7 +210,7 @@ if ($result) {
// Now loop on each link of record in bank. // Now loop on each link of record in bank.
foreach ( $links as $key => $val ) { 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 // We save tabtype for a future use, to remember what kind of payment it is
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
@ -280,7 +281,7 @@ if ($result) {
$paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label']; $paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); $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') { } else if ($links[$key]['type'] == 'payment_expensereport') {
$paymentexpensereportstatic->id = $links[$key]['url_id']; $paymentexpensereportstatic->id = $links[$key]['url_id'];
$paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id']; $paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id'];
@ -410,6 +411,10 @@ if (! $error && $action == 'writebookkeeping') {
} else if ($tabtype[$key] == 'payment_donation') { } else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -491,6 +496,11 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $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 = $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') { } else if ($tabtype[$key] == 'banktransfert') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
@ -728,6 +738,7 @@ if (empty($action) || $action == 'view') {
$expensereportstatic = new ExpenseReport($db); $expensereportstatic = new ExpenseReport($db);
$vatstatic = new Tva($db); $vatstatic = new Tva($db);
$donationstatic = new Don($db); $donationstatic = new Don($db);
$salarystatic = new PaymentSalary($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
@ -882,6 +893,20 @@ if (empty($action) || $action == 'view') {
} }
else dol_print_error($db); 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; /*$invoicestatic->id = $key;

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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'); dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/reglement.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr>";
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $object->ref;
print '</td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
print "<tr>"; print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td>'; print '<td>'.$langs->trans("DatePayment").'</td><td>';
@ -352,6 +353,8 @@ if ($id)
print '</table>'; print '</table>';
print '</div>';
dol_fiche_end(); dol_fiche_end();
/* /*

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 $element='tva'; //!< Id that identify managed objects
//public $table_element='tva'; //!< Name of table without prefix where object is stored //public $table_element='tva'; //!< Name of table without prefix where object is stored
public $picto='payment';
var $tms; var $tms;
var $datep; var $datep;
@ -73,6 +74,7 @@ class Tva extends CommonObject
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
$now=dol_now();
// Clean parameters // Clean parameters
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
@ -89,7 +91,7 @@ class Tva extends CommonObject
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
$sql.= "tms,"; $sql.= "datec,";
$sql.= "datep,"; $sql.= "datep,";
$sql.= "datev,"; $sql.= "datev,";
$sql.= "amount,"; $sql.= "amount,";
@ -101,7 +103,7 @@ class Tva extends CommonObject
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= " '".$this->db->idate($this->tms)."',"; $sql.= " '".$this->db->idate($now)."',";
$sql.= " '".$this->db->idate($this->datep)."',"; $sql.= " '".$this->db->idate($this->datep)."',";
$sql.= " '".$this->db->idate($this->datev)."',"; $sql.= " '".$this->db->idate($this->datev)."',";
$sql.= " '".$this->amount."',"; $sql.= " '".$this->amount."',";
@ -679,7 +681,7 @@ class Tva extends CommonObject
*/ */
function info($id) function info($id)
{ {
$sql = "SELECT t.rowid, t.tms as datec, t.fk_user_creat"; $sql = "SELECT t.rowid, t.tms, t.datec, t.fk_user_creat";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE t.rowid = ".$id; $sql.= " WHERE t.rowid = ".$id;
@ -706,7 +708,7 @@ class Tva extends CommonObject
} }
$this->date_creation = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms);
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
} }
@ -719,4 +721,28 @@ class Tva extends CommonObject
} }
} }
/**
* 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 '';
}
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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'); dol_fiche_head($head, 'info', $langs->trans("VATPayment"), 0, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/reglement.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($object); dol_print_object_info($object);
print '</td></tr></table>'; print '</td></tr></table>';
print '</div>'; print '</div>';
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -380,6 +380,8 @@ create table llx_loan_schedule
fk_user_modif integer fk_user_modif integer
)ENGINE=innodb; )ENGINE=innodb;
ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms;
ALTER TABLE llx_user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user; ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user;
ALTER TABLE llx_user_rights DROP INDEX uk_user_rights; ALTER TABLE llx_user_rights DROP INDEX uk_user_rights;
@ -393,6 +395,3 @@ ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup;
ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id);
ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);

View File

@ -21,6 +21,7 @@ create table llx_tva
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp, tms timestamp,
datec datetime, -- Create date
datep date, -- date de paiement datep date, -- date de paiement
datev date, -- date de valeur datev date, -- date de valeur
amount real NOT NULL DEFAULT 0, amount real NOT NULL DEFAULT 0,

View File

@ -66,6 +66,7 @@ RemoveFromRubriqueConfirm=Are you sure you want to remove link between the entry
ListBankTransactions=List of bank entries ListBankTransactions=List of bank entries
IdTransaction=Transaction ID IdTransaction=Transaction ID
BankTransactions=Bank entries BankTransactions=Bank entries
BankTransaction=Bank entry
ListTransactions=List entries ListTransactions=List entries
ListTransactionsByCategory=List entries/category ListTransactionsByCategory=List entries/category
TransactionsToConciliate=Entries to reconcile TransactionsToConciliate=Entries to reconcile

View File

@ -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 $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 $list 0=Return array,1=Return string list
* @param int $socid 0=No filter on third party, id of third party * @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 "," * @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(); $projects = array();
$temp = array(); $temp = array();
@ -1149,6 +1150,8 @@ class Project extends CommonObject
{ {
// No filter. Use this if user has permission to see all project // No filter. Use this if user has permission to see all project
} }
$sql.= $filter;
//print $sql; //print $sql;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);