From b1c007aa75b4eba59a583a9783de1f3369f39c08 Mon Sep 17 00:00:00 2001 From: aspangaro <alexandre.spangaro@gmail.com> Date: Fri, 9 Dec 2016 06:59:24 +0100 Subject: [PATCH] VAT payment card - Uniformize presentation --- htdocs/compta/tva/card.php | 14 +++--- htdocs/compta/tva/class/tva.class.php | 48 ++++++++++++++++++++ htdocs/compta/tva/info.php | 64 +++++++++++++++++++++++++++ htdocs/core/lib/vat.lib.php | 57 ++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 8 deletions(-) create mode 100644 htdocs/compta/tva/info.php create mode 100644 htdocs/core/lib/vat.lib.php diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 17bcd80757c..01581f7e626 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -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); @@ -305,11 +307,7 @@ if ($action == 'create') 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'); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index eb4ee3a2408..3c45ec77a89 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -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); + } + } + } diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php new file mode 100644 index 00000000000..f85ab9fc2b0 --- /dev/null +++ b/htdocs/compta/tva/info.php @@ -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(); diff --git a/htdocs/core/lib/vat.lib.php b/htdocs/core/lib/vat.lib.php new file mode 100644 index 00000000000..9355bb1056e --- /dev/null +++ b/htdocs/core/lib/vat.lib.php @@ -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; +} -- GitLab