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 '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.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.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
$langs->load("compta"); $langs->load("compta");
$langs->load("banks"); $langs->load("banks");
@ -38,11 +39,11 @@ if (empty($refund)) $refund=0;
$lttype=GETPOST('localTaxType', 'int'); $lttype=GETPOST('localTaxType', 'int');
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges'); $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 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('localtaxvatcard','globalcard')); $hookmanager->initHooks(array('localtaxvatcard','globalcard'));
@ -52,8 +53,8 @@ $hookmanager->initHooks(array('localtaxvatcard','globalcard'));
* Actions * Actions
*/ */
//add payment of localtax if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id)
if($_POST["cancel"] == $langs->trans("Cancel")){ {
header("Location: list.php?localTaxType=".$lttype); header("Location: list.php?localTaxType=".$lttype);
exit; 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"]); $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
$localtax->accountid=GETPOST("accountid"); $object->accountid=GETPOST("accountid");
$localtax->paymenttype=GETPOST("paiementtype"); $object->paymenttype=GETPOST("paiementtype");
$localtax->datev=$datev; $object->datev=$datev;
$localtax->datep=$datep; $object->datep=$datep;
$localtax->amount=price2num(GETPOST("amount")); $object->amount=price2num(GETPOST("amount"));
$localtax->label=GETPOST("label"); $object->label=GETPOST("label");
$localtax->ltt=$lttype; $object->ltt=$lttype;
$ret=$localtax->addPayment($user); $ret=$object->addPayment($user);
if ($ret > 0) if ($ret > 0)
{ {
$db->commit(); $db->commit();
@ -84,7 +85,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
else else
{ {
$db->rollback(); $db->rollback();
setEventMessages($localtax->error, $localtax->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$_GET["action"]="create"; $_GET["action"]="create";
} }
} }
@ -92,39 +93,39 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
//delete payment of localtax //delete payment of localtax
if ($action == 'delete') if ($action == 'delete')
{ {
$result=$localtax->fetch($id); $result=$object->fetch($id);
if ($localtax->rappro == 0) if ($object->rappro == 0)
{ {
$db->begin(); $db->begin();
$ret=$localtax->delete($user); $ret=$object->delete($user);
if ($ret > 0) if ($ret > 0)
{ {
if ($localtax->fk_bank) if ($object->fk_bank)
{ {
$accountline=new AccountLine($db); $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) $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) if ($result >= 0)
{ {
$db->commit(); $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; exit;
} }
else else
{ {
$localtax->error=$accountline->error; $object->error=$accountline->error;
$db->rollback(); $db->rollback();
setEventMessages($localtax->error, $localtax->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
{ {
$db->rollback(); $db->rollback();
setEventMessages($localtax->error, $localtax->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
@ -136,17 +137,12 @@ if ($action == 'delete')
/* /*
* View * View
*/ */
llxHeader();
$form = new Form($db);
if ($id) if ($id)
{ {
$vatpayment = new Localtax($db); $result = $object->fetch($id);
$result = $vatpayment->fetch($id);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db); 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') if ($action == 'create')
{ {
@ -173,7 +176,7 @@ if ($action == 'create')
print $form->select_date($datep,"datep",'','','','add',1,1); print $form->select_date($datep,"datep",'','','','add',1,1);
print '</td></tr>'; 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 $form->select_date($datev,"datev",'','','','add',1,1);
print '</td></tr>'; print '</td></tr>';
@ -218,47 +221,48 @@ if ($action == 'create')
} }
/* ************************************************************************** */ // View mode
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
if ($id) if ($id)
{ {
$h = 0; $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][1] = $langs->trans('Card');
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $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 '<table class="border" width="100%">';
print "<tr>"; print "<tr>";
print '<td width="25%">'.$langs->trans("Ref").'</td><td>'; print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $vatpayment->ref; print $object->ref;
print '</td></tr>'; print '</td></tr>';
print "<tr>"; print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td>'; 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 '</td></tr>';
print '<tr><td>'.$langs->trans("DateValue").'</td><td>'; print '<tr><td>'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print dol_print_date($vatpayment->datev,'day'); print dol_print_date($object->datev,'day');
print '</td></tr>'; 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 (! empty($conf->banque->enabled))
{ {
if ($vatpayment->fk_account > 0) if ($object->fk_account > 0)
{ {
$bankline=new AccountLine($db); $bankline=new AccountLine($db);
$bankline->fetch($vatpayment->fk_bank); $bankline->fetch($object->fk_bank);
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>'; print '<td>'.$langs->trans('BankTransactionLine').'</td>';
@ -271,22 +275,28 @@ if ($id)
// Other attributes // Other attributes
$parameters=array(); $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 $hookmanager->resPrint;
print '</table>'; print '</table>';
dol_fiche_end(); print '</div>';
dol_fiche_end();
/* /*
* Boutons d'actions * Action buttons
*/ */
print "<div class=\"tabsAction\">\n"; print "<div class=\"tabsAction\">\n";
if ($vatpayment->rappro == 0) if ($object->rappro == 0)
print '<a class="butActionDelete" href="card.php?id='.$vatpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>'; {
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
}
else else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
}
print "</div>"; print "</div>";
} }

View File

@ -29,7 +29,11 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/ */
class Localtax extends CommonObject 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 $tms;
var $datep; var $datep;
var $datev; var $datev;
@ -607,4 +611,29 @@ class Localtax extends CommonObject
return $result; 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 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 * View
*/ */
$form = new Form($db);
$title=$langs->trans("VAT") . " - " . $langs->trans("Card"); $title=$langs->trans("VAT") . " - " . $langs->trans("Card");
$help_url=''; $help_url='';
llxHeader("",$title,$helpurl); llxHeader("",$title,$helpurl);
$form = new Form($db);
if ($id) if ($id)
{ {

View File

@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/ */
class Tva extends CommonObject class Tva extends CommonObject
{ {
//public $element='tva'; //!< Id that identify managed objects public $element='tva'; //!< Id that identify managed objects
//public $table_element='tva'; //!< Name of table without prefix where object is stored public $table_element='tva'; //!< Name of table without prefix where object is stored
public $picto='payment'; public $picto='payment';
var $tms; var $tms;
@ -48,8 +48,6 @@ class Tva extends CommonObject
var $fk_user_creat; var $fk_user_creat;
var $fk_user_modif; var $fk_user_modif;
/** /**
* Constructor * Constructor
* *
@ -58,8 +56,6 @@ class Tva extends CommonObject
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->element = 'tva';
$this->table_element = 'tva';
} }