Fix: Head array hidden if nothing

This commit is contained in:
Laurent Destailleur 2010-05-20 22:23:58 +00:00
parent 542b5c7e64
commit 1a90eefb86
8 changed files with 76 additions and 66 deletions

View File

@ -249,8 +249,7 @@ if ($resql)
$action->userdone->id=$obj->fk_user_done;
// Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside
// calendar view.
// They are date start and end of action but modified to not be outside calendar view.
if ($action->percentage <= 0)
{
$action->date_start_in_calendar=$action->datep;
@ -269,37 +268,43 @@ if ($resql)
$action->ponctuel=1;
}
if ($action->date_start_in_calendar < $firstdaytoshow) $action->date_start_in_calendar=$firstdaytoshow;
if ($action->date_end_in_calendar > $lastdaytoshow) $action->date_end_in_calendar=$lastdaytoshow;
// Add an entry in actionarray for each day
$daycursor=$action->date_start_in_calendar;
$annee = date('Y',$daycursor);
$mois = date('m',$daycursor);
$jour = date('d',$daycursor);
// Loop on each day covered by action to prepare an index to show on calendar
$loop=true; $j=0;
$daykey=dol_mktime(0,0,0,$mois,$jour,$annee);
do
// Check values
if ($action->date_end_in_calendar < $firstdaytoshow ||
$action->date_start_in_calendar > $lastdaytoshow)
{
//if ($action->id==408) print 'daykey='.$daykey.' '.$action->datep.' '.$action->datef.'<br>';
//if ($action->datef && $action->datef == $daykey && $action->datep < $action->datef)
//{ // We discard such index. This means it's end of a range ending on last day + 1 at 00:00:00.
//}
//else
//{
$actionarray[$daykey][]=$action;
$j++;
//}
$daykey+=60*60*24;
if ($daykey > $action->date_end_in_calendar) $loop=false;
// This record is out of visible range
}
else
{
if ($action->date_start_in_calendar < $firstdaytoshow) $action->date_start_in_calendar=$firstdaytoshow;
if ($action->date_end_in_calendar > $lastdaytoshow) $action->date_end_in_calendar=$lastdaytoshow;
// Add an entry in actionarray for each day
$daycursor=$action->date_start_in_calendar;
$annee = date('Y',$daycursor);
$mois = date('m',$daycursor);
$jour = date('d',$daycursor);
// Loop on each day covered by action to prepare an index to show on calendar
$loop=true; $j=0;
$daykey=dol_mktime(0,0,0,$mois,$jour,$annee);
do
{
//if ($action->id==408) print 'daykey='.$daykey.' '.$action->datep.' '.$action->datef.'<br>';
$actionarray[$daykey][]=$action;
$j++;
$daykey+=60*60*24;
if ($daykey > $action->date_end_in_calendar) $loop=false;
}
while ($loop);
//print 'Event '.$i.' id='.$action->id.' (start='.dol_print_date($action->datep).'-end='.dol_print_date($action->datef);
//print ' startincalendar='.dol_print_date($action->date_start_in_calendar).'-endincalendar='.dol_print_date($action->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
}
while ($loop);
$i++;
//print 'Event '.$i.' id='.$action->id.' (start='.dol_print_date($action->datep).'-end='.dol_print_date($action->datef).') was added in '.$j.' different index days in array<br>';
}
}
else
@ -405,14 +410,15 @@ if ($_GET["action"] != 'show_day') // View by month
}
echo " </tr>\n";
// In loops, tmpday contains day nb in current month (can be negative for days of previous month)
// In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month)
//var_dump($actionarray);
//print $tmpday;
for($iter_week = 0; $iter_week < 6 ; $iter_week++)
{
echo " <tr>\n";
for($iter_day = 0; $iter_day < 7; $iter_day++)
{
/* Show days before the beginning of the current month
(previous month) */
/* Show days before the beginning of the current month (previous month) */
if($tmpday <= 0)
{
$style='cal_other_month';

View File

@ -406,13 +406,11 @@ if ($socid > 0)
{
$var=true;
$num = $db->num_rows($resql);
if ($num > 0)
{
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$objsoc->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td></tr></table></td>';
print '</tr>';
$var=!$var;
}
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$objsoc->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td></tr></table></td>';
print '</tr>';
$i = 0;
while ($i < $num && $i < $MAXLIST)
{
@ -460,12 +458,11 @@ if ($socid > 0)
{
$var=true;
$num = $db->num_rows($resql);
if ($num >0 )
{
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td></tr></table></td>';
print '</tr>';
}
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td></tr></table></td>';
print '</tr>';
$i = 0;
while ($i < $num && $i < $MAXLIST)
{

View File

@ -65,7 +65,7 @@ class Propal extends CommonObject
var $datec; // Date of creation
var $datev; // Date of validation
var $date; // Date of proposal
var $datep; // Duplicate with date
var $datep; // Same than date
var $date_livraison;
var $fin_validite;

View File

@ -2078,7 +2078,7 @@ class Facture extends CommonObject
/**
* \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle lon
* \param alreadypaid 0=Not payment already done, 1=Some payments already done
* \param alreadypaid 0=No payment already done, 1=Some payments already done
* \return string Libelle
*/
function getLibStatut($mode=0,$alreadypaid=-1)

View File

@ -306,11 +306,13 @@ if ($socid > 0)
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut,';
$sql.= ' s.nom, s.rowid as socid,';
$sql.= ' sum(pf.amount) as am';
$sql.= ' SUM(pf.amount) as am';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc, f.datef, f.datec, f.paye, f.fk_statut, s.nom, s.rowid';
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef, f.datec, f.paye, f.fk_statut,';
$sql.= ' s.nom, s.rowid';
$sql.= " ORDER BY f.datef DESC, f.datec DESC";
$resql=$db->query($sql);

View File

@ -216,29 +216,28 @@ class Fournisseur extends Societe
}
/**
* \brief Cr<EFBFBD><EFBFBD> une categorie fournisseur
* \param user Utilisateur qui cr<EFBFBD>e
* \param name Nom categorie
* \return int <0 si ko, 0 si ok
* \brief Create a supplier category
* \param user User asking creation
* \param name Nom categorie
* \return int <0 si ko, 0 si ok
*/
function CreateCategory($user, $name)
{
dol_syslog("Fournisseur::CreateCategory");
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label,visible,type)";
$sql.= " VALUES ";
$sql.= " ('".addslashes($name)."',1,1)";
$result = $this->db->query($sql);
if ($result == 1)
dol_syslog("Fournisseur::CreateCategory sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
dol_syslog("Fournisseur::CreateCategory : Success");
return 0;
}
else
{
dol_syslog("Fournisseur::CreateCategory : Failed (".$this->db->error().")");
$this->error=$this->db->lasterror();
dol_syslog("Fournisseur::CreateCategory : Failed (".$this->error.")");
return -1;
}
}

View File

@ -623,6 +623,7 @@ else
$html->select_date($fac->datep,'','','','',"update",1,1);
print '</td></tr>';
// Due date
print '<tr><td>'.$langs->trans('DateEcheance').'</td><td nowrap="nowrap">';
$html->select_date($fac->date_echeance,'ech','','','',"update",1,1);
if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
@ -875,7 +876,7 @@ else
print '<tr>';
print '<td>'.$langs->trans('DateEcheance').'</td><td colspan="3">';
print dol_print_date($fac->date_echeance,'daytext');
if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance && $fac->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
print '</td></tr>';
// Status

View File

@ -191,7 +191,7 @@ if ( $societe->fetch($socid) )
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastOrders",($num<$MAXLIST?$num:$MAXLIST)).'</td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastOrders",($num<$MAXLIST?"":$MAXLIST)).'</td>';
print '<td align="right"><a href="commande/liste.php?socid='.$societe->id.'">'.$langs->trans("AllOrders").' ('.$num.')</td></tr></table>';
print '</td></tr>';
while ($i < $num && $i <= $MAXLIST)
@ -234,10 +234,13 @@ if ( $societe->fetch($socid) )
if ($user->rights->fournisseur->facture->lire)
{
$sql = 'SELECT p.rowid,p.libelle,p.facnumber,p.fk_statut, p.datef as df, total_ttc as amount, paye';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as p';
$sql.= ' WHERE p.fk_soc = '.$societe->id;
$sql.= ' ORDER BY p.datef DESC';
$sql = 'SELECT f.rowid,f.libelle,f.facnumber,f.fk_statut,f.datef as df,f.total_ttc as amount,f.paye,';
$sql.= ' SUM(pf.amount) as am';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
$sql.= ' WHERE f.fk_soc = '.$societe->id;
$sql.= ' GROUP BY f.rowid,f.libelle,f.facnumber,f.fk_statut,f.datef,f.total_ttc,f.paye';
$sql.= ' ORDER BY f.datef DESC';
$resql=$db->query($sql);
if ($resql)
{
@ -258,7 +261,9 @@ if ( $societe->fetch($socid) )
print img_object($langs->trans('ShowBill'),'bill').' '.$obj->facnumber.'</a> '.dol_trunc($obj->libelle,14).'</td>';
print '<td align="center" nowrap="nowrap">'.dol_print_date($db->jdate($obj->df),'day').'</td>';
print '<td align="right" nowrap="nowrap">'.price($obj->amount).'</td>';
print '<td align="right" nowrap="nowrap">'.$facturestatic->LibStatut($obj->paye,$obj->fk_statut,5).'</td>';
print '<td align="right" nowrap="nowrap">';
print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$obj->am);
print '</td>';
print '</tr>';
$i++;
}