Merge pull request #6096 from aspangaro/5.0-b2

VAT payment card - Uniformize presentation
This commit is contained in:
Laurent Destailleur 2016-12-10 11:44:38 +01:00 committed by GitHub
commit bd1d076753
4 changed files with 175 additions and 8 deletions

View File

@ -27,6 +27,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
$langs->load("compta");
$langs->load("banks");
@ -38,7 +39,7 @@ $refund=GETPOST("refund","int");
if (empty($refund)) $refund=0;
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@ -179,8 +180,9 @@ if ($action == 'delete')
/*
* View
*/
llxHeader();
$title=$langs->trans("VAT") . " - " . $langs->trans("Card");
$help_url='';
llxHeader("",$title,$helpurl);
$form = new Form($db);
@ -299,11 +301,7 @@ if ($action == 'create')
// View mode
if ($id)
{
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
$head=vat_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');

View File

@ -671,4 +671,52 @@ class Tva extends CommonObject
return $result;
}
/**
* Informations of vat payment object
*
* @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;
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;
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;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datec);
$this->import_key = $obj->import_key;
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
}

View File

@ -0,0 +1,64 @@
<?php
/* Copyright (C) 2016 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/tva/info.php
* \ingroup tax
* \brief Page with info about vat
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("compta");
$langs->load("bills");
$id=GETPOST('id','int');
$action=GETPOST("action");
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
/*
* View
*/
$title=$langs->trans("VAT") . " - " . $langs->trans("Info");
$help_url='';
llxHeader("",$title,$helpurl);
$object = new Tva($db);
$object->fetch($id);
$object->info($id);
$head = vat_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("VATPayment"), 0, 'payment');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();

View File

@ -0,0 +1,57 @@
<?php
/* Copyright (C) 2016 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/lib/vat.lib.php
* \ingroup tax
* \brief Library for tax module (VAT)
*/
/**
* Prepare array with list of tabs
*
* @param Object $object Object related to tabs
* @return array Array of tabs to show
*/
function vat_prepare_head($object)
{
global $db, $langs, $conf;
$tab = 0;
$head = array();
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
$head[$tab][1] = $langs->trans('Card');
$head[$tab][2] = 'card';
$tab++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $tab,'vat');
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/info.php?id='.$object->id;
$head[$tab][1] = $langs->trans("Info");
$head[$tab][2] = 'info';
$tab++;
complete_head_from_modules($conf,$langs,$object,$head,$tab,'vat','remove');
return $head;
}