Browse Source

FIX : Various payment

Alexandre SPANGARO 7 years ago
parent
commit
7b935a96bf

+ 4 - 4
htdocs/accountancy/bookkeeping/list.php

@@ -1,8 +1,8 @@
 <?php
-/* Copyright (C) 2013-2016 Olivier Geffroy      <jeff@jeffinfo.com>
- * Copyright (C) 2013-2016 Florian Henry        <florian.henry@open-concept.pro>
- * Copyright (C) 2013-2017 Alexandre Spangaro   <aspangaro@zendsi.com>
- * Copyright (C) 2016-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
+/* Copyright (C) 2013-2016  Olivier Geffroy      <jeff@jeffinfo.com>
+ * Copyright (C) 2013-2016  Florian Henry        <florian.henry@open-concept.pro>
+ * Copyright (C) 2013-2017  Alexandre Spangaro   <aspangaro@zendsi.com>
+ * Copyright (C) 2016-2017  Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * 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

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

@@ -1,9 +1,9 @@
 <?php
-/* Copyright (C) 2013-2014 Olivier Geffroy      <jeff@jeffinfo.com>
- * Copyright (C) 2013-2016 Alexandre Spangaro   <aspangaro@zendsi.com>
- * Copyright (C) 2013-2014 Florian Henry		<florian.henry@open-concept.pro>
- * Copyright (C) 2014 	   Juanjo Menent		<jmenent@2byte.es>
- * Copyright (C) 2015      Ari Elbaz (elarifr)  <github@accedinfo.com>
+/* Copyright (C) 2013-2014  Olivier Geffroy      <jeff@jeffinfo.com>
+ * Copyright (C) 2013-2016  Alexandre Spangaro   <aspangaro@zendsi.com>
+ * Copyright (C) 2013-2014  Florian Henry        <florian.henry@open-concept.pro>
+ * Copyright (C) 2014       Juanjo Menent        <jmenent@2byte.es>
+ * Copyright (C) 2015       Ari Elbaz (elarifr)  <github@accedinfo.com>
  *
  * 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
@@ -20,9 +20,9 @@
  */
 
 /**
- * \file		htdocs/accountancy/class/accountingaccount.class.php
- * \ingroup		Advanced accountancy
- * \brief		File of class to manage accounting accounts
+ *  \file       htdocs/accountancy/class/accountingaccount.class.php
+ *  \ingroup    Advanced accountancy
+ *  \brief      File of class to manage accounting accounts
  */
 
 /**
@@ -152,11 +152,11 @@ class AccountingAccount extends CommonObject
 
 		if (empty($this->pcg_type) || $this->pcg_type == '-1')
 		{
-		    $this->pcg_type = 'XXXXXX';
+			$this->pcg_type = 'XXXXXX';
 		}
 		if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
 		{
-		    $this->pcg_subtype = 'XXXXXX';
+			$this->pcg_subtype = 'XXXXXX';
 		}
 		// Check parameters
 		// Put here code to add control on parameters values
@@ -235,17 +235,17 @@ class AccountingAccount extends CommonObject
 	 */
 	function update($user)
 	{
-	    // Check parameters
-	    if (empty($this->pcg_type) || $this->pcg_type == '-1')
-	    {
-	        $this->pcg_type = 'XXXXXX';
-	    }
-	    if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
-	    {
-	        $this->pcg_subtype = 'XXXXXX';
-	    }
-
-	    $this->db->begin();
+		// Check parameters
+		if (empty($this->pcg_type) || $this->pcg_type == '-1')
+		{
+			$this->pcg_type = 'XXXXXX';
+		}
+		if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
+		{
+			$this->pcg_subtype = 'XXXXXX';
+		}
+
+		$this->db->begin();
 
 		$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
 		$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
@@ -395,17 +395,17 @@ class AccountingAccount extends CommonObject
 		$linkclose='';
 		if (empty($notooltip))
 		{
-		    if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
-		    {
-		        $label=$langs->trans("ShowAccoutingAccount");
-		        $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
-		    }
-		    $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
-		    $linkclose.=' class="classfortooltip"';
+			if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+			{
+				$label=$langs->trans("ShowAccoutingAccount");
+				$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+			}
+			$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
+			$linkclose.=' class="classfortooltip"';
 		}
 
-        $linkstart='<a href="'.$url.'"';
-        $linkstart.=$linkclose.'>';
+		$linkstart='<a href="'.$url.'"';
+		$linkstart.=$linkclose.'>';
 		$linkend='</a>';
 
 		if ($nourl)
@@ -462,10 +462,10 @@ class AccountingAccount extends CommonObject
 	}
 
 	/**
-	 * Account desactivate
+	 * Account deactivated
 	 *
-	 * @param int $id Id
-	 * @return int <0 if KO, >0 if OK
+	 * @param  int  $id         Id
+	 * @return int              <0 if KO, >0 if OK
 	 */
 	function account_desactivate($id) {
 		$result = $this->checkUsage();
@@ -494,10 +494,10 @@ class AccountingAccount extends CommonObject
 	}
 
 	/**
-	 * Account activate
+	 * Account activated
 	 *
-	 * @param int $id Id
-	 * @return int <0 if KO, >0 if OK
+	 * @param  int  $id         Id
+	 * @return int              <0 if KO, >0 if OK
 	 */
 	function account_activate($id) {
 		$this->db->begin();
@@ -522,56 +522,56 @@ class AccountingAccount extends CommonObject
 	/**
 	 *  Retourne le libelle du statut d'un user (actif, inactif)
 	 *
-	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
-	 *  @return	string 			       Label of status
+	 *  @param  int     $mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+	 *  @return string              Label of status
 	 */
 	function getLibStatut($mode=0)
 	{
-	    return $this->LibStatut($this->status,$mode);
+		return $this->LibStatut($this->status,$mode);
 	}
 
 	/**
 	 *  Renvoi le libelle d'un statut donne
 	 *
-	 *  @param	int		$statut        	Id statut
-	 *  @param  int		$mode          	0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
-	 *  @return string 			       	Label of status
+	 *  @param  int     $statut     Id statut
+	 *  @param  int     $mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+	 *  @return string              Label of status
 	 */
 	function LibStatut($statut,$mode=0)
 	{
-	    global $langs;
-	    $langs->load('users');
-
-	    if ($mode == 0)
-	    {
-	        $prefix='';
-	        if ($statut == 1) return $langs->trans('Enabled');
-	        if ($statut == 0) return $langs->trans('Disabled');
-	    }
-	    if ($mode == 1)
-	    {
-	        if ($statut == 1) return $langs->trans('Enabled');
-	        if ($statut == 0) return $langs->trans('Disabled');
-	    }
-	    if ($mode == 2)
-	    {
-	        if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
-	        if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
-	    }
-	    if ($mode == 3)
-	    {
-	        if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4');
-	        if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5');
-	    }
-	    if ($mode == 4)
-	    {
-	        if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
-	        if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
-	    }
-	    if ($mode == 5)
-	    {
-	        if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
-	        if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
-	    }
+		global $langs;
+		$langs->load('users');
+
+		if ($mode == 0)
+		{
+			$prefix='';
+			if ($statut == 1) return $langs->trans('Enabled');
+			if ($statut == 0) return $langs->trans('Disabled');
+		}
+		if ($mode == 1)
+		{
+			if ($statut == 1) return $langs->trans('Enabled');
+			if ($statut == 0) return $langs->trans('Disabled');
+		}
+		if ($mode == 2)
+		{
+			if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+			if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+		}
+		if ($mode == 3)
+		{
+			if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4');
+			if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5');
+		}
+		if ($mode == 4)
+		{
+			if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+			if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+		}
+		if ($mode == 5)
+		{
+			if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
+			if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
+		}
 	}
 }

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

