From b8cbb84e7cb10117a110a61f2745caaa14d12467 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Nov 2017 00:28:00 +0100 Subject: [PATCH] Clean code --- htdocs/core/boxes/box_activity.php | 2 ++ htdocs/core/boxes/box_external_rss.php | 4 +-- htdocs/core/boxes/box_factures_fourn.php | 3 ++ htdocs/core/boxes/box_ficheinter.php | 26 +++++++------- htdocs/core/boxes/box_members.php | 5 +-- htdocs/core/boxes/box_project.php | 42 ++++++++++------------ htdocs/core/boxes/box_services_expired.php | 42 ++++++++++++---------- htdocs/core/boxes/box_supplier_orders.php | 28 ++++++--------- htdocs/index.php | 4 +-- htdocs/langs/en_US/contracts.lang | 1 - htdocs/langs/en_US/interventions.lang | 1 - htdocs/langs/en_US/main.lang | 2 ++ htdocs/theme/eldy/style.css.php | 2 +- 13 files changed, 80 insertions(+), 82 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index d3059daba53..cbb866d6f20 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -188,6 +188,8 @@ class box_activity extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $commandestatic=new Commande($db); + $langs->load("orders"); + $cachedir = DOL_DATA_ROOT.'/commande/temp'; $filename = '/boxactivity-order'.$fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 264f05b1f03..01eb4ac8893 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -82,7 +82,7 @@ class box_external_rss extends ModeleBoxes $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; - + // Get RSS feed $url=$conf->global->$keyforparamurl; @@ -106,7 +106,7 @@ class box_external_rss extends ModeleBoxes 'text' => $title, 'sublink' => $link, 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")), - 'subpicto'=>'object_bookmark', + 'subpicto'=>'help', ); } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 0dd0ceb22ba..bae9aef5953 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -117,6 +117,7 @@ class box_factures_fourn extends ModeleBoxes $datelimite=$db->jdate($objp->datelimite); $date=$db->jdate($objp->df); $datem=$db->jdate($objp->tms); + $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; @@ -124,6 +125,8 @@ class box_factures_fourn extends ModeleBoxes $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->date_echeance = $datelimite; $facturestatic->statut = $objp->fk_statut; + $facturestatic->ref_supplier = $objp->ref_supplier; + $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index c96fb37afe7..ef7ba62c15c 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -108,27 +108,25 @@ class box_ficheinter extends ModeleBoxes $ficheinterstatic->statut=$objp->fk_statut; $ficheinterstatic->id=$objp->rowid; + $ficheinterstatic->ref=$objp->ref; - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/fichinter/card.php?id=".$objp->rowid); + $this->info_box_contents[$i][] = array('td' => '', + 'text' => $ficheinterstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][1] = array('td' => '', - 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some interventions have no ref - 'url' => DOL_URL_ROOT."/fichinter/card.php?id=".$objp->rowid); - - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', + $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][3] = array('td' => '', + $this->info_box_contents[$i][] = array('td' => '', 'text' => dol_trunc($objp->name,40), 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][4] = array('td' => 'class="right"', + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => dol_print_date($datec,'day')); - $this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"', + $this->info_box_contents[$i][] = array('td' => 'align="right" class="nowrap"', 'text' => $ficheinterstatic->getLibStatut(6), 'asis'=>1 ); @@ -136,20 +134,20 @@ class box_ficheinter extends ModeleBoxes $i++; } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions")); + if ($num==0) $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInterventions")); $db->free($resql); } else { - $this->info_box_contents[0][0] = array( 'td' => '', + $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql)); } } else { - $this->info_box_contents[0][0] = array( + $this->info_box_contents[0][] = array( 'td' => 'align="left" class="nohover opacitymedium"', 'text' => $langs->trans("ReadPermissionNotAllowed") ); diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index bbf7cd8ad48..25fa257d098 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Frederic France * @@ -109,6 +109,7 @@ class box_members extends ModeleBoxes $memberstatic->firstname=$objp->firstname; $memberstatic->id = $objp->rowid; $memberstatic->ref = $objp->rowid; + $memberstatic->company = $objp->company; if (! empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; @@ -126,7 +127,7 @@ class box_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => '', - 'text' => $memberstatic->getFullName($langs), + 'text' => $memberstatic->company, 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, ); diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 9422f228530..ad5af03ac00 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -110,22 +110,18 @@ class box_project extends ModeleBoxes while ($i < min($num, $max)) { $objp = $db->fetch_object($result); - $tooltip = $langs->trans('Project') . ': ' . $objp->ref; - $this->info_box_contents[$i][0] = array( - 'td' => 'align="left" width="16"', - 'logo' => 'object_project'.($objp->public?'pub':''), - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/projet/card.php?id=".$objp->rowid, - ); + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; - $this->info_box_contents[$i][1] = array( + $this->info_box_contents[$i][] = array( 'td' => '', - 'text' => $objp->ref, - 'tooltip' => $tooltip, - 'url' => DOL_URL_ROOT."/projet/card.php?id=".$objp->rowid, + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 ); - $this->info_box_contents[$i][2] = array( + $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $objp->title, ); @@ -137,28 +133,28 @@ class box_project extends ModeleBoxes $resultTask = $db->query($sql); if ($resultTask) { $objTask = $db->fetch_object($resultTask); - $this->info_box_contents[$i][3] = array( + $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), ); if ($objTask->nb > 0) - $this->info_box_contents[$i][4] = array( + $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", ); else - $this->info_box_contents[$i][4] = array('td' => 'class="right"', 'text' => "N/A "); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); $totalnbTask += $objTask->nb; } else { - $this->info_box_contents[$i][3] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][4] = array('td' => 'class="right"', 'text' => "N/A "); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); } $i++; } if ($max < $num) { - $this->info_box_contents[$i][0] = array('td' => 'colspan="5"', 'text' => '...'); + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); $i++; } } @@ -166,25 +162,25 @@ class box_project extends ModeleBoxes // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][0] = array( + $this->info_box_contents[$i][] = array( 'tr' => 'class="liste_total"', 'td' => 'align="left" ', 'text' => " ", ); - $this->info_box_contents[$i][1] = array( + $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $langs->trans("Total")." ".$textHead, 'text' => " ", ); - $this->info_box_contents[$i][2] = array( + $this->info_box_contents[$i][] = array( 'td' => 'align="right" ', 'text' => round($num, 0)." ".$langs->trans("Projects"), ); - $this->info_box_contents[$i][3] = array( + $this->info_box_contents[$i][] = array( 'td' => 'align="right" ', 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), ); - $this->info_box_contents[$i][4] = array( + $this->info_box_contents[$i][] = array( 'td' => '', 'text' => " ", ); diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 4f3a2817549..f1d14c0df70 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -69,6 +69,8 @@ class box_services_expired extends ModeleBoxes $this->max=$max; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + $now=dol_now(); $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices",$max)); @@ -77,7 +79,7 @@ class box_services_expired extends ModeleBoxes { // Select contracts with at least one expired service $sql = "SELECT "; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat,"; + $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; $sql.= " s.nom as name, s.rowid as socid,"; $sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; @@ -87,7 +89,7 @@ class box_services_expired extends ModeleBoxes $sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid"; + $sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; $sql.= " ORDER BY date_line ASC"; $sql.= $db->plimit($max, 0); @@ -99,6 +101,7 @@ class box_services_expired extends ModeleBoxes $i = 0; $thirdpartytmp = new Societe($this->db); + $contract = new Contrat($this->db); while ($i < $num) { @@ -106,30 +109,33 @@ class box_services_expired extends ModeleBoxes $objp = $db->fetch_object($resql); - $dateline=$db->jdate($objp->date_line); - if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late")); - - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid); - - $this->info_box_contents[$i][1] = array('td' => '', - 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref - 'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid); - $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; - $this->info_box_contents[$i][2] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone" align="left"', + $contract->id = $objp->rowid; + $contract->ref = $objp->ref; + $contract->statut = $objp->fk_statut; + $contract->ref_customer = $objp->ref_customer; + $contract->ref_supplier = $objp->ref_supplier; + + $dateline=$db->jdate($objp->date_line); + if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late")); + + $this->info_box_contents[$i][] = array('td' => '', + 'text' => $contract->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone" align="left"', 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), 'asis' => 1 ); - $this->info_box_contents[$i][4] = array('td' => 'align="center"', + $this->info_box_contents[$i][] = array('td' => 'align="center"', 'text' => dol_print_date($dateline,'day'), 'text2'=> $late); - $this->info_box_contents[$i][5] = array('td' => 'class="right"', + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $objp->nb_services); @@ -139,14 +145,14 @@ class box_services_expired extends ModeleBoxes if ($num==0) { $langs->load("contracts"); - $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoExpiredServices")); + $this->info_box_contents[$i][] = array('td' => 'align="center"','text'=>$langs->trans("NoExpiredServices")); } $db->free($resql); } else { - $this->info_box_contents[0][0] = array( 'td' => '', + $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql)); } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 34734d9dd5a..dc20e9b9665 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -109,28 +109,20 @@ class box_supplier_orders extends ModeleBoxes $objp = $db->fetch_object($result); $date=$db->jdate($objp->date_commande); $datem=$db->jdate($objp->tms); - $thirdpartytmp->id = $objp->socid; + + $supplierorderstatic->id = $objp->id; + $supplierorderstatic->ref = $objp->ref; + + $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; - $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; - $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; - - $tooltip = $langs->trans('SupplierOrder') . ': ' . $objp->ref; - $this->info_box_contents[$line][] = array( - 'td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'tooltip' => $tooltip, - 'url' => $urlo, - ); - $this->info_box_contents[$line][] = array( 'td' => '', - 'text' => $objp->ref, - 'tooltip' => $tooltip, - 'url' => $urlo, + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 ); $this->info_box_contents[$line][] = array( @@ -158,14 +150,14 @@ class box_supplier_orders extends ModeleBoxes } if ($num == 0) - $this->info_box_contents[$line][0] = array( + $this->info_box_contents[$line][] = array( 'td' => 'align="center"', 'text' => $langs->trans("NoSupplierOrder"), ); $db->free($result); } else { - $this->info_box_contents[0][0] = array( + $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), @@ -174,7 +166,7 @@ class box_supplier_orders extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array( + $this->info_box_contents[0][] = array( 'td' => 'align="left" class="nohover opacitymedium"', 'text' => $langs->trans("ReadPermissionNotAllowed") ); diff --git a/htdocs/index.php b/htdocs/index.php index 0cba7291e9b..8c2a45d0edd 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -118,7 +118,7 @@ $langs->load("contracts"); if (empty($user->societe_id)) { $boxstat.='
'; - $boxstat.=''; + $boxstat.='
'; $boxstat.=''; $boxstat.=''; $boxstat.=''; @@ -525,7 +525,7 @@ if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = round($to //var_dump($totallate); $boxwork=''; $boxwork.='
'; -$boxwork.='
'.$langs->trans("DolibarrStateBoard").'
'."\n"; +$boxwork.='
'."\n"; $boxwork.=''; $boxwork.=''; $boxwork.=''."\n"; diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index e0642b27c02..3768cfb9ff1 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -44,7 +44,6 @@ ConfirmActivateService=Are you sure you want to activate this service with date RefContract=Contract reference DateContract=Contract date DateServiceActivate=Service activation date -ShowContract=Show contract ListOfServices=List of services ListOfInactiveServices=List of not active services ListOfExpiredServices=List of expired active services diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 15415a7fcd5..4c93eff9d0d 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -28,7 +28,6 @@ InterventionClassifyBilled=Classify "Billed" InterventionClassifyUnBilled=Classify "Unbilled" InterventionClassifyDone=Classify "Done" StatusInterInvoiced=Billed -ShowIntervention=Show intervention SendInterventionRef=Submission of intervention %s SendInterventionByMail=Send intervention by Email InterventionCreatedInDolibarr=Intervention %s created diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7f89918e90a..518b3ea6e04 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -766,6 +766,8 @@ AddBox=Add box SelectElementAndClick=Select an element and click %s PrintFile=Print File %s ShowTransaction=Show entry on bank account +ShowIntervention=Show intervention +ShowContract=Show contract GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide. Deny=Deny Denied=Denied diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e20ca0c0acc..f835ecaddf9 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4469,7 +4469,7 @@ dl.dropdown { margin-left: 2px; margin-right: 2px; padding:0px; - vertical-align: text-bottom; + vertical-align: middle; display: inline-block; } .dropdown dd, .dropdown dt {
'.$langs->trans("DolibarrWorkBoard").'