Skip to content

Commit

Permalink
Fix links on list from warnings dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jun 6, 2016
1 parent 473ab18 commit fb13225
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 25 deletions.
12 changes: 8 additions & 4 deletions htdocs/adherents/class/adherent.class.php
Expand Up @@ -1737,7 +1737,7 @@ function load_board($user)
$response = new WorkboardResponse();
$response->warning_delay=$conf->adherent->cotisation->warning_delay/60/60/24;
$response->label=$langs->trans("MembersWithSubscriptionToReceive");
$response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1';
$response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1&filter=outofdate';
$response->img=img_object($langs->trans("Members"),"user");

$adherentstatic = new Adherent($this->db);
Expand Down Expand Up @@ -2006,14 +2006,18 @@ public static function replaceThirdparty($db, $origin_id, $dest_id)
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}

/**
* Return if a member is late (subscription late) or not
*
* @return boolean True if late, False if not late
*/
public function hasDelay()
{
global $conf;

//Only valid members
if ($this->statut <= 0) {
return false;
}
if ($this->statut <= 0) return false;
if (! $this->datefin) return false;

$now = dol_now();

Expand Down
1 change: 1 addition & 0 deletions htdocs/compta/bank/class/account.class.php
Expand Up @@ -1102,6 +1102,7 @@ function load_board(User $user, $filteraccountid = 0)
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
$sql.= " AND clos = 0";
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;

$resql=$this->db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/bank/index.php
Expand Up @@ -105,7 +105,7 @@
$solde = $acc->solde(1);

print '<tr '.$bc[$var].'>';
print '<td width="30%">'.$acc->getNomUrl(1).'</td>';
print '<td class="titlefield">'.$acc->getNomUrl(1).'</td>';
print '<td>'.$acc->bank.'</td>';
print '<td>'.$acc->number.'</td>';
print '<td align="center">';
Expand All @@ -116,7 +116,7 @@
setEventMessages($acc->error, $acc->errors, 'errors');
} else {
print $result->nbtodo;
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
}
}
else print $langs->trans("FeatureDisabled");
Expand Down
4 changes: 2 additions & 2 deletions htdocs/contrat/services.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
*
Expand Down Expand Up @@ -291,7 +291,7 @@
print '<td align="center">';
print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue)):'&nbsp;');
if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)))
print img_picto($langs->trans("Late"),"warning");
print ' '.img_picto($langs->trans("Late"),"warning");
else print '&nbsp;&nbsp;&nbsp;&nbsp;';
print '</td>';
}
Expand Down
18 changes: 13 additions & 5 deletions htdocs/expensereport/card.php
Expand Up @@ -1401,6 +1401,7 @@
print '<td>'.$langs->trans("NotePrivate").'</td>';
print '<td colspan="2">'.$object->note_private.'</td>';
print '</tr>';
// Amount
print '<tr>';
print '<td>'.$langs->trans("AmountHT").'</td>';
print '<td>'.price($object->total_ht).'</td>';
Expand All @@ -1412,9 +1413,8 @@
if($object->fk_statut==6) $rowspan+=2;

print '<td rowspan="'.$rowspan.'" valign="top">';
/*
* Payments
*/

// List of payments
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
$sql.= "c.code as type_code,c.libelle as payment_type";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p";
Expand Down Expand Up @@ -1499,9 +1499,13 @@
}
print '</td></tr>';

// Validation date
print '<tr>';
print '<td>'.$langs->trans("DATE_SAVE").'</td>';
print '<td>'.dol_print_date($object->date_create,'dayhour').'</td></tr>';
print '<td>'.dol_print_date($object->date_create,'dayhour');
if ($object->status == 2 && $object->hasDelay('toapprove')) print ' '.img_warning($langs->trans("Late"));
if ($object->status == 5 && $object->hasDelay('topay')) print ' '.img_warning($langs->trans("Late"));
print '</td></tr>';
print '</tr>';

// User to inform
Expand All @@ -1515,7 +1519,11 @@
$userfee=new User($db);
$userfee->fetch($object->fk_user_validator);
print $userfee->getNomUrl(1);
if (empty($userfee->email) || ! isValidEmail($userfee->email)) print img_warning($langs->trans("EmailNotValid"));
if (empty($userfee->email) || ! isValidEmail($userfee->email))
{
$langs->load("errors");
print img_warning($langs->trans("ErrorBadEMail", $userfee->email));
}
}
print '</td></tr>';
}
Expand Down
22 changes: 22 additions & 0 deletions htdocs/expensereport/class/expensereport.class.php
Expand Up @@ -1613,6 +1613,28 @@ function load_board($user, $option='topay')
return -1;
}
}