@@ -618,8 +618,8 @@ if (! $error && $action == 'writebookkeeping') {
 			$MAXNBERRORS=5;
 			if ($error >= $MAXNBERRORS)
 			{
-			    setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors');
-			    break;  // Break in the foreach
+				setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors');
+				break;  // Break in the foreach
 			}
 		}
 	}
@@ -1059,59 +1059,59 @@ function getSourceDocRef($val, $typerecord)
 		$sqlmid = 'SELECT payfac.fk_facture as id, f.facnumber as ref';
 		$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f";
 		$sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"];
-        $ref = $langs->trans("Invoice");
+		$ref = $langs->trans("Invoice");
 	}
 	elseif ($typerecord == 'payment_supplier')
 	{
 		$sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref';
 		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f";
 		$sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"];
-        $ref = $langs->trans("SupplierInvoice");
+		$ref = $langs->trans("SupplierInvoice");
 	}
 	elseif ($typerecord == 'payment_expensereport')
 	{
 		$sqlmid = 'SELECT e.rowid as id, e.ref';
 		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e";
 		$sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid";
-        $ref = $langs->trans("ExpenseReport");
+		$ref = $langs->trans("ExpenseReport");
 	}
 	elseif ($typerecord == 'payment_salary')
 	{
 		$sqlmid = 'SELECT s.rowid as ref';
 		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s";
 		$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"];
-        $ref = $langs->trans("SalaryPayment");
+		$ref = $langs->trans("SalaryPayment");
 	}
 	elseif ($typerecord == 'payment_vat')
 	{
 		$sqlmid = 'SELECT v.rowid as ref';
 		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v";
 		$sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"];
-        $ref = $langs->trans("PaymentVat");
+		$ref = $langs->trans("PaymentVat");
 	}
 	elseif ($typerecord == 'payment_donation')
 	{
 		$sqlmid = 'SELECT payd.fk_donation as ref';
 		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd";
 		$sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"];
-        $ref = $langs->trans("Donation").' ';
+		$ref = $langs->trans("Donation").' ';
 	}
 	elseif ($typerecord == 'payment_various')
 	{
 		$sqlmid = 'SELECT v.rowid as ref';
 		$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v";
 		$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"];
-        $ref = $langs->trans("VariousPayment");
+		$ref = $langs->trans("VariousPayment");
 	}
