Merge pull request #5707 from aspangaro/5.0-p12

Fix Presentation of fiscal year
This commit is contained in:
Juanjo Menent 2016-09-07 17:06:58 +02:00 committed by GitHub
commit 73865fa14a
4 changed files with 81 additions and 75 deletions

View File

@ -80,8 +80,8 @@ $max = 100;
$form = new Form($db); $form = new Form($db);
$title = $langs->trans('FiscalYears'); $title = $langs->trans('FiscalYears');
$helpurl = "";
llxHeader('', $title, LOG_ERR); llxHeader('', $title, $helpurl);
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f";
@ -94,7 +94,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
} }
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);
@ -102,12 +102,12 @@ $result = $db->query($sql);
if ($result) { if ($result) {
$var = false; $var = false;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$title = $langs->trans('FiscalYears'); $title = $langs->trans('FiscalYears');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1);
// Load attribute_label // Load attribute_label
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -117,10 +117,10 @@ if ($result) {
print '<td>' . $langs->trans("DateEnd") . '</td>'; print '<td>' . $langs->trans("DateEnd") . '</td>';
print '<td align="right">' . $langs->trans("Statut") . '</td>'; print '<td align="right">' . $langs->trans("Statut") . '</td>';
print '</tr>'; print '</tr>';
if ($num) { if ($num) {
$fiscalyearstatic = new Fiscalyear($db); $fiscalyearstatic = new Fiscalyear($db);
while ( $i < $num && $i < $max ) { while ( $i < $num && $i < $max ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$fiscalyearstatic->id = $obj->rowid; $fiscalyearstatic->id = $obj->rowid;
@ -137,7 +137,6 @@ if ($result) {
} else { } else {
print '<tr ' . $bc[$var] . '><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>'; print '<tr ' . $bc[$var] . '><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
} }
print '</table>'; print '</table>';
} else { } else {
dol_print_error($db); dol_print_error($db);

View File

@ -28,7 +28,9 @@ $langs->load("admin");
$langs->load("compta"); $langs->load("compta");
// Security check // Security check
if (! $user->admin) if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear)
accessforbidden(); accessforbidden();
$error = 0; $error = 0;
@ -71,13 +73,13 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
else if ($action == 'add') { else if ($action == 'add') {
if (! GETPOST('cancel', 'alpha')) { if (! GETPOST('cancel', 'alpha')) {
$error = 0; $error = 0;
$object->date_start = $date_start; $object->date_start = $date_start;
$object->date_end = $date_end; $object->date_end = $date_end;
$object->label = GETPOST('label', 'alpha'); $object->label = GETPOST('label', 'alpha');
$object->statut = GETPOST('statut', 'int'); $object->statut = GETPOST('statut', 'int');
$object->datec = dol_now(); $object->datec = dol_now();
if (empty($object->date_start) && empty($object->date_end)) { if (empty($object->date_start) && empty($object->date_end)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error ++; $error ++;
@ -86,20 +88,20 @@ else if ($action == 'add') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$error ++; $error ++;
} }
if (! $error) { if (! $error) {
$db->begin(); $db->begin();
$id = $object->create($user); $id = $object->create($user);
if ($id > 0) { if ($id > 0) {
$db->commit(); $db->commit();
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit(); exit();
} else { } else {
$db->rollback(); $db->rollback();
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'create'; $action = 'create';
} }
@ -116,12 +118,12 @@ else if ($action == 'add') {
else if ($action == 'update') { else if ($action == 'update') {
if (! GETPOST('cancel', 'alpha')) { if (! GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id); $result = $object->fetch($id);
$object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start;
$object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end; $object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end;
$object->label = GETPOST('label', 'alpha'); $object->label = GETPOST('label', 'alpha');
$object->statut = GETPOST('statut', 'int'); $object->statut = GETPOST('statut', 'int');
$result = $object->update($user); $result = $object->update($user);
if ($result > 0) { if ($result > 0) {
@ -139,105 +141,106 @@ else if ($action == 'update') {
/* /*
* View * View
*/ */
$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card");
llxHeader(); $helpurl = "";
llxHeader("",$title,$helpurl);
$form = new Form($db); $form = new Form($db);
if ($action == 'create') if ($action == 'create')
{ {
print load_fiche_titre($langs->trans("NewFiscalYear")); print load_fiche_titre($langs->trans("NewFiscalYear"));
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
dol_fiche_head(); dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Label // Label
print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="32" value="' . GETPOST("label") . '"></td></tr>'; print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="32" value="' . GETPOST("label") . '"></td></tr>';
// Date start // Date start
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>'; print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear'); print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>'; print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend'); print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend');
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("Status") . '</td>'; print '<td class="fieldrequired">' . $langs->trans("Status") . '</td>';
print '<td class="valeur">'; print '<td class="valeur">';
print $form->selectarray('statut', $statut2label, GETPOST('statut')); print $form->selectarray('statut', $statut2label, GETPOST('statut'));
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center">'; print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">'; print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">'; print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} else if ($id) { } else if ($id) {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0) { if ($result > 0) {
$head = fiscalyear_prepare_head($object); $head = fiscalyear_prepare_head($object);
if ($action == 'edit') { if ($action == 'edit') {
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n"; print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="' . $id . '">'; print '<input type="hidden" name="id" value="' . $id . '">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print "<tr>"; print "<tr>";
print '<td class="titlefield">' . $langs->trans("Ref") . '</td><td>'; print '<td class="titlefieldcreate titlefield">' . $langs->trans("Ref") . '</td><td>';
print $object->ref; print $object->ref;
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td>'; print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td>';
print '<input name="label" class="flat" size="32" value="' . $object->label . '">'; print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
print '</td></tr>'; print '</td></tr>';
// Date start // Date start
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>'; print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear'); print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>'; print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr><td>' . $langs->trans("Statut") . '</td><td>'; print '<tr><td>' . $langs->trans("Statut") . '</td><td>';
print $form->selectarray('statut', $statut2label, $object->statut); print $form->selectarray('statut', $statut2label, $object->statut);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br><div class="center">'; print '<br><div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">'; print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
dol_fiche_end(); dol_fiche_end();
} else { } else {
/* /*
@ -246,58 +249,57 @@ if ($action == 'create')
if ($action == 'delete') { if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
} }
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/fiscalyear.php">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/fiscalyear.php">' . $langs->trans("BackToList") . '</a>';
// Ref // Ref
print '<tr><td width="25%">' . $langs->trans("Ref") . '</td><td width="50%">'; print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td width="50%">';
print $object->ref; print $object->ref;
print '</td><td width="25%">'; print '</td><td>';
print $linkback; print $linkback;
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32');
print "</td></tr>"; print "</td></tr>";
// Date start // Date start
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker');
print '</td><td colspan="2">'; print '</td><td colspan="2">';
print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker');
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr><td>' . $langs->trans("Status") . '</td><td colspan="2">' . $object->getLibStatut(4) . '</td></tr>'; print '<tr><td>' . $langs->trans("Status") . '</td><td colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
print "</table>"; print "</table>";
dol_fiche_end(); dol_fiche_end();
/* /*
* Barre d'actions * Barre d'actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>'; print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>'; print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
print '</div>'; print '</div>';
} }
} else { } else {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,8 +16,8 @@
*/ */
/** /**
* \file htdocs/accountancy/admin/fiscalyear_card.php * \file htdocs/accountancy/admin/fiscalyear_card.php
* \brief Page to show info of a fiscal year * \brief Page to show info of a fiscal year
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
@ -29,27 +29,31 @@ $langs->load("admin");
$langs->load("compta"); $langs->load("compta");
// Security check // Security check
if (! $user->admin) if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear)
accessforbidden(); accessforbidden();
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
// View // View
llxHeader(); $title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Info");
$helpurl = "";
llxHeader("",$title,$helpurl);
if ($id) { if ($id) {
$object = new Fiscalyear($db); $object = new Fiscalyear($db);
$object->fetch($id); $object->fetch($id);
$object->info($id); $object->info($id);
$head = fiscalyear_prepare_head($object); $head = fiscalyear_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("FiscalYearCard"), 0, 'cron'); dol_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron');
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($object); dol_print_object_info($object);
print '</td></tr></table>'; print '</td></tr></table>';
print '</div>'; print '</div>';
} }

View File

@ -49,7 +49,7 @@ ErrorDecimalLargerThanAreForbidden=Error, a precision higher than <b>%s</b> is n
DictionarySetup=Dictionary setup DictionarySetup=Dictionary setup
Dictionary=Dictionaries Dictionary=Dictionaries
Chartofaccounts=Chart of accounts Chartofaccounts=Chart of accounts
Fiscalyear=Fiscal years Fiscalyear=Fiscal year
ErrorReservedTypeSystemSystemAuto=Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record ErrorReservedTypeSystemSystemAuto=Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record
ErrorCodeCantContainZero=Code can't contain value 0 ErrorCodeCantContainZero=Code can't contain value 0
DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers) DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers)
@ -1522,6 +1522,7 @@ OpenFiscalYear=Open fiscal year
CloseFiscalYear=Close fiscal year CloseFiscalYear=Close fiscal year
DeleteFiscalYear=Delete fiscal year DeleteFiscalYear=Delete fiscal year
ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ?
ShowFiscalYear=Show fiscal year
AlwaysEditable=Can always be edited AlwaysEditable=Can always be edited
MAIN_APPLICATION_TITLE=Force visible name of application (warning: setting your own name here may break autofill login feature when using DoliDroid mobile application) MAIN_APPLICATION_TITLE=Force visible name of application (warning: setting your own name here may break autofill login feature when using DoliDroid mobile application)
NbMajMin=Minimum number of uppercase characters NbMajMin=Minimum number of uppercase characters