Fix look and feel v7

This commit is contained in:
Laurent Destailleur 2018-04-28 18:43:29 +02:00
parent e8fd5ea5cd
commit 2241418b33
4 changed files with 100 additions and 62 deletions

View File

@ -25,6 +25,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.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,11 +39,11 @@ if (empty($refund)) $refund=0;
$lttype=GETPOST('localTaxType', 'int');
// 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');
$localtax = new Localtax($db);
$object = new Localtax($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('localtaxvatcard','globalcard'));
@ -52,8 +53,8 @@ $hookmanager->initHooks(array('localtaxvatcard','globalcard'));
* Actions
*/
//add payment of localtax
if($_POST["cancel"] == $langs->trans("Cancel")){
if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id)
{
header("Location: list.php?localTaxType=".$lttype);
exit;
}
@ -66,15 +67,15 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
$localtax->accountid=GETPOST("accountid");
$localtax->paymenttype=GETPOST("paiementtype");
$localtax->datev=$datev;
$localtax->datep=$datep;
$localtax->amount=price2num(GETPOST("amount"));
$localtax->label=GETPOST("label");
$localtax->ltt=$lttype;
$object->accountid=GETPOST("accountid");
$object->paymenttype=GETPOST("paiementtype");
$object->datev=$datev;
$object->datep=$datep;
$object->amount=price2num(GETPOST("amount"));
$object->label=GETPOST("label");
$object->ltt=$lttype;
$ret=$localtax->addPayment($user);
$ret=$object->addPayment($user);
if ($ret > 0)
{
$db->commit();
@ -84,7 +85,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
else
{
$db->rollback();
setEventMessages($localtax->error, $localtax->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$_GET["action"]="create";
}
}
@ -92,39 +93,39 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
//delete payment of localtax
if ($action == 'delete')
{
$result=$localtax->fetch($id);
$result=$object->fetch($id);
if ($localtax->rappro == 0)
if ($object->rappro == 0)
{
$db->begin();
$ret=$localtax->delete($user);
$ret=$object->delete($user);
if ($ret > 0)
{
if ($localtax->fk_bank)
if ($object->fk_bank)
{
$accountline=new AccountLine($db);
$result=$accountline->fetch($localtax->fk_bank);
$result=$accountline->fetch($object->fk_bank);
if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
}
if ($result >= 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$localtax->ltt);
header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt);
exit;
}
else
{
$localtax->error=$accountline->error;
$object->error=$accountline->error;
$db->rollback();
setEventMessages($localtax->error, $localtax->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
$db->rollback();
setEventMessages($localtax->error, $localtax->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
@ -136,17 +137,12 @@ if ($action == 'delete')
/*
* View
*/
llxHeader();
$form = new Form($db);
* View
*/
if ($id)
{
$vatpayment = new Localtax($db);
$result = $vatpayment->fetch($id);
$result = $object->fetch($id);
if ($result <= 0)
{
dol_print_error($db);
@ -154,6 +150,13 @@ if ($id)
}
}
$form = new Form($db);
$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card");
$help_url='';
llxHeader("",$title,$helpurl);
if ($action == 'create')
{
@ -173,7 +176,7 @@ if ($action == 'create')
print $form->select_date($datep,"datep",'','','','add',1,1);
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateValue").'</td><td>';
print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print $form->select_date($datev,"datev",'','','','add',1,1);
print '</td></tr>';
@ -218,47 +221,48 @@ if ($action == 'create')
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
// View mode
if ($id)
{
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$vatpayment->id;
$head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$object->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');
dol_fiche_head($head, 'card', $langs->transcountry("LT".$object->ltt, $mysoc->country_code), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/localtax/list.php?restore_lastsearch_values=1">'.$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 class="border" width="100%">';
print "<tr>";
print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
print $vatpayment->ref;
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->ref;
print '</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($vatpayment->datep,'day');
print dol_print_date($object->datep,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
print dol_print_date($vatpayment->datev,'day');
print '<tr><td>'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print dol_print_date($object->datev,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($vatpayment->amount).'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
if (! empty($conf->banque->enabled))
{
if ($vatpayment->fk_account > 0)
if ($object->fk_account > 0)
{
$bankline=new AccountLine($db);
$bankline->fetch($vatpayment->fk_bank);
$bankline->fetch($object->fk_bank);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
@ -271,22 +275,28 @@ if ($id)
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>';
dol_fiche_end();
print '</div>';
dol_fiche_end();
/*
* Boutons d'actions
*/
* Action buttons
*/
print "<div class=\"tabsAction\">\n";
if ($vatpayment->rappro == 0)
print '<a class="butActionDelete" href="card.php?id='.$vatpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
if ($object->rappro == 0)
{
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
}
print "</div>";
}

View File

@ -29,7 +29,11 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Localtax extends CommonObject
{
var $ltt;
public $element='localtax'; //!< Id that identify managed objects
public $table_element='localtax'; //!< Name of table without prefix where object is stored
public $picto='payment';
var $ltt;
var $tms;
var $datep;
var $datev;
@ -607,4 +611,29 @@ class Localtax extends CommonObject
return $result;
}
/**
* 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 '';
}
}

View File

@ -172,7 +172,8 @@ if ($action == 'delete')
}
else
{
setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
$mesg='Error try do delete a line linked to a conciliated bank transaction';
setEventMessages($mesg, null, 'errors');
}
}
@ -180,11 +181,13 @@ if ($action == 'delete')
/*
* View
*/
$form = new Form($db);
$title=$langs->trans("VAT") . " - " . $langs->trans("Card");
$help_url='';
llxHeader("",$title,$helpurl);
$form = new Form($db);
if ($id)
{

View File

@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
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 $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;
@ -48,8 +48,6 @@ class Tva extends CommonObject
var $fk_user_creat;
var $fk_user_modif;
/**
* Constructor
*
@ -58,8 +56,6 @@ class Tva extends CommonObject
function __construct($db)
{
$this->db = $db;
$this->element = 'tva';
$this->table_element = 'tva';
}