/**
* Return if an expense report is late or not
*
* @param string $option 'topay' or 'toapprove'
* @return boolean True if late, False if not late
*/
public function hasDelay($option)
{
global $conf;

//Only valid members
if ($option == 'toapprove' && $this->status != 2) return false;
if ($option == 'topay' && $this->status != 5) return false;

$now = dol_now();

if ($option == 'toapprove')
return $this->datevalid < ($now - $conf->expensereport->approve->warning_delay);
else
return $this->datevalid < ($now - $conf->expensereport->payment->warning_delay);
}
}


Expand Down
24 changes: 15 additions & 9 deletions htdocs/expensereport/list.php
Expand Up @@ -81,7 +81,6 @@

$form = new Form($db);
$formother = new FormOther($db);
$expensereporttmp=new ExpenseReport($db);

llxHeader('', $langs->trans("ListOfTrips"));

Expand All @@ -104,7 +103,7 @@
$pagenext = $page + 1;

$sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
$sql.= " d.date_debut, d.date_fin,";
$sql.= " d.date_debut, d.date_fin, d.date_valid,";
$sql.= " u.rowid as id_user, u.firstname, u.lastname";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
Expand Down Expand Up @@ -244,7 +243,8 @@
print '</td>';

// User
if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous){
if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous)
{
print '<td class="liste_titre" align="left">';
print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td>';
Expand Down Expand Up @@ -280,29 +280,35 @@

$expensereportstatic=new ExpenseReport($db);

if($num > 0)
if ($num > 0)
{
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);

$expensereportstatic->id=$objp->rowid;
$expensereportstatic->ref=$objp->ref;
$expensereportstatic->status=$objp->status;
$expensereportstatic->valid=$objp->date_valid;
$expensereportstatic->date_debut=$objp->date_debut;
$expensereportstatic->date_fin=$objp->date_fin;

$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
print '<td>';
print $expensereportstatic->getNomUrl(1);
print $expensereportstatic->status;
if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late"));
if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late"));
print '</td>';
print '<td align="center">'.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').'</td>';
print '<td align="center">'.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').'</td>';
print '<td align="left"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$objp->id_user.'">'.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>';
print '<td align="right">'.price($objp->total_ht).'</td>';
print '<td align="right">'.price($objp->total_tva).'</td>';
print '<td align="right">'.price($objp->total_ttc).'</td>';

$expensereporttmp->status=$objp->status;
print '<td align="right">';
//print $objp->status;
print $expensereporttmp->getLibStatut(5);
print $expensereportstatic->getLibStatut(5);
print '</td>';

print '<td></td>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/index.php
Expand Up @@ -473,7 +473,7 @@
{
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$board=new Account($db);
$nb = $board::countAccountToReconcile();
$nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
if ($nb > 0)
{
$dashboardlines[] = $board->load_board($user);
Expand Down
4 changes: 4 additions & 0 deletions htdocs/projet/list.php
Expand Up @@ -558,6 +558,9 @@
$projectstatic->user_author_id = $obj->fk_user_creat;
$projectstatic->public = $obj->public;
$projectstatic->ref = $obj->ref;
$projectstatic->datee = $obj->date_end;
$projectstatic->statut = $obj->fk_statut;
$projectstatic->opp_status = $obj->fk_opp_status;

$userAccess = $projectstatic->restrictedProjectArea($user); // why this ?
if ($userAccess >= 0)
Expand All @@ -570,6 +573,7 @@
{
print '<td class="nowrap">';
print $projectstatic->getNomUrl(1);
if ($projectstatic->hasDelay()) print img_warning($langs->trans('Late'));
print '</td>';
}
// Title
Expand Down
6 changes: 4 additions & 2 deletions htdocs/projet/tasks/list.php
Expand Up @@ -213,7 +213,7 @@
if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found

$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
$sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate";
$sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate";
$sql.= ", s.nom as name, s.rowid as socid";
$sql.= ", t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update";
$sql.= ", t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut";
Expand Down Expand Up @@ -550,13 +550,14 @@
$projectstatic->title = $obj->projecttitle;
$projectstatic->public = $obj->public;
$projectstatic->statut = $obj->projectstatus;
$projectstatic->datee = $obj->date_end;
$projectstatic->datee = $obj->projectdatee;

$taskstatic->id = $obj->id;
$taskstatic->ref = $obj->ref;
$taskstatic->label = $obj->label;
$taskstatic->fk_statut = $obj->fk_statut;
$taskstatic->progress = $obj->progress;
$taskstatic->datee = $obj->date_end;

$userAccess = $projectstatic->restrictedProjectArea($user); // why this ?
if ($userAccess >= 0)
Expand Down Expand Up @@ -607,6 +608,7 @@
{
print '<td>';
print $taskstatic->getNomUrl(1,'withproject');
if ($taskstatic->hasDelay()) print img_warning("Late");
print '</td>';
}
// Label
Expand Down

0 comments on commit fb13225

Please sign in to comment.