Fix: Doxygen

This commit is contained in:
Laurent Destailleur 2014-09-02 20:00:10 +02:00
parent 229cbc2342
commit df70450073
8 changed files with 352 additions and 341 deletions

View File

@ -1,5 +1,5 @@
<?PHP <?PHP
/* /*
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
@ -34,7 +34,7 @@ if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php"); $res = @include ("../../../main.inc.php");
if (! $res) if (! $res)
die("Include of main fails"); die("Include of main fails");
// Class // Class
dol_include_once("/core/lib/report.lib.php"); dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php"); dol_include_once("/core/lib/date.lib.php");
@ -73,13 +73,13 @@ $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
/* /*
* view * view
*/ */
print '<br><br>'; print '<br><br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<td align="left">' . $langs->trans("Ref") . '</td>'; print '<td align="left">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("Label") . '</td>'; print '<td align="left">' . $langs->trans("Label") . '</td>';
@ -88,13 +88,13 @@ if ($resql) {
print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>'; print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>'; print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>'; print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
$var = True; $var = True;
while ( $i < min($num, 250) ) { while ( $i < min($num, 250) ) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var = ! $var; $var = ! $var;
$compta_prodsell = $obj->accountancy_code_sell; $compta_prodsell = $obj->accountancy_code_sell;
if (empty($compta_prodsell)) { if (empty($compta_prodsell)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
@ -102,7 +102,7 @@ if ($resql) {
else else
$compta_prodsell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
} }
$compta_prodbuy = $obj->accountancy_code_buy; $compta_prodbuy = $obj->accountancy_code_buy;
if (empty($compta_prodbuy)) { if (empty($compta_prodbuy)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
@ -110,12 +110,12 @@ if ($resql) {
else else
$compta_prodbuy = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
} }
$product_static = new Product($db); $product_static = new Product($db);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
// Ref produit // Ref produit
$product_static->ref = $objp->p . ref; $product_static->ref = $objp->ref;
$product_static->id = $objp->rowid; $product_static->id = $objp->rowid;
$product_static->type = $objp->type; $product_static->type = $objp->type;
print '<td>'; print '<td>';
@ -127,13 +127,13 @@ if ($resql) {
print '<td align="left">' . $obj->ref . '</td>'; print '<td align="left">' . $obj->ref . '</td>';
print '<td align="left">' . $obj->label . '</td>'; print '<td align="left">' . $obj->label . '</td>';
print '<td align="left">' . $obj->description . '</td>'; print '<td align="left">' . $obj->description . '</td>';
print '<td align="left">' . $obj->accountancy_code_buy . '</td>'; print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
print '<td align="left">' . $compta_prodbuy . '</td>'; print '<td align="left">' . $compta_prodbuy . '</td>';
print '<td align="left">' . $obj->accountancy_code_sell . '</td>'; print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
print '<td align="left">' . $compta_prodsell . '</td>'; print '<td align="left">' . $compta_prodsell . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i ++;
} }

View File

@ -24,10 +24,10 @@
*/ */
/** /**
* \class AccountancySystem * Class to manage accountancy systems
* \brief Classe to manage accountancy systems
*/ */
class AccountancySystem { class AccountancySystem
{
var $db; var $db;
var $error; var $error;
var $rowid; var $rowid;
@ -37,7 +37,7 @@ class AccountancySystem {
var $label; var $label;
var $account_number; var $account_number;
var $account_parent; var $account_parent;
/** /**
* Constructor * Constructor
* *
@ -46,7 +46,7 @@ class AccountancySystem {
function __construct($db) { function __construct($db) {
$this->db = $db; $this->db = $db;
} }
/** /**
* Insert accountancy system name into database * Insert accountancy system name into database
* *
@ -55,16 +55,16 @@ class AccountancySystem {
*/ */
function create($user) { function create($user) {
$now = dol_now(); $now = dol_now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
$sql .= " (date_creation, fk_user_author, numero,intitule)"; $sql .= " (date_creation, fk_user_author, numero,intitule)";
$sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->intitule . "')"; $sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->intitule . "')";
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system");
if ($id > 0) { if ($id > 0) {
$this->id = $id; $this->id = $id;
$result = $this->id; $result = $this->id;
@ -78,7 +78,7 @@ class AccountancySystem {
$this->error = "AccountancySystem::Create Erreur $result"; $this->error = "AccountancySystem::Create Erreur $result";
dol_syslog($this->error, LOG_ERR); dol_syslog($this->error, LOG_ERR);
} }
return $result; return $result;
} }
} }

View File

@ -24,10 +24,10 @@
*/ */
/** /**
* \class AccountingAccount * Classe permettant la gestion des comptes generaux de compta
* \brief Classe permettant la gestion des comptes generaux de compta
*/ */
class AccountingAccount { class AccountingAccount
{
var $db; var $db;
var $id; var $id;
var $rowid; var $rowid;
@ -41,7 +41,7 @@ class AccountingAccount {
var $fk_user_author; var $fk_user_author;
var $fk_user_modif; var $fk_user_modif;
var $active; var $active;
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB handler acces base de donnees * \param DB handler acces base de donnees
@ -49,11 +49,11 @@ class AccountingAccount {
*/ */
function __construct($db, $rowid = '') { function __construct($db, $rowid = '') {
$this->db = $db; $this->db = $db;
if ($rowid != '') if ($rowid != '')
return $this->fetch($rowid); return $this->fetch($rowid);
} }
/** /**
* \brief Load record in memory * \brief Load record in memory
*/ */
@ -65,7 +65,7 @@ class AccountingAccount {
} elseif ($account_number) { } elseif ($account_number) {
$sql .= " account_number = '" . $account_number . "'"; $sql .= " account_number = '" . $account_number . "'";
} }
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -74,7 +74,7 @@ class AccountingAccount {
return null; return null;
} }
} }
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->rowid = $obj->rowid; $this->rowid = $obj->rowid;
$this->datec = $obj->datec; $this->datec = $obj->datec;
@ -88,10 +88,10 @@ class AccountingAccount {
$this->fk_user_author = $obj->fk_user_author; $this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif; $this->fk_user_modif = $obj->fk_user_modif;
$this->active = $obj->active; $this->active = $obj->active;
return $obj->rowid; return $obj->rowid;
} }
/** /**
* \brief insert line in accountingaccount * \brief insert line in accountingaccount
* \param user utilisateur qui effectue l'insertion * \param user utilisateur qui effectue l'insertion
@ -99,7 +99,7 @@ class AccountingAccount {
function create($user, $notrigger = 0) { function create($user, $notrigger = 0) {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->fk_pcg_version)) if (isset($this->fk_pcg_version))
$this->fk_pcg_version = trim($this->fk_pcg_version); $this->fk_pcg_version = trim($this->fk_pcg_version);
@ -117,13 +117,13 @@ class AccountingAccount {
$this->fk_user_author = trim($this->fk_user_author); $this->fk_user_author = trim($this->fk_user_author);
if (isset($this->active)) if (isset($this->active))
$this->active = trim($this->active); $this->active = trim($this->active);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accountingaccount("; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accountingaccount(";
$sql .= "datec"; $sql .= "datec";
$sql .= ", entity"; $sql .= ", entity";
$sql .= ", fk_pcg_version"; $sql .= ", fk_pcg_version";
@ -134,9 +134,9 @@ class AccountingAccount {
$sql .= ", label"; $sql .= ", label";
$sql .= ", fk_user_author"; $sql .= ", fk_user_author";
$sql .= ", active"; $sql .= ", active";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " '" . $this->db->idate($now) . "'"; $sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity; $sql .= ", " . $conf->entity;
$sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); $sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
@ -147,25 +147,25 @@ class AccountingAccount {
$sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . $user->id; $sql .= ", " . $user->id;
$sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'"); $sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'");
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
$error ++; $error ++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
if (! $error) { if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount");
if (! $notrigger) { if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
// // Call triggers // // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db); // $interface=new Interfaces($this->db);
@ -174,7 +174,7 @@ class AccountingAccount {
// // End call triggers // // End call triggers
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
@ -188,7 +188,7 @@ class AccountingAccount {
return $this->id; return $this->id;
} }
} }
/** /**
* Update record * Update record
* *
@ -197,9 +197,9 @@ class AccountingAccount {
*/ */
function update($user) { function update($user) {
global $langs; global $langs;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
@ -209,9 +209,9 @@ class AccountingAccount {
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
$sql .= " , fk_user_modif = " . $user->id; $sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = '" . $this->active . "'"; $sql .= " , active = '" . $this->active . "'";
$sql .= " WHERE rowid = " . $this->id; $sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -223,7 +223,7 @@ class AccountingAccount {
return - 1; return - 1;
} }
} }
/** /**
* Check usage of accounting code * Check usage of accounting code
* *
@ -232,16 +232,16 @@ class AccountingAccount {
*/ */
function checkUsage() { function checkUsage() {
global $langs; global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
$sql .= "UNION"; $sql .= "UNION";
$sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num > 0) { if ($num > 0) {
@ -255,7 +255,7 @@ class AccountingAccount {
return - 1; return - 1;
} }
} }
/** /**
* Delete object in database * Delete object in database
* *
@ -266,18 +266,18 @@ class AccountingAccount {
function delete($user, $notrigger = 0) { function delete($user, $notrigger = 0) {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$result = $this->checkUsage(); $result = $this->checkUsage();
if ($result > 0) { if ($result > 0) {
$this->db->begin(); $this->db->begin();
if (! $error) { if (! $error) {
if (! $notrigger) { if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
// // Call triggers // // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db); // $interface=new Interfaces($this->db);
@ -286,11 +286,11 @@ class AccountingAccount {
// // End call triggers // // End call triggers
} }
} }
if (! $error) { if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount";
$sql .= " WHERE rowid=" . $this->id; $sql .= " WHERE rowid=" . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql); dol_syslog(get_class($this) . "::delete sql=" . $sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
@ -298,7 +298,7 @@ class AccountingAccount {
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
@ -315,7 +315,7 @@ class AccountingAccount {
return - 1; return - 1;
} }
} }
/** /**
* Information on record * Information on record
* *
@ -326,10 +326,10 @@ class AccountingAccount {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a';
$sql .= ' WHERE a.rowid = ' . $id; $sql .= ' WHERE a.rowid = ' . $id;
dol_syslog(get_class($this) . '::info sql=' . $sql); dol_syslog(get_class($this) . '::info sql=' . $sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
if ($this->db->num_rows($result)) { if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -352,7 +352,7 @@ class AccountingAccount {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
/** /**
* Account desactivate * Account desactivate
* *
@ -361,19 +361,19 @@ class AccountingAccount {
*/ */
function account_desactivate($id) { function account_desactivate($id) {
global $langs; global $langs;
$result = $this->checkUsage(); $result = $this->checkUsage();
if ($result > 0) { if ($result > 0) {
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= "SET active = '0'"; $sql .= "SET active = '0'";
$sql .= " WHERE rowid = ".$this->db->escape($id); $sql .= " WHERE rowid = ".$this->db->escape($id);
dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -386,7 +386,7 @@ class AccountingAccount {
return - 1; return - 1;
} }
} }
/** /**
* Account activate * Account activate
* *
@ -395,13 +395,13 @@ class AccountingAccount {
*/ */
function account_activate($id) { function account_activate($id) {
global $langs; global $langs;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= "SET active = '1'"; $sql .= "SET active = '1'";
$sql .= " WHERE rowid = ".$this->db->escape($id); $sql .= " WHERE rowid = ".$this->db->escape($id);
dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* *
* 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
@ -49,7 +49,7 @@ class BookKeeping
var $piece_num; var $piece_num;
var $linesexport = array (); var $linesexport = array ();
var $linesmvt = array (); var $linesmvt = array ();
/** /**
* Constructor * Constructor
* *
@ -59,7 +59,7 @@ class BookKeeping
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
* Load a line into memory from database * Load a line into memory from database
* *
@ -74,14 +74,14 @@ class BookKeeping
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
$sql .= " WHERE rowid = '" . $id . "'"; $sql .= " WHERE rowid = '" . $id . "'";
dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_date = $this->db->jdate($obj->doc_date);
$this->doc_type = $obj->doc_type; $this->doc_type = $obj->doc_type;
$this->doc_ref = $obj->doc_ref; $this->doc_ref = $obj->doc_ref;
@ -103,10 +103,10 @@ class BookKeeping
dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR);
return - 1; return - 1;
} }
return 1; return 1;
} }
/** /**
* Load an accounting document into memory from database * Load an accounting document into memory from database
* *
@ -118,12 +118,12 @@ class BookKeeping
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$sql .= " WHERE piece_num = '" . $piecenum . "'"; $sql .= " WHERE piece_num = '" . $piecenum . "'";
dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->piece_num = $obj->piece_num; $this->piece_num = $obj->piece_num;
$this->code_journal = $obj->code_journal; $this->code_journal = $obj->code_journal;
$this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_date = $this->db->jdate($obj->doc_date);
@ -134,10 +134,10 @@ class BookKeeping
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
return - 1; return - 1;
} }
return 1; return 1;
} }
/** /**
* Return next number movement * Return next number movement
* *
@ -145,14 +145,14 @@ class BookKeeping
*/ */
function getNextNumMvt() { function getNextNumMvt() {
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->max; return $obj->max;
} }
else else
@ -162,7 +162,7 @@ class BookKeeping
return - 1; return - 1;
} }
} }
/** /**
* Load all informations of accountancy document * Load all informations of accountancy document
* *
@ -177,17 +177,17 @@ class BookKeeping
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
$sql .= " WHERE piece_num = '" . $piecenum . "'"; $sql .= " WHERE piece_num = '" . $piecenum . "'";
dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
while ( $obj = $this->db->fetch_object($result) ) { while ( $obj = $this->db->fetch_object($result) ) {
$line = new BookKeepingLine(); $line = new BookKeepingLine();
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_date = $this->db->jdate($obj->doc_date);
$line->doc_type = $obj->doc_type; $line->doc_type = $obj->doc_type;
$line->doc_ref = $obj->doc_ref; $line->doc_ref = $obj->doc_ref;
@ -202,7 +202,7 @@ class BookKeeping
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num; $line->piece_num = $obj->piece_num;
$this->linesmvt[] = $line; $this->linesmvt[] = $line;
} }
} else { } else {
@ -210,40 +210,43 @@ class BookKeeping
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
return - 1; return - 1;
} }
return 1; return 1;
} }
/** /**
* \brief Insert line into bookkeeping * Insert line into bookkeeping
* \param user User who inserted operation *
* @param User $user User who inserted operation
* @return $result Result
*/ */
function create() { function create($user='')
{
global $conf, $user, $langs; global $conf, $user, $langs;
$this->piece_num = 0; $this->piece_num = 0;
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "SELECT count(*)"; $sql = "SELECT count(*)";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
$sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " WHERE doc_type = '" . $this->doc_type . "'";
$sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND fk_docdet = " . $this->fk_docdet;
$sql .= " AND numero_compte = '" . $this->numero_compte . "'"; $sql .= " AND numero_compte = '" . $this->numero_compte . "'";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$row = $this->db->fetch_array($resql); $row = $this->db->fetch_array($resql);
if ($row[0] == 0) { if ($row[0] == 0) {
// Determine piece_num // Determine piece_num
$sqlnum = "SELECT piece_num"; $sqlnum = "SELECT piece_num";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
if ($resqlnum) if ($resqlnum)
@ -256,7 +259,7 @@ class BookKeeping
{ {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
if ($resqlnum) { if ($resqlnum) {
@ -268,11 +271,11 @@ class BookKeeping
if (empty($this->piece_num)) { if (empty($this->piece_num)) {
$this->piece_num = 1; $this->piece_num = 1;
} }
$now = dol_now(); $now = dol_now();
if (empty($this->date_create)) if (empty($this->date_create))
$this->date_create = $now(); $this->date_create = $now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, "; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, ";
$sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,"; $sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,";
$sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)"; $sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)";
@ -280,12 +283,12 @@ class BookKeeping
$sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',"; $sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',";
$sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '"; $sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '";
$sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")"; $sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping");
if ($id > 0) { if ($id > 0) {
$this->id = $id; $this->id = $id;
$result = 0; $result = 0;
@ -305,27 +308,30 @@ class BookKeeping
$result = - 5; $result = - 5;
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql");
} }
return $result; return $result;
} }
/** /**
* \brief Delete bookkepping by importkey * Delete bookkepping by importkey
*
* @param string $importkey Import key
* @return int Result
*/ */
function delete_by_importkey($importkey) { function delete_by_importkey($importkey) {
$this->db->begin(); $this->db->begin();
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping ";
$sql .= " WHERE import_key = '" . $importkey . "'"; $sql .= " WHERE import_key = '" . $importkey . "'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
$error ++; $error ++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
@ -339,7 +345,7 @@ class BookKeeping
return 1; return 1;
} }
} }
/** /**
* Create object into database * Create object into database
* *
@ -351,7 +357,7 @@ class BookKeeping
{ {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->doc_type)) if (isset($this->doc_type))
$this->doc_type = trim($this->doc_type); $this->doc_type = trim($this->doc_type);
@ -383,10 +389,10 @@ class BookKeeping
$this->code_journal = trim($this->code_journal); $this->code_journal = trim($this->code_journal);
if (isset($this->piece_num)) if (isset($this->piece_num))
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping("; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping(";
$sql .= "doc_date,"; $sql .= "doc_date,";
@ -405,9 +411,9 @@ class BookKeeping
$sql .= "import_key,"; $sql .= "import_key,";
$sql .= "code_journal,"; $sql .= "code_journal,";
$sql .= "piece_num"; $sql .= "piece_num";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ","; $sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ",";
$sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ","; $sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ",";
$sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ","; $sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ",";
@ -424,25 +430,25 @@ class BookKeeping
$sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ","; $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ",";
$sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ","; $sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ",";
$sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . ""; $sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . "";
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
$error ++; $error ++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
if (! $error) { if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping");
if (! $notrigger) { if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
// // Call triggers // // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db); // $interface=new Interfaces($this->db);
@ -451,7 +457,7 @@ class BookKeeping
// // End call triggers // // End call triggers
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
@ -465,7 +471,7 @@ class BookKeeping
return $this->id; return $this->id;
} }
} }
/** /**
* Update object into database * Update object into database
* *
@ -477,7 +483,7 @@ class BookKeeping
{ {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->doc_type)) if (isset($this->doc_type))
$this->doc_type = trim($this->doc_type); $this->doc_type = trim($this->doc_type);
@ -509,13 +515,13 @@ class BookKeeping
$this->code_journal = trim($this->code_journal); $this->code_journal = trim($this->code_journal);
if (isset($this->piece_num)) if (isset($this->piece_num))
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
// Check parameters // Check parameters
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
// Update request // Update request
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET";
$sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ","; $sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ",";
$sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ","; $sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ",";
$sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ","; $sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ",";
@ -532,23 +538,23 @@ class BookKeeping
$sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ","; $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ",";
$sql .= " code_journal=" . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ","; $sql .= " code_journal=" . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ",";
$sql .= " piece_num=" . (isset($this->piece_num) ? $this->piece_num : "null") . ""; $sql .= " piece_num=" . (isset($this->piece_num) ? $this->piece_num : "null") . "";
$sql .= " WHERE rowid=" . $this->id; $sql .= " WHERE rowid=" . $this->id;
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
$error ++; $error ++;
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
if (! $error) { if (! $error) {
if (! $notrigger) { if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
// // Call triggers // // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db); // $interface=new Interfaces($this->db);
@ -557,7 +563,7 @@ class BookKeeping
// // End call triggers // // End call triggers
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
@ -571,7 +577,7 @@ class BookKeeping
return 1; return 1;
} }
} }
/** /**
* Delete object in database * Delete object in database
* *
@ -583,24 +589,24 @@ class BookKeeping
{ {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
if (! $error) if (! $error)
{ {
if (! $notrigger) if (! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
} }
if (! $error) { if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$sql .= " WHERE rowid=" . $this->id; $sql .= " WHERE rowid=" . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql); dol_syslog(get_class($this) . "::delete sql=" . $sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
@ -608,7 +614,7 @@ class BookKeeping
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ( $this->errors as $errmsg ) { foreach ( $this->errors as $errmsg ) {
@ -624,9 +630,12 @@ class BookKeeping
return 1; return 1;
} }
} }
/** /**
* \brief Delete bookkepping by importkey * Delete bookkepping by importkey
*
* @param string $model Model
* @return int Result
*/ */
function export_bookkeping($model = 'ebp') function export_bookkeping($model = 'ebp')
{ {
@ -635,20 +644,20 @@ class BookKeeping
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$this->linesexport = array (); $this->linesexport = array ();
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) { while ( $obj = $this->db->fetch_object($resql) ) {
$line = new BookKeepingLine(); $line = new BookKeepingLine();
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_date = $this->db->jdate($obj->doc_date);
$line->doc_type = $obj->doc_type; $line->doc_type = $obj->doc_type;
$line->doc_ref = $obj->doc_ref; $line->doc_ref = $obj->doc_ref;
@ -663,11 +672,11 @@ class BookKeeping
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num; $line->piece_num = $obj->piece_num;
$this->linesexport[] = $line; $this->linesexport[] = $line;
} }
$this->db->free($resql); $this->db->free($resql);
return $num; return $num;
} }
else else
@ -679,6 +688,9 @@ class BookKeeping
} }
} }
/**
* Class BookKeepingLine
*/
class BookKeepingLine class BookKeepingLine
{ {
var $id; var $id;

View File

@ -19,10 +19,10 @@
/** /**
* \file htdocs/accountancy/class/html.formventilation.class.php * \file htdocs/accountancy/class/html.formventilation.class.php
* \ingroup Accounting Expert * \ingroup Accounting Expert
* \brief File of class with all html predefined components * \brief File of class with all html predefined components
*/ */
/** /**
* Class to manage generation of HTML components for bank module * Class to manage generation of HTML components for bank module
*/ */
@ -30,7 +30,7 @@ class FormVentilation extends Form
{ {
var $db; var $db;
var $error; var $error;
/** /**
* Constructor * Constructor
* *
@ -48,33 +48,33 @@ class FormVentilation extends Form
* @param string $selectedkey Value * @param string $selectedkey Value
* @return string HTML edit field * @return string HTML edit field
*/ */
function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey) function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='')
{ {
global $langs; global $langs;
$date_array = array (); $date_array = array ();
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
$sql .= ' ORDER BY import_key DESC'; $sql .= ' ORDER BY import_key DESC';
$out = '<SELECT name="' . $htmlname . '">'; $out = '<SELECT name="' . $htmlname . '">';
dol_syslog(get_class($this) . "::select_bookkeeping_importkey sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_bookkeeping_importkey sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$i = 0; $i = 0;
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ( $i < $num ) { while ( $i < $num ) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$selected = ''; $selected = '';
if ($selectedkey == $obj->import_key) { if ($selectedkey == $obj->import_key) {
$selected = ' selected="selected" '; $selected = ' selected="selected" ';
} }
$out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . $obj->import_key . '</OPTION>'; $out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . $obj->import_key . '</OPTION>';
$i ++; $i ++;
} }
} else { } else {
@ -82,12 +82,12 @@ class FormVentilation extends Form
dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
return - 1; return - 1;
} }
$out .= '</SELECT>'; $out .= '</SELECT>';
return $out; return $out;
} }
/** /**
* Return list of accounts with label by chart of accounts * Return list of accounts with label by chart of accounts
* *
@ -95,38 +95,38 @@ class FormVentilation extends Form
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
* *
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array())
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$out = ''; $out = '';
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa"; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " ORDER BY aa.account_number"; $sql .= " ORDER BY aa.account_number";
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$out .= ajax_combobox($htmlname, $event); $out .= ajax_combobox($htmlname, $event);
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">'; $out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
if ($showempty) if ($showempty)
$out .= '<option value="-1"></option>'; $out .= '<option value="-1"></option>';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
if ($num) { if ($num) {
while ( $i < $num ) { while ( $i < $num ) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$label = $obj->account_number . ' - ' . $obj->label; $label = $obj->account_number . ' - ' . $obj->label;
// Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number // Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number
// Bacause same account_number can be share between different accounting_system and do have the same meaning // Bacause same account_number can be share between different accounting_system and do have the same meaning
if (($selectid != '') && $selectid == $obj->rowid) { if (($selectid != '') && $selectid == $obj->rowid) {
@ -148,7 +148,7 @@ class FormVentilation extends Form
$this->db->free($resql); $this->db->free($resql);
return $out; return $out;
} }
/** /**
* Return list of accounts with label by class of accounts * Return list of accounts with label by class of accounts
* *
@ -156,25 +156,25 @@ class FormVentilation extends Form
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
* *
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array())
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$out = ''; $out = '';
$sql = "SELECT DISTINCT pcg_type "; $sql = "SELECT DISTINCT pcg_type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= " ORDER BY pcg_type"; $sql .= " ORDER BY pcg_type";
dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$out .= ajax_combobox($htmlname, $event); $out .= ajax_combobox($htmlname, $event);
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">'; $out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
if ($showempty) if ($showempty)
$out .= '<option value="-1"></option>'; $out .= '<option value="-1"></option>';
@ -184,7 +184,7 @@ class FormVentilation extends Form
while ( $i < $num ) { while ( $i < $num ) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$label = $obj->pcg_type; $label = $obj->pcg_type;
if (($selectid != '') && $selectid == $obj->pcg_type) { if (($selectid != '') && $selectid == $obj->pcg_type) {
$out .= '<option value="' . $obj->pcg_type . '" selected="selected">' . $label . '</option>'; $out .= '<option value="' . $obj->pcg_type . '" selected="selected">' . $label . '</option>';
} else { } else {
@ -202,7 +202,7 @@ class FormVentilation extends Form
$this->db->free($resql); $this->db->free($resql);
return $out; return $out;
} }
/** /**
* Return list of accounts with label by sub_class of accounts * Return list of accounts with label by sub_class of accounts
* *
@ -210,25 +210,25 @@ class FormVentilation extends Form
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
* *
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array())
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$out = ''; $out = '';
$sql = "SELECT DISTINCT pcg_subtype "; $sql = "SELECT DISTINCT pcg_subtype ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= " ORDER BY pcg_subtype"; $sql .= " ORDER BY pcg_subtype";
dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$out .= ajax_combobox($htmlname, $event); $out .= ajax_combobox($htmlname, $event);
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">'; $out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
if ($showempty) if ($showempty)
$out .= '<option value="-1"></option>'; $out .= '<option value="-1"></option>';
@ -238,7 +238,7 @@ class FormVentilation extends Form
while ( $i < $num ) { while ( $i < $num ) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$label = $obj->pcg_subtype; $label = $obj->pcg_subtype;
if (($selectid != '') && $selectid == $obj->pcg_subtype) { if (($selectid != '') && $selectid == $obj->pcg_subtype) {
$out .= '<option value="' . $obj->pcg_subtype . '" selected="selected">' . $label . '</option>'; $out .= '<option value="' . $obj->pcg_subtype . '" selected="selected">' . $label . '</option>';
} else { } else {

View File

@ -38,7 +38,7 @@ if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php"); $res = @include ("../../../main.inc.php");
if (! $res) if (! $res)
die("Include of main fails"); die("Include of main fails");
// Class // Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.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/date.lib.php';
@ -78,7 +78,7 @@ if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->access) if (! $user->rights->accounting->access)
accessforbidden(); accessforbidden();
/* /*
* View * View
*/ */
@ -133,28 +133,28 @@ $paymentvatstatic = new TVA($db);
dol_syslog("accountancy/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
// Variables // Variables
$cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); $cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); $cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$tabpay = array (); $tabpay = array ();
$tabbq = array (); $tabbq = array ();
$tabtp = array (); $tabtp = array ();
$tabcompany[$obj->rowid] = array ( $tabcompany[$obj->rowid] = array (
'id' => $obj->socid, 'id' => $obj->socid,
'name' => $obj->name, 'name' => $obj->name,
'code_client' => $obj->code_compta 'code_client' => $obj->code_compta
); );
$tabtype = array (); $tabtype = array ();
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// Controls // Controls
$compta_bank = $obj->account_number; $compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)') if ($obj->label == '(SupplierInvoicePayment)')
@ -163,7 +163,7 @@ if ($result) {
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
if ($obj->typeop == '(BankTransfert)') if ($obj->typeop == '(BankTransfert)')
$compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH; $compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH;
// Variable bookkeeping // Variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
@ -175,11 +175,11 @@ if ($result) {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
} }
$links = $object->get_url($obj->rowid); $links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val ) { foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment') { if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id']; $paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
@ -188,16 +188,16 @@ if ($result) {
$paymentsupplierstatic->ref = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'company') { } else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id']; $societestatic->id = $links[$key]['url_id'];
$societestatic->nom = $links[$key]['label']; $societestatic->nom = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount; $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'sc') { } else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id']; $chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution') if ($reg[1] == 'socialcontribution')
@ -208,14 +208,14 @@ if ($result) {
} }
$chargestatic->ref = $chargestatic->lib; $chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
@ -223,13 +223,13 @@ if ($result) {
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
} }
} else if ($links[$key]['type'] == 'payment_vat') { } else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount; $tabtp[$obj->rowid][$cpttva] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') { } else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount; $tabtp[$obj->rowid][$cpttva] += $obj->amount;
} }
@ -238,9 +238,9 @@ if ($result) {
}*/ }*/
} }
$tabbq[$obj->rowid][$compta_bank] += $obj->amount; $tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
$i ++; $i ++;
} }
} else { } else {
@ -266,14 +266,14 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->intitule; $bookkeeping->label_compte = $compte->intitule;
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0; $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
$bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0); $bookkeeping->credit = ($mt < 0 ? - $mt : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
if ($tabtype[$key] == 'payment') { if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -286,7 +286,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->doc_ref = $objmid->facnumber; $bookkeeping->doc_ref = $objmid->facnumber;
} }
} else if ($tabtype[$key] == 'payment_supplier') { } else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber'; $sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
@ -299,7 +299,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->doc_ref = $objmid->facnumber; $bookkeeping->doc_ref = $objmid->facnumber;
} }
} }
$result = $bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
@ -308,7 +308,7 @@ if ($action == 'writeBookKeeping') {
} }
// Third party // Third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -316,17 +316,17 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->label_compte = $tabcompany[$key]['name']; $bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0); $bookkeeping->debit = ($mt < 0 ? - $mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
if ($tabtype[$key] == 'sc') { if ($tabtype[$key] == 'sc') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') { } else if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -341,7 +341,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $k; $bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') { } else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber'; $sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
@ -356,7 +356,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $k; $bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'company') { } else if ($tabtype[$key] == 'company') {
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -371,11 +371,11 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $k; $bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else { } else {
$bookkeeping->doc_ref = $k; $bookkeeping->doc_ref = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} }
$result = $bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
@ -383,7 +383,7 @@ if ($action == 'writeBookKeeping') {
} }
} }
} }
if (empty($error)) { if (empty($error)) {
setEventMessage($langs->trans('Success'), 'mesgs'); setEventMessage($langs->trans('Success'), 'mesgs');
} }
@ -391,20 +391,20 @@ if ($action == 'writeBookKeeping') {
// export csv // export csv
if ($action == 'export_csv') { if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_SEPARATORCSV;
header('Content-Type: text/csv'); header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_banque.csv'); header('Content-Disposition: attachment;filename=journal_banque.csv');
$companystatic = new Client($db); $companystatic = new Client($db);
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
{ {
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
// Bank // Bank
print $date . $sep; print $date . $sep;
print $conf->global->ACCOUNTING_BANK_JOURNAL . $sep; print $conf->global->ACCOUNTING_BANK_JOURNAL . $sep;
@ -417,7 +417,7 @@ if ($action == 'export_csv') {
print $sep; print $sep;
} }
print "\n"; print "\n";
// Third party // Third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
@ -441,13 +441,13 @@ if ($action == 'export_csv') {
{ {
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day'); $date = dol_print_date($db->jdate($val["date"]), 'day');
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
@ -456,13 +456,13 @@ if ($action == 'export_csv') {
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
} }
print "\n"; print "\n";
// Third party // Third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $companystatic->name . '"' . $sep; print '"' . $companystatic->name . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
@ -473,11 +473,11 @@ if ($action == 'export_csv') {
} }
} }
} else { } else {
$form = new Form($db); $form = new Form($db);
llxHeader('', $langs->trans("BankJournal")); llxHeader('', $langs->trans("BankJournal"));
$nom = $langs->trans("BankJournal"); $nom = $langs->trans("BankJournal");
$nomlink = ''; $nomlink = '';
$periodlink = ''; $periodlink = '';
@ -486,11 +486,11 @@ if ($action == 'export_csv') {
$description = $langs->trans("DescBankJournal") . '<br>'; $description = $langs->trans("DescBankJournal") . '<br>';
$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); $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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />'; print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />'; print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
print ' print '
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
@ -504,12 +504,12 @@ if ($action == 'export_csv') {
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
</script>'; </script>';
/* /*
* Show result array * Show result array
*/ */
print '<br><br>'; print '<br><br>';
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
@ -520,18 +520,18 @@ if ($action == 'export_csv') {
print "<td>" . $langs->trans("PaymentMode") . "</td>"; print "<td>" . $langs->trans("PaymentMode") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
$var = true; $var = true;
$r = ''; $r = '';
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day'); $date = dol_print_date($db->jdate($val["date"]), 'day');
if ($val["lib"] == '(SupplierInvoicePayment)') if ($val["lib"] == '(SupplierInvoicePayment)')
$reflabel = $langs->trans('SupplierInvoicePayment'); $reflabel = $langs->trans('SupplierInvoicePayment');
if ($val["lib"] == '(CustomerInvoicePayment)') if ($val["lib"] == '(CustomerInvoicePayment)')
$reflabel = $langs->trans('CustomerInvoicePayment'); $reflabel = $langs->trans('CustomerInvoicePayment');
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
if (1) { if (1) {
@ -546,7 +546,7 @@ if ($action == 'export_csv') {
print "</tr>"; print "</tr>";
} }
} }
// Third party // Third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') { if ($k != 'type') {
@ -561,12 +561,12 @@ if ($action == 'export_csv') {
print "</tr>"; print "</tr>";
} }
} }
$var = ! $var; $var = ! $var;
} }
print "</table>"; print "</table>";
// End of page // End of page
llxFooter(); llxFooter();
} }