-    dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
-    $resultmid = $db->query($sqlmid);
-    if ($resultmid) {
-        while ($objmid = $db->fetch_object($resultmid))
-        {
-            $ref.=' '.$objmid->ref;
-        }
-    }
-    else dol_print_error($db);
+	dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
+	$resultmid = $db->query($sqlmid);
+	if ($resultmid) {
+		while ($objmid = $db->fetch_object($resultmid))
+		{
+			$ref.=' '.$objmid->ref;
+		}
+	}
+	else dol_print_error($db);
 
 	return $ref;
 }

+ 1 - 1
htdocs/compta/bank/various_payment/card.php

@@ -437,7 +437,7 @@ if ($id)
 	if (! empty($conf->accounting->enabled))
 	{
 		$accountingaccount = new AccountingAccount($db);
-		$accountingaccount->fetch('',$object->accountancy_code);
+		$accountingaccount->fetch('',$object->accountancy_code, 1);
 
 		print $accountingaccount->getNomUrl(0,1,1,'',1);
 	} else {

+ 3 - 3
htdocs/compta/bank/various_payment/index.php

@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C) 2017		Alexandre Spangaro	<aspangaro@zendsi.com>
- * Copyright (C) 2017		Laurent Destailleur <eldy@users.sourceforge.net>
+/* Copyright (C) 2017       Alexandre Spangaro  <aspangaro@zendsi.com>
+ * Copyright (C) 2017       Laurent Destailleur <eldy@users.sourceforge.net>
  *
  * 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
@@ -257,7 +257,7 @@ if ($result)
 		// Accounting account
 		if (! empty($conf->accounting->enabled)) {
 			$accountingaccount = new AccountingAccount($db);
-			$accountingaccount->fetch('',$obj->accountancy_code);
+			$accountingaccount->fetch('', $obj->accountancy_code, 1);
 
 			print '<td>'.$accountingaccount->getNomUrl(0,1,1,'',1).'</td>';
 		}