From 37c7d49537e8807efc5fc80abc0e7b43569b6749 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 6 Sep 2016 22:42:15 +0200 Subject: [PATCH] Presentation of fiscal year --- htdocs/accountancy/admin/fiscalyear.php | 15 ++- htdocs/accountancy/admin/fiscalyear_card.php | 114 ++++++++++--------- htdocs/accountancy/admin/fiscalyear_info.php | 24 ++-- htdocs/langs/en_US/admin.lang | 3 +- 4 files changed, 81 insertions(+), 75 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 638e9794fe8..f9fb603e483 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -80,8 +80,8 @@ $max = 100; $form = new Form($db); $title = $langs->trans('FiscalYears'); - -llxHeader('', $title, LOG_ERR); +$helpurl = ""; +llxHeader('', $title, $helpurl); $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"; @@ -94,7 +94,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} +} $sql.= $db->plimit($limit+1, $offset); @@ -102,12 +102,12 @@ $result = $db->query($sql); if ($result) { $var = false; $num = $db->num_rows($result); - + $i = 0; $title = $langs->trans('FiscalYears'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1); - + // Load attribute_label print ''; print ''; @@ -117,10 +117,10 @@ if ($result) { print ''; print ''; print ''; - + if ($num) { $fiscalyearstatic = new Fiscalyear($db); - + while ( $i < $num && $i < $max ) { $obj = $db->fetch_object($result); $fiscalyearstatic->id = $obj->rowid; @@ -137,7 +137,6 @@ if ($result) { } else { print ''; } - print '
' . $langs->trans("DateEnd") . '' . $langs->trans("Statut") . '
' . $langs->trans("None") . '
'; } else { dol_print_error($db); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index c45700ce4f5..ec0f19d9d07 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -28,7 +28,9 @@ $langs->load("admin"); $langs->load("compta"); // Security check -if (! $user->admin) +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->fiscalyear) accessforbidden(); $error = 0; @@ -71,13 +73,13 @@ if ($action == 'confirm_delete' && $confirm == "yes") { else if ($action == 'add') { if (! GETPOST('cancel', 'alpha')) { $error = 0; - + $object->date_start = $date_start; $object->date_end = $date_end; $object->label = GETPOST('label', 'alpha'); $object->statut = GETPOST('statut', 'int'); $object->datec = dol_now(); - + if (empty($object->date_start) && empty($object->date_end)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error ++; @@ -86,20 +88,20 @@ else if ($action == 'add') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); $error ++; } - + if (! $error) { $db->begin(); - + $id = $object->create($user); - + if ($id > 0) { $db->commit(); - + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); } else { $db->rollback(); - + setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } @@ -116,12 +118,12 @@ else if ($action == 'add') { else if ($action == 'update') { if (! GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); - + $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; $object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end; $object->label = GETPOST('label', 'alpha'); $object->statut = GETPOST('statut', 'int'); - + $result = $object->update($user); if ($result > 0) { @@ -139,105 +141,106 @@ else if ($action == 'update') { /* * View */ - -llxHeader(); +$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); +$helpurl = ""; +llxHeader("",$title,$helpurl); $form = new Form($db); if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); - + print '
'; print ''; print ''; - + dol_fiche_head(); - + print ''; - + // Label - print ''; - + print ''; + // Date start print ''; - + // Date end print ''; - + // Statut print ''; print ''; print ''; - + print '
' . $langs->trans("Label") . '
' . $langs->trans("Label") . '
' . $langs->trans("DateStart") . ''; print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear'); print '
' . $langs->trans("DateEnd") . ''; print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend'); print '
' . $langs->trans("Status") . ''; print $form->selectarray('statut', $statut2label, GETPOST('statut')); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; } else if ($id) { $result = $object->fetch($id); if ($result > 0) { $head = fiscalyear_prepare_head($object); - + if ($action == 'edit') { - dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); - + dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print '
' . "\n"; print ''; print ''; print ''; - + print ''; - + // Ref print ""; - print ''; - + // Label print ''; - + // Date start print ''; - + // Date end print ''; - + // Statut print ''; - + print '
' . $langs->trans("Ref") . ''; + print '' . $langs->trans("Ref") . ''; print $object->ref; print '
' . $langs->trans("Label") . ''; print ''; print '
' . $langs->trans("DateStart") . ''; print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear'); print '
' . $langs->trans("DateEnd") . ''; print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); print '
' . $langs->trans("Statut") . ''; print $form->selectarray('statut', $statut2label, $object->statut); print '
'; - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; - + dol_fiche_end(); } else { /* @@ -246,58 +249,57 @@ if ($action == 'create') if ($action == '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 ''; - + $linkback = '' . $langs->trans("BackToList") . ''; - + // Ref - print ''; - + // Label print '"; - + // Date start print ''; - + // Date end print ''; - + // Statut print ''; - + print "
' . $langs->trans("Ref") . ''; + print '
' . $langs->trans("Ref") . ''; print $object->ref; - print ''; + print ''; print $linkback; print '
'; print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print ''; print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print "
'; print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print ''; print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print '
'; print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print ''; print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
"; - + dol_fiche_end(); - + /* * Barre d'actions */ - print '
'; - + print '' . $langs->trans('Modify') . ''; - + print '' . $langs->trans('Delete') . ''; - + print '
'; } } else { diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index f1f61a1f8d5..612e4d7f759 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * * 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 @@ -16,8 +16,8 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show info of a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_card.php + * \brief Page to show info of a fiscal year */ require '../../main.inc.php'; @@ -29,27 +29,31 @@ $langs->load("admin"); $langs->load("compta"); // Security check -if (! $user->admin) +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->fiscalyear) accessforbidden(); $id = GETPOST('id', 'int'); // View -llxHeader(); +$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Info"); +$helpurl = ""; +llxHeader("",$title,$helpurl); if ($id) { $object = new Fiscalyear($db); $object->fetch($id); $object->info($id); - + $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 '
'; dol_print_object_info($object); print '
'; - + print ''; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ebac37ce6d8..0ee682a7d5e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -49,7 +49,7 @@ ErrorDecimalLargerThanAreForbidden=Error, a precision higher than %s is n DictionarySetup=Dictionary setup Dictionary=Dictionaries 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 ErrorCodeCantContainZero=Code can't contain value 0 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 DeleteFiscalYear=Delete fiscal year ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? +ShowFiscalYear=Show fiscal year 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) NbMajMin=Minimum number of uppercase characters