2005-08-16 22:03:50 +02:00
|
|
|
<?php
|
2007-08-03 00:12:41 +02:00
|
|
|
/* Copyright (C) 2005 Christophe
|
2013-01-14 13:06:08 +01:00
|
|
|
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
2015-01-21 01:06:04 +01:00
|
|
|
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
2015-01-25 01:20:58 +01:00
|
|
|
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
2005-08-16 22:03:50 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-08-16 22:03:50 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-01 01:24:38 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-16 22:03:50 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2011-10-24 14:11:49 +02:00
|
|
|
* \file htdocs/core/boxes/box_comptes.php
|
2009-06-08 21:11:19 +02:00
|
|
|
* \ingroup banque
|
2009-10-29 02:12:53 +01:00
|
|
|
* \brief Module to generate box for bank accounts
|
2009-06-08 21:11:19 +02:00
|
|
|
*/
|
2012-08-23 02:04:35 +02:00
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
|
|
|
|
|
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
2005-08-16 22:03:50 +02:00
|
|
|
|
|
|
|
|
|
2012-01-26 13:49:15 +01:00
|
|
|
/**
|
|
|
|
|
* Class to manage the box to show last users
|
|
|
|
|
*/
|
2012-02-20 09:42:57 +01:00
|
|
|
class box_comptes extends ModeleBoxes
|
|
|
|
|
{
|
2006-06-18 03:34:15 +02:00
|
|
|
var $boxcode="currentaccounts";
|
|
|
|
|
var $boximg="object_bill";
|
2013-01-15 17:06:53 +01:00
|
|
|
var $boxlabel="BoxCurrentAccounts";
|
2009-06-08 21:11:19 +02:00
|
|
|
var $depends = array("banque"); // Box active if module banque active
|
2005-08-16 22:03:50 +02:00
|
|
|
|
2006-06-18 03:34:15 +02:00
|
|
|
var $db;
|
|
|
|
|
var $param;
|
2013-01-16 15:54:07 +01:00
|
|
|
var $enabled = 1;
|
2013-04-23 16:18:26 +02:00
|
|
|
|
2006-06-18 03:34:15 +02:00
|
|
|
var $info_box_head = array();
|
|
|
|
|
var $info_box_contents = array();
|
|
|
|
|
|
2013-04-23 16:18:26 +02:00
|
|
|
|
2006-06-18 03:34:15 +02:00
|
|
|
/**
|
2013-04-23 16:18:26 +02:00
|
|
|
* Constructor
|
2013-04-04 13:58:33 +02:00
|
|
|
*
|
2013-04-23 16:18:26 +02:00
|
|
|
* @param DoliDB $db Database handler
|
|
|
|
|
* @param string $param More parameters
|
2009-06-08 21:11:19 +02:00
|
|
|
*/
|
2013-04-23 16:18:26 +02:00
|
|
|
function __construct($db,$param='')
|
2006-06-18 03:34:15 +02:00
|
|
|
{
|
2013-01-15 17:06:53 +01:00
|
|
|
global $conf, $user;
|
2013-04-23 16:18:26 +02:00
|
|
|
|
2013-01-15 17:06:53 +01:00
|
|
|
$this->db = $db;
|
2013-04-23 16:18:26 +02:00
|
|
|
|
2013-01-14 13:06:08 +01:00
|
|
|
// disable module for such cases
|
|
|
|
|
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
|
|
|
|
if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users
|
2017-06-12 14:09:00 +02:00
|
|
|
|
|
|
|
|
$this->hidden = ! ($user->rights->banque->lire);
|
2006-06-18 03:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-09-11 20:35:38 +02:00
|
|
|
* Load data into info_box_contents array to show array later.
|
|
|
|
|
*
|
2011-11-23 18:28:14 +01:00
|
|
|
* @param int $max Maximum number of records to load
|
|
|
|
|
* @return void
|
2009-06-08 21:11:19 +02:00
|
|
|
*/
|
2006-06-18 03:34:15 +02:00
|
|
|
function loadBox($max=5)
|
|
|
|
|
{
|
2007-07-30 15:17:39 +02:00
|
|
|
global $user, $langs, $db, $conf;
|
2006-06-18 03:34:15 +02:00
|
|
|
|
2008-12-07 16:55:40 +01:00
|
|
|
$this->max=$max;
|
2009-06-08 21:11:19 +02:00
|
|
|
|
2006-06-18 03:34:15 +02:00
|
|
|
$this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts"));
|
|
|
|
|
|
2015-01-21 01:06:04 +01:00
|
|
|
if ($user->rights->banque->lire) {
|
2017-11-25 12:13:03 +01:00
|
|
|
$sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url";
|
|
|
|
|
$sql.= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban";
|
|
|
|
|
$sql.= ", b.domiciliation, b.proprio, b.owner_address";
|
|
|
|
|
$sql.= ", b.account_number, b.currency_code";
|
|
|
|
|
$sql.= ", b.min_allowed, b.min_desired, comment";
|
|
|
|
|
$sql.= ', b.fk_accountancy_journal';
|
|
|
|
|
$sql.= ', aj.code as accountancy_journal';
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b";
|
|
|
|
|
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal';
|
|
|
|
|
$sql.= " WHERE b.entity = ".$conf->entity;
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " AND clos = 0";
|
2014-01-15 17:52:16 +01:00
|
|
|
//$sql.= " AND courant = 1";
|
2007-08-03 00:12:41 +02:00
|
|
|
$sql.= " ORDER BY label";
|
|
|
|
|
$sql.= $db->plimit($max, 0);
|
|
|
|
|
|
2015-01-21 01:06:04 +01:00
|
|
|
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
if ($result) {
|
|
|
|
|
$num = $db->num_rows($result);
|
|
|
|
|
|
2015-02-02 21:09:30 +01:00
|
|
|
$line = 0;
|
2015-01-21 01:06:04 +01:00
|
|
|
$solde_total = array();
|
|
|
|
|
|
|
|
|
|
$account_static = new Account($db);
|
2015-02-02 21:09:30 +01:00
|
|
|
while ($line < $num) {
|
2015-01-21 01:06:04 +01:00
|
|
|
$objp = $db->fetch_object($result);
|
|
|
|
|
|
|
|
|
|
$account_static->id = $objp->rowid;
|
2016-12-11 14:01:04 +01:00
|
|
|
$account_static->ref = $objp->ref;
|
2015-01-25 01:20:58 +01:00
|
|
|
$account_static->label = $objp->label;
|
|
|
|
|
$account_static->number = $objp->number;
|
2017-11-25 12:13:03 +01:00
|
|
|
$account_static->account_number = $objp->account_number;
|
|
|
|
|
$account_static->currency_code = $objp->currency_code;
|
|
|
|
|
$account_static->accountancy_journal = $objp->accountancy_journal;
|
2015-01-21 01:06:04 +01:00
|
|
|
$solde=$account_static->solde(0);
|
|
|
|
|
|
|
|
|
|
$solde_total[$objp->currency_code] += $solde;
|
|
|
|
|
|
2015-02-02 21:09:30 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
2017-03-10 11:22:27 +01:00
|
|
|
'td' => '',
|
2015-01-25 01:20:58 +01:00
|
|
|
'text' => $account_static->getNomUrl(1),
|
|
|
|
|
'asis' => 1,
|
2015-01-21 01:06:04 +01:00
|
|
|
);
|
|
|
|
|
|
2015-02-02 21:09:30 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
2017-03-10 11:22:27 +01:00
|
|
|
'td' => '',
|
2015-01-21 01:06:04 +01:00
|
|
|
'text' => $objp->number,
|
|
|
|
|
);
|
|
|
|
|
|
2015-02-02 21:09:30 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
2017-03-10 11:22:27 +01:00
|
|
|
'td' => 'class="right"',
|
2015-01-23 00:55:24 +01:00
|
|
|
'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code)
|
2015-01-21 01:06:04 +01:00
|
|
|
);
|
|
|
|
|
|
2015-02-02 21:09:30 +01:00
|
|
|
$line++;
|
2015-01-21 01:06:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Total
|
|
|
|
|
foreach ($solde_total as $key=>$solde) {
|
2015-02-02 21:09:30 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
2015-01-21 01:06:04 +01:00
|
|
|
'tr' => 'class="liste_total"',
|
|
|
|
|
'td' => 'align="left" class="liste_total"',
|
|
|
|
|
'text' => $langs->trans('Total').' '.$key,
|
|
|
|
|
);
|
2015-02-02 21:09:30 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
2015-01-21 01:06:04 +01:00
|
|
|
'td' => 'align="right" class="liste_total"',
|
|
|
|
|
'text' => ' '
|
|
|
|
|
);
|
2015-01-23 00:55:24 +01:00
|
|
|
|
2015-02-02 21:09:30 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
2015-01-21 01:06:04 +01:00
|
|
|
'td' => 'align="right" class="liste_total"',
|
2015-01-24 15:36:47 +01:00
|
|
|
'text' => price($solde, 0, $langs, 0, -1, -1, $key)
|
2015-01-21 01:06:04 +01:00
|
|
|
);
|
2015-02-02 21:09:30 +01:00
|
|
|
$line++;
|
2015-01-21 01:06:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$db->free($result);
|
|
|
|
|
} else {
|
|
|
|
|
$this->info_box_contents[0][0] = array(
|
2017-03-10 11:22:27 +01:00
|
|
|
'td' => '',
|
2015-01-21 01:06:04 +01:00
|
|
|
'maxlength'=>500,
|
|
|
|
|
'text' => ($db->error().' sql='.$sql),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->info_box_contents[0][0] = array(
|
2017-06-10 00:05:47 +02:00
|
|
|
'td' => 'align="left" class="nohover opacitymedium"',
|
|
|
|
|
'text' => $langs->trans("ReadPermissionNotAllowed")
|
2015-01-21 01:06:04 +01:00
|
|
|
);
|
|
|
|
|
}
|
2005-08-16 22:03:50 +02:00
|
|
|
|
2006-06-18 03:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-23 18:28:14 +01:00
|
|
|
/**
|
|
|
|
|
* Method to show box
|
|
|
|
|
*
|
|
|
|
|
* @param array $head Array with properties of box title
|
|
|
|
|
* @param array $contents Array with properties of box lines
|
2016-06-27 13:57:10 +02:00
|
|
|
* @param int $nooutput No print, only return string
|
2017-06-12 14:09:00 +02:00
|
|
|
* @return string
|
2011-11-23 18:28:14 +01:00
|
|
|
*/
|
2016-06-27 13:57:10 +02:00
|
|
|
function showBox($head = null, $contents = null, $nooutput=0)
|
|
|
|
|
{
|
2017-06-12 14:09:00 +02:00
|
|
|
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
|
2006-06-18 03:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
2005-08-16 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
|