From adc36e7d63860b091194aa1be688df183bf65bae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Oct 2018 00:20:47 +0200 Subject: [PATCH] Clean code --- htdocs/compta/facture/class/facture.class.php | 16 +++--- htdocs/compta/facture/list.php | 7 ++- htdocs/contrat/list.php | 2 +- htdocs/core/lib/date.lib.php | 50 +++++++++---------- htdocs/core/lib/functions.lib.php | 14 +++++- 5 files changed, 50 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ded797b3307..048f686df3b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1253,12 +1253,14 @@ class Facture extends CommonInvoice if ($addlinktonotes) { - $txttoshow=($user->societe_id>0?$this->note_public:$this->note_private); + $txttoshow=($user->socid > 0 ? $this->note_public : $this->note_private); if ($txttoshow) { $notetoshow=$langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow,1); $result.=' '; - $result.=''.img_picto('','object_generic').''; + $result.=''; + $result.=img_picto('','note'); + $result.=''; //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); //$result.=''; $result.=''; @@ -4931,17 +4933,17 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); - + $returnPercent = floatval($res['situation_percent']); - + if($include_credit_note) { - + $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; $sql.= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed $sql.= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; - + $res = $this->db->query($sql); if($res) { while($obj = $this->db->fetch_object($res)) { @@ -4949,7 +4951,7 @@ class FactureLigne extends CommonInvoiceLine } } } - + return $returnPercent; } else { $this->error = $this->db->error(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 72cfa38e8c2..2e5cb83883f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -904,7 +904,7 @@ if ($resql) $projectstatic=new Project($db); $discount = new DiscountAbsolute($db); - + if ($num > 0) { $i=0; @@ -914,6 +914,7 @@ if ($resql) $obj = $db->fetch_object($resql); $datelimit=$db->jdate($obj->datelimite); + $facturestatic->id=$obj->id; $facturestatic->ref=$obj->ref; $facturestatic->type=$obj->type; @@ -957,12 +958,10 @@ if ($resql) print ''; - print ''; - print '
'; + print ''; print $facturestatic->getNomUrl(1,'',200,0,'',0,1); print empty($obj->increment)?'':' ('.$obj->increment.')'; - print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->id; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index e616afefd99..3331a7718fd 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -622,7 +622,7 @@ while ($i < min($num,$limit)) if (!empty($obj->note_private) || !empty($obj->note_public)) { print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + print ''.img_picto($langs->trans("ViewPrivateNote"),'note').''; print ''; } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 1b10f6d4233..8f01ea6aebe 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -923,41 +923,41 @@ function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $ha * This replace old function monthArrayOrSelected. * * @param Translate $outputlangs Object langs - * @param int $short 1=Return short label + * @param int $short 0=Return long label, 1=Return short label * @return array Month string or array if selected < 0 */ function monthArray($outputlangs,$short=0) { $montharray = array ( - 1 => $outputlangs->trans("January"), - 2 => $outputlangs->trans("February"), - 3 => $outputlangs->trans("March"), - 4 => $outputlangs->trans("April"), - 5 => $outputlangs->trans("May"), - 6 => $outputlangs->trans("June"), - 7 => $outputlangs->trans("July"), - 8 => $outputlangs->trans("August"), - 9 => $outputlangs->trans("September"), - 10 => $outputlangs->trans("October"), - 11 => $outputlangs->trans("November"), - 12 => $outputlangs->trans("December") + 1 => $outputlangs->trans("Month01"), + 2 => $outputlangs->trans("Month02"), + 3 => $outputlangs->trans("Month03"), + 4 => $outputlangs->trans("Month04"), + 5 => $outputlangs->trans("Month05"), + 6 => $outputlangs->trans("Month06"), + 7 => $outputlangs->trans("Month07"), + 8 => $outputlangs->trans("Month08"), + 9 => $outputlangs->trans("Month09"), + 10 => $outputlangs->trans("Month10"), + 11 => $outputlangs->trans("Month11"), + 12 => $outputlangs->trans("Month12") ); if (! empty($short)) { $montharray = array ( - 1 => $outputlangs->trans("JanuaryMin"), - 2 => $outputlangs->trans("FebruaryMin"), - 3 => $outputlangs->trans("MarchMin"), - 4 => $outputlangs->trans("AprilMin"), - 5 => $outputlangs->trans("MayMin"), - 6 => $outputlangs->trans("JuneMin"), - 7 => $outputlangs->trans("JulyMin"), - 8 => $outputlangs->trans("AugustMin"), - 9 => $outputlangs->trans("SeptemberMin"), - 10 => $outputlangs->trans("OctoberMin"), - 11 => $outputlangs->trans("NovemberMin"), - 12 => $outputlangs->trans("DecemberMin") + 1 => $outputlangs->trans("MonthShort01"), + 2 => $outputlangs->trans("MonthShort02"), + 3 => $outputlangs->trans("MonthShort03"), + 4 => $outputlangs->trans("MonthShort04"), + 5 => $outputlangs->trans("MonthShort05"), + 6 => $outputlangs->trans("MonthShort06"), + 7 => $outputlangs->trans("MonthShort07"), + 8 => $outputlangs->trans("MonthShort08"), + 9 => $outputlangs->trans("MonthShort09"), + 10 => $outputlangs->trans("MonthShort10"), + 11 => $outputlangs->trans("MonthShort11"), + 12 => $outputlangs->trans("MonthShort12") ); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 36c7b2a58e1..1561f4d5782 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3150,8 +3150,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( - 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow') + 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', + 'note','switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow') )) { $fakey = $pictowithoutext; $facolor = ''; $fasize = ''; @@ -3195,6 +3195,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithoutext == 'grip_title' || $pictowithoutext == 'grip') { $fakey = 'fa-arrows'; } + elseif ($pictowithoutext == 'listlight') { + $fakey = 'fa-download'; + $facolor = '#999'; + $marginleftonlyshort=1; + } elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize = '1.2em'; @@ -3204,6 +3209,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-crop'; $facolor = '#444'; } + elseif ($pictowithoutext == 'note') { + $fakey = 'fa-sticky-note-o'; + $facolor = '#999'; + $marginleftonlyshort=1; + } elseif ($pictowithoutext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor = '#555';