From a762910f1152b67355118920d085a0a8283f39d7 Mon Sep 17 00:00:00 2001 From: aspangaro <alexandre.spangaro@gmail.com> Date: Mon, 29 Jun 2015 21:16:30 +0200 Subject: [PATCH] Add getNomUrl on accounting for account --- htdocs/accountancy/admin/account.php | 14 ++++-- .../class/accountingaccount.class.php | 45 +++++++++++++------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 0c2a825604b..d935eb025dc 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> + * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.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 @@ -154,7 +154,7 @@ if ($result) { print_liste_field_titre($langs->trans("Accountparent"), $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Active"), $_SERVER["PHP_SELF"], "aa.active", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); print '</tr>'; @@ -174,12 +174,17 @@ if ($result) { $var = true; + $accountstatic=new AccountingAccount($db); + while ( $i < min($num, $limit) ) { $obj = $db->fetch_object($resql); - $var = ! $var; + $accountstatic->id=$obj->rowid; + $accountstatic->label=$obj->label; + $accountstatic->account_number=$obj->account_number; + print '<tr ' . $bc[$var] . '>'; - print '<td><a href="./card.php?id=' . $obj->rowid . '">' . $obj->account_number . '</td>'; + print '<td>' . $accountstatic->getNomUrl(1) . '</td>'; print '<td>' . $obj->label . '</td>'; print '<td>' . $obj->account_parent . '</td>'; print '<td>' . $obj->pcg_type . '</td>'; @@ -210,6 +215,7 @@ if ($result) { print '</td>' . "\n"; print "</tr>\n"; + $var=!$var; $i ++; } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 1161e83004c..f3ad3e23a47 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> + * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * @@ -66,8 +66,7 @@ class AccountingAccount extends CommonObject */ function fetch($rowid = null, $account_number = null) { - if ($rowid || $account_number) - { + if ($rowid || $account_number) { $sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, fk_user_author, fk_user_modif, active"; $sql.= " FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE"; if ($rowid) { @@ -78,12 +77,10 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->rowid = $obj->rowid; $this->datec = $obj->datec; @@ -99,18 +96,13 @@ class AccountingAccount extends CommonObject $this->active = $obj->active; return $this->id; - } - else - { + } else { return 0; } - } - else - { + } else { dol_print_error($this->db); } } - return -1; } @@ -344,6 +336,31 @@ class AccountingAccount extends CommonObject } } + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @return string Chaine avec URL + */ + function getNomUrl($withpicto=0) + { + global $langs; + + $result=''; + + $link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id.'">'; + $linkend='</a>'; + + $picto='billr'; + + $label=$langs->trans("Show").': '.$this->account_number.' - '.$this->label; + + if ($withpicto) $result.=($link.img_object($label,$picto).$linkend); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.$this->account_number.$linkend; + return $result; + } + /** * Information on record * -- GitLab