Browse Source

NEW : VAT payment v6 look and feel

Alexandre SPANGARO 8 years ago
parent
commit
e547aa8aee

+ 18 - 15
htdocs/compta/tva/card.php

@@ -2,7 +2,7 @@
 /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2016 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2013 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2015	   Alexandre Spangaro   <aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2015-2017 Alexandre Spangaro   <aspangaro@zendsi.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -305,16 +305,17 @@ if ($id)
 
 	dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');
 
+	$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/reglement.php">'.$langs->trans("BackToList").'</a>';
 
-	print '<table class="border" width="100%">';
+	dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
 
-	print "<tr>";
-	print '<td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
-	print $object->ref;
-	print '</td></tr>';
+	print '<div class="fichecenter">';
+	print '<div class="underbanner clearboth"></div>';
+
+	print '<table class="border" width="100%">';
 
 	// Label
-	print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
+	print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
 
 	print "<tr>";
 	print '<td>'.$langs->trans("DatePayment").'</td><td>';
@@ -335,23 +336,25 @@ if ($id)
 	{
 		if ($object->fk_account > 0)
 		{
- 		   	$bankline=new AccountLine($db);
-    		$bankline->fetch($object->fk_bank);
+			$bankline=new AccountLine($db);
+			$bankline->fetch($object->fk_bank);
 
-	    	print '<tr>';
-	    	print '<td>'.$langs->trans('BankTransactionLine').'</td>';
+			print '<tr>';
+			print '<td>'.$langs->trans('BankTransactionLine').'</td>';
 			print '<td>';
 			print $bankline->getNomUrl(1,0,'showall');
-	    	print '</td>';
-	    	print '</tr>';
+			print '</td>';
+			print '</tr>';
 		}
 	}
 
-        // Other attributes
-        $reshook=$hookmanager->executeHooks('formObjectOptions','',$object,$action);    // Note that $action and $object may have been modified by hook
+	// Other attributes
+	$reshook=$hookmanager->executeHooks('formObjectOptions','',$object,$action);    // Note that $action and $object may have been modified by hook
 
 	print '</table>';
 
+	print '</div>';
+
 	dol_fiche_end();
 
 	/*

+ 63 - 37
htdocs/compta/tva/class/tva.class.php

@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2011-2015 Alexandre Spangaro   <aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2011-2017 Alexandre Spangaro   <aspangaro@zendsi.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ class Tva extends CommonObject
 {
 	//public $element='tva';			//!< Id that identify managed objects
 	//public $table_element='tva';	//!< Name of table without prefix where object is stored
+	public $picto='payment';
 
 	var $tms;
 	var $datep;
@@ -73,6 +74,7 @@ class Tva extends CommonObject
     	global $conf, $langs;
 
 		$error=0;
+		$now=dol_now();
 
 		// Clean parameters
 		$this->amount=trim($this->amount);
@@ -89,7 +91,7 @@ class Tva extends CommonObject
 
 		// Insert request
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
-		$sql.= "tms,";
+		$sql.= "datec,";
 		$sql.= "datep,";
 		$sql.= "datev,";
 		$sql.= "amount,";
@@ -101,7 +103,7 @@ class Tva extends CommonObject
 
         $sql.= ") VALUES (";
 
-		$sql.= " '".$this->db->idate($this->tms)."',";
+		$sql.= " '".$this->db->idate($now)."',";
 		$sql.= " '".$this->db->idate($this->datep)."',";
 		$sql.= " '".$this->db->idate($this->datev)."',";
 		$sql.= " '".$this->amount."',";
@@ -677,46 +679,70 @@ class Tva extends CommonObject
 	 *	@param	int		$id     Id of vat payment
 	 *	@return	int				<0 if KO, >0 if OK
 	 */
-    function info($id)
-    {
-        $sql = "SELECT t.rowid, t.tms as datec, t.fk_user_creat";
-        $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
-        $sql.= " WHERE t.rowid = ".$id;
+	function info($id)
+	{
+		$sql = "SELECT t.rowid, t.tms, t.datec, t.fk_user_creat";
+		$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
+		$sql.= " WHERE t.rowid = ".$id;
 
-        dol_syslog(get_class($this)."::info", LOG_DEBUG);
-        $result=$this->db->query($sql);
-        if ($result)
-        {
-            if ($this->db->num_rows($result))
-            {
-                $obj = $this->db->fetch_object($result);
+		dol_syslog(get_class($this)."::info", LOG_DEBUG);
+		$result=$this->db->query($sql);
+		if ($result)
+		{
+			if ($this->db->num_rows($result))
+			{
+				$obj = $this->db->fetch_object($result);
 
-                $this->id = $obj->rowid;
+				$this->id = $obj->rowid;
 
-                if ($obj->fk_user_creat) {
-                    $cuser = new User($this->db);
-                    $cuser->fetch($obj->fk_user_creat);
-                    $this->user_creation = $cuser;
-                }
+				if ($obj->fk_user_creat) {
+					$cuser = new User($this->db);
+					$cuser->fetch($obj->fk_user_creat);
+					$this->user_creation = $cuser;
+				}
 
-                if ($obj->fk_user_modif) {
-                    $muser = new User($this->db);
-                    $muser->fetch($obj->fk_user_modif);
-                    $this->user_modification = $muser;
-                }
+				if ($obj->fk_user_modif) {
+					$muser = new User($this->db);
+					$muser->fetch($obj->fk_user_modif);
+					$this->user_modification = $muser;
+				}
 
-                $this->date_creation     = $this->db->jdate($obj->datec);
-                $this->date_modification = $this->db->jdate($obj->datec);
-                $this->import_key        = $obj->import_key;
-            }
+				$this->date_creation     = $this->db->jdate($obj->datec);
+				$this->date_modification = $this->db->jdate($obj->tms);
+				$this->import_key        = $obj->import_key;
+			}
 
-            $this->db->free($result);
+			$this->db->free($result);
 
-        }
-        else
-        {
-            dol_print_error($this->db);
-        }
-    }
+		}
+		else
+		{
+			dol_print_error($this->db);
+		}
+	}
+
+	/**
+	 * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
+	 *
+	 * @param	int		$mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+	 * @return  string				Libelle
+	 */
+	function getLibStatut($mode=0)
+	{
+	    return $this->LibStatut($this->statut,$mode);
+	}
+	
+	/**
+	 * Renvoi le libelle d'un statut donne
+	 *
+	 * @param   int		$status     Statut
+	 * @param   int		$mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+	 * @return	string  		    Libelle du statut
+	 */
+	function LibStatut($status,$mode=0)
+	{
+	    global $langs;	// TODO Renvoyer le libelle anglais et faire traduction a affichage
 
+	    return '';
+	}
 }

+ 10 - 1
htdocs/compta/tva/info.php

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

+ 1 - 0
htdocs/install/mysql/migration/5.0.0-6.0.0.sql

@@ -379,3 +379,4 @@ create table llx_loan_schedule
   fk_user_modif		integer           
 )ENGINE=innodb;
 
+ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms;

+ 1 - 0
htdocs/install/mysql/tables/llx_tva.sql

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