View File

@ -38,7 +38,7 @@ if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php"); $res = @include ("../../../main.inc.php");
if (! $res) if (! $res)
die("Include of main fails"); die("Include of main fails");
// Class // Class
dol_include_once("/core/lib/report.lib.php"); dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php"); dol_include_once("/core/lib/date.lib.php");
@ -127,24 +127,24 @@ $paymentvatstatic = new TVA($db);
dol_syslog("accountancy/journal/cashjournal.php:: sql=" . $sql, LOG_DEBUG); dol_syslog("accountancy/journal/cashjournal.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
// les variables // les variables
$cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); $cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); $cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$tabpay = array (); $tabpay = array ();
$tabbq = array (); $tabbq = array ();
$tabtp = array (); $tabtp = array ();
$tabcompany = array (); $tabcompany = array ();
$tabtype = array (); $tabtype = array ();
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// controls // controls
$compta_bank = $obj->account_number; $compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)') if ($obj->label == '(SupplierInvoicePayment)')
@ -153,9 +153,9 @@ if ($result) {
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
if ($obj->typeop == '(BankTransfert)') if ($obj->typeop == '(BankTransfert)')
$compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH; $compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH;
// variable bookkeeping // variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["ref"] = $obj->label; $tabpay[$obj->rowid]["ref"] = $obj->label;
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
@ -165,11 +165,11 @@ if ($result) {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
} }
$links = $object->get_url($obj->rowid); $links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val ) { foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment') { if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id']; $paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
@ -178,16 +178,16 @@ if ($result) {
$paymentsupplierstatic->ref = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'company') { } else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id']; $societestatic->id = $links[$key]['url_id'];
$societestatic->nom = $links[$key]['label']; $societestatic->nom = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount; $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'sc') { } else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id']; $chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution') if ($reg[1] == 'socialcontribution')
@ -198,7 +198,7 @@ if ($result) {
} }
$chargestatic->ref = $chargestatic->lib; $chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
@ -212,7 +212,7 @@ if ($result) {
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
} }
} else if ($links[$key]['type'] == 'payment_vat') { } else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
@ -226,9 +226,9 @@ if ($result) {
}*/ }*/
} }
$tabbq[$obj->rowid][$compta_bank] += $obj->amount; $tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
$i ++; $i ++;
} }
} else { } else {
@ -254,14 +254,14 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->intitule; $bookkeeping->label_compte = $compte->intitule;
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0; $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
$bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0); $bookkeeping->credit = ($mt < 0 ? - $mt : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL;
if ($tabtype[$key] == 'payment') { if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -274,7 +274,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->doc_ref = $objmid->facnumber; $bookkeeping->doc_ref = $objmid->facnumber;
} }
} else if ($tabtype[$key] == 'payment_supplier') { } else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber'; $sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
@ -287,7 +287,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->doc_ref = $objmid->facnumber; $bookkeeping->doc_ref = $objmid->facnumber;
} }
} }
$result = $bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
@ -296,7 +296,7 @@ if ($action == 'writeBookKeeping') {
} }
// third party // third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -304,17 +304,17 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->label_compte = $tabcompany[$key]['name']; $bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0); $bookkeeping->debit = ($mt < 0 ? - $mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0 ? $mt : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL;
if ($tabtype[$key] == 'sc') { if ($tabtype[$key] == 'sc') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') { } else if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -329,7 +329,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $k; $bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') { } else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber'; $sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
@ -344,7 +344,7 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $k; $bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'company') { } else if ($tabtype[$key] == 'company') {
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -359,11 +359,11 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->code_tiers = $k; $bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else { } else {
$bookkeeping->doc_ref = $k; $bookkeeping->doc_ref = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} }
$result = $bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
@ -371,7 +371,7 @@ if ($action == 'writeBookKeeping') {
} }
} }
} }
if (empty($error)) { if (empty($error)) {
setEventMessage($langs->trans('Success'), 'mesgs'); setEventMessage($langs->trans('Success'), 'mesgs');
} }
@ -379,19 +379,19 @@ if ($action == 'writeBookKeeping') {
// export csv // export csv
if ($action == 'export_csv') { if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_SEPARATORCSV;
header('Content-Type: text/csv'); header('Content-Type: text/csv');
header('Content-Disposition:attachment;filename=journal_caisse.csv'); header('Content-Disposition:attachment;filename=journal_caisse.csv');
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
{ {
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
// Cash // Cash
print $date . $sep; print $date . $sep;
print $conf->global->ACCOUNTING_CASH_JOURNAL . $sep; print $conf->global->ACCOUNTING_CASH_JOURNAL . $sep;
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print length_accountg(html_entity_decode($k)) . $sep; print length_accountg(html_entity_decode($k)) . $sep;
print $sep; print $sep;
@ -401,7 +401,7 @@ if ($action == 'export_csv') {
print utf8_decode($langs->trans("CashPayment")) . $sep; print utf8_decode($langs->trans("CashPayment")) . $sep;
print $val["ref"] . $sep; print $val["ref"] . $sep;
print "\n"; print "\n";
// Third party // Third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
@ -427,7 +427,7 @@ if ($action == 'export_csv') {
$date = dol_print_date($db->jdate($val["date"]), 'day'); $date = dol_print_date($db->jdate($val["date"]), 'day');
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
// Cash // Cash
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
@ -436,7 +436,7 @@ if ($action == 'export_csv') {
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
} }
print "\n"; print "\n";
// Third party // Third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
@ -452,11 +452,11 @@ if ($action == 'export_csv') {
} }
} }
} else { } else {
$form = new Form($db); $form = new Form($db);
llxHeader('', $langs->trans("CashJournal"), ''); llxHeader('', $langs->trans("CashJournal"), '');
$nom = $langs->trans("CashJournal"); $nom = $langs->trans("CashJournal");
$nomlink = ''; $nomlink = '';
$periodlink = ''; $periodlink = '';
@ -465,11 +465,11 @@ if ($action == 'export_csv') {
$description = $langs->trans("DescCashJournal") . '<br>'; $description = $langs->trans("DescCashJournal") . '<br>';
$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); $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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />'; print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />'; print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
print ' print '
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
@ -483,12 +483,12 @@ if ($action == 'export_csv') {
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
</script>'; </script>';
/* /*
* Show result array * Show result array
*/ */
print '<br><br>'; print '<br><br>';
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
@ -497,13 +497,13 @@ if ($action == 'export_csv') {
print "<td>" . $langs->trans("Account") . "</td>"; print "<td>" . $langs->trans("Account") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
$var = true; $var = true;
$r = ''; $r = '';
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day'); $date = dol_print_date($db->jdate($val["date"]), 'day');
// Cash // Cash
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
if (1) { if (1) {
@ -516,26 +516,26 @@ if ($action == 'export_csv') {
print "</tr>"; print "</tr>";
} }
} }
// third party // third party
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') { if ($k != 'type') {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $val["soclib"] . "</td>"; print "<td>" . $val["soclib"] . "</td>";
print "<td>" . length_accounta($k) . "</td>"; print "<td>" . length_accounta($k) . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
} }
} }
$var = ! $var; $var = ! $var;
} }
print "</table>"; print "</table>";
// End of page // End of page
llxFooter(); llxFooter();
} }

View File

@ -35,7 +35,7 @@ $langs->load("accountancy");
// Security check // Security check
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Date range // Date range
$year = GETPOST("year"); $year = GETPOST("year");
if (empty($year)) { if (empty($year)) {
@ -105,9 +105,8 @@ $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) .
$description = $langs->trans("DescThirdPartyReport"); $description = $langs->trans("DescThirdPartyReport");
$builddate = time(); $builddate = time();
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( $moreparam=array('action' => '');
'action' => '' report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam);
));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />'; print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
@ -157,16 +156,16 @@ $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
// export csv // export csv
if (GETPOST('action') == 'export_csv') { if (GETPOST('action') == 'export_csv') {
header('Content-Type: text/csv'); header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=export_csv.csv'); header('Content-Disposition: attachment;filename=export_csv.csv');
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var = ! $var; $var = ! $var;
print '"' . $obj->compta . '",'; print '"' . $obj->compta . '",';
print '"' . $obj->address . '",'; print '"' . $obj->address . '",';
print '"' . $obj->zip . '",'; print '"' . $obj->zip . '",';
@ -177,15 +176,15 @@ if ($resql) {
print "\n"; print "\n";
$i ++; $i ++;
} }
/* /*
* View * View
*/ */
$thirdpartystatic = new Societe($db); $thirdpartystatic = new Societe($db);
print '<br><br>'; print '<br><br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "</table>\n"; print "</table>\n";
print '</td><td valign="top" width="70%" class="notopnoleftnoright"></td>'; print '</td><td valign="top" width="70%" class="notopnoleftnoright"></td>';
@ -201,13 +200,13 @@ if ($resql) {
print '<td align="left">' . $langs->trans("Contact") . '</td>'; print '<td align="left">' . $langs->trans("Contact") . '</td>';
print '<td align="left">' . $langs->trans("Phone") . '</td>'; print '<td align="left">' . $langs->trans("Phone") . '</td>';
print '<td align="left">' . $langs->trans("Fax") . '</td></tr>'; print '<td align="left">' . $langs->trans("Fax") . '</td></tr>';
$var = True; $var = True;
while ( $obj = $db->fetch_object($resql) ) { while ( $obj = $db->fetch_object($resql) ) {
$var = ! $var; $var = ! $var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'; print '<td>';
$thirdpartystatic->id = $obj->rowid; $thirdpartystatic->id = $obj->rowid;
@ -227,10 +226,10 @@ if ($resql) {
print '<td align="left">' . $obj->phone . '</td>'; print '<td align="left">' . $obj->phone . '</td>';
print '<td align="left">' . $obj->fax . '</td>'; print '<td align="left">' . $obj->fax . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i ++;
} }
print "</table>"; print "</table>";
$db->free($resql); $db->free($resql);
} else { } else {