浏览代码

Fix: Doxygen

Laurent Destailleur 10 年之前
父节点
当前提交
df70450073

+ 15 - 15
htdocs/accountancy/admin/productaccount.php

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

+ 9 - 9
htdocs/accountancy/class/accountancysystem.class.php

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

+ 54 - 54
htdocs/accountancy/class/accountingaccount.class.php

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

+ 96 - 84
htdocs/accountancy/class/bookkeeping.class.php

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

+ 38 - 38
htdocs/accountancy/class/html.formventilation.class.php

@@ -19,10 +19,10 @@
 
 /**
  *	\file		htdocs/accountancy/class/html.formventilation.class.php
- *	\ingroup	Accounting Expert 
+ *	\ingroup	Accounting Expert
  *	\brief		File of class with all html predefined components
  */
- 
+
 /**
  *	Class to manage generation of HTML components for bank module
  */
@@ -30,7 +30,7 @@ class FormVentilation extends Form
 {
 	var $db;
 	var $error;
-	
+
 	/**
      * Constructor
      *
@@ -48,33 +48,33 @@ class FormVentilation extends Form
 	 *	@param	string	$selectedkey	Value
 	 *	@return	string					HTML edit field
 	 */
-	function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey)
+	function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='')
 	{
 		global $langs;
-		
+
 		$date_array = array ();
-		
+
 		$sql  = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
 		$sql .= ' ORDER BY import_key DESC';
-		
+
 		$out = '<SELECT name="' . $htmlname . '">';
-		
+
 		dol_syslog(get_class($this) . "::select_bookkeeping_importkey sql=" . $sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
 			$i = 0;
 			$num = $this->db->num_rows($resql);
-			
+
 			while ( $i < $num ) {
 				$obj = $this->db->fetch_object($resql);
-				
+
 				$selected = '';
 				if ($selectedkey == $obj->import_key) {
 					$selected = ' selected="selected" ';
 				}
-				
+
 				$out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . $obj->import_key . '</OPTION>';
-				
+
 				$i ++;
 			}
 		} else {
@@ -82,12 +82,12 @@ class FormVentilation extends Form
 			dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
 			return - 1;
 		}
-		
+
 		$out .= '</SELECT>';
-		
+
 		return $out;
 	}
-	
+
 	/**
 	 *	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	int		$showempty		Add an empty field
 	 *  @param	array	$event			Event options
-     *       
+     *
 	 *	@return	string					String with HTML select
 	 */
 	function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array())
 	{
 		global $conf, $user, $langs;
-		
+
 		$out = '';
-		
+
 		$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
 		$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 .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
 		$sql .= " AND aa.active = 1";
 		$sql .= " ORDER BY aa.account_number";
-		
+
 		dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
-			
+
 			$out .= ajax_combobox($htmlname, $event);
 			$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
 			if ($showempty)
 				$out .= '<option value="-1"></option>';
 			$num = $this->db->num_rows($resql);
-			
+
 			$i = 0;
 			if ($num) {
 				while ( $i < $num ) {
 					$obj = $this->db->fetch_object($resql);
 					$label = $obj->account_number . ' - ' . $obj->label;
-					
+
 					// 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
 					if (($selectid != '') && $selectid == $obj->rowid) {
@@ -148,7 +148,7 @@ class FormVentilation extends Form
 		$this->db->free($resql);
 		return $out;
 	}
-	
+
 	/**
 	 *	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	int		$showempty		Add an empty field
 	 *  @param	array	$event			Event options
-     *       
+     *
 	 *	@return	string					String with HTML select
 	 */
 	function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array())
 	{
 		global $conf, $user, $langs;
-		
+
 		$out = '';
-		
+
 		$sql = "SELECT DISTINCT pcg_type ";
 		$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount ";
 		$sql .= " ORDER BY pcg_type";
-		
+
 		dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
-			
+
 			$out .= ajax_combobox($htmlname, $event);
-			
+
 			$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
 			if ($showempty)
 				$out .= '<option value="-1"></option>';
@@ -184,7 +184,7 @@ class FormVentilation extends Form
 				while ( $i < $num ) {
 					$obj = $this->db->fetch_object($resql);
 					$label = $obj->pcg_type;
-					
+
 					if (($selectid != '') && $selectid == $obj->pcg_type) {
 						$out .= '<option value="' . $obj->pcg_type . '" selected="selected">' . $label . '</option>';
 					} else {
@@ -202,7 +202,7 @@ class FormVentilation extends Form
 		$this->db->free($resql);
 		return $out;
 	}
-	
+
 	/**
 	 *	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	int		$showempty		Add an empty field
 	 *  @param	array	$event			Event options
-     *       
+     *
 	 *	@return	string					String with HTML select
 	 */
 	function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array())
 	{
 		global $conf, $user, $langs;
-		
+
 		$out = '';
-		
+
 		$sql = "SELECT DISTINCT pcg_subtype ";
 		$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount ";
 		$sql .= " ORDER BY pcg_subtype";
-		
+
 		dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if ($resql) {
-			
+
 			$out .= ajax_combobox($htmlname, $event);
-			
+
 			$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
 			if ($showempty)
 				$out .= '<option value="-1"></option>';
@@ -238,7 +238,7 @@ class FormVentilation extends Form
 				while ( $i < $num ) {
 					$obj = $this->db->fetch_object($resql);
 					$label = $obj->pcg_subtype;
-					
+
 					if (($selectid != '') && $selectid == $obj->pcg_subtype) {
 						$out .= '<option value="' . $obj->pcg_subtype . '" selected="selected">' . $label . '</option>';
 					} else {

+ 64 - 64
htdocs/accountancy/journal/bankjournal.php

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

+ 59 - 59
htdocs/accountancy/journal/cashjournal.php

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

+ 17 - 18
scripts/accountancy/export-thirdpartyaccount.php

@@ -35,7 +35,7 @@ $langs->load("accountancy");
 // Security check
 if (!$user->admin)
     accessforbidden();
-	
+
 // Date range
 $year = GETPOST("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");
 $builddate = time();
 
-report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
-		'action' => '' 
-));
+$moreparam=array('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();" />';
 
@@ -157,16 +156,16 @@ $resql = $db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql);
 	$i = 0;
-	
+
 	// export csv
 	if (GETPOST('action') == 'export_csv') {
-		
+
 		header('Content-Type: text/csv');
 		header('Content-Disposition: attachment;filename=export_csv.csv');
-		
+
 		$obj = $db->fetch_object($resql);
 		$var = ! $var;
-		
+
 		print '"' . $obj->compta . '",';
 		print '"' . $obj->address . '",';
 		print '"' . $obj->zip . '",';
@@ -177,15 +176,15 @@ if ($resql) {
 		print "\n";
 		$i ++;
 	}
-	
+
 	/*
 	 * View
 	 */
-	
+
 	$thirdpartystatic = new Societe($db);
-	
+
 	print '<br><br>';
-	
+
 	print '<table class="noborder" width="100%">';
 	print "</table>\n";
 	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("Phone") . '</td>';
 	print '<td align="left">' . $langs->trans("Fax") . '</td></tr>';
-	
+
 	$var = True;
-	
+
 	while ( $obj = $db->fetch_object($resql) ) {
-		
+
 		$var = ! $var;
-		
+
 		print "<tr $bc[$var]>";
 		print '<td>';
 		$thirdpartystatic->id = $obj->rowid;
@@ -227,10 +226,10 @@ if ($resql) {
 		print '<td align="left">' . $obj->phone . '</td>';
 		print '<td align="left">' . $obj->fax . '</td>';
 		print "</tr>\n";
-		
+
 		$i ++;
 	}
-	
+
 	print "</table>";
 	$db->free($resql);
 } else {