From e00eb762f4884b45af72ef0bb00966237a43ad23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Aug 2011 14:25:44 +0000 Subject: [PATCH] Look: Uniformize code and array presentation Doc: Doxygen --- htdocs/comm/index.php | 91 ++++++++++++- htdocs/comm/propal/index.php | 113 +++++++++++++--- htdocs/compta/index.php | 16 +-- htdocs/contrat/class/contrat.class.php | 54 ++++---- htdocs/contrat/index.php | 171 ++++++++++++++++++++----- htdocs/contrat/services.php | 6 +- 6 files changed, 361 insertions(+), 90 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 7af6a2934fb..248c5437186 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -21,7 +21,7 @@ * \file htdocs/comm/index.php * \ingroup commercial * \brief Home page of commercial area - * \version $Id: index.php,v 1.172 2011/08/08 12:22:52 eldy Exp $ + * \version $Id: index.php,v 1.173 2011/08/08 14:25:44 eldy Exp $ */ require("../main.inc.php"); @@ -272,6 +272,87 @@ $NBMAX=3; $max=3; +/* + * Last modified proposals + */ +/* +if ($conf->propal->enabled && $user->rights->propale->lire) +{ + $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas, p.rowid as propalid, p.total_ht, p.ref, p.fk_statut, p.datep as dp"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_soc = s.rowid"; + $sql.= " AND p.entity = ".$conf->entity; + //$sql.= " AND p.fk_statut > 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql.= " ORDER BY p.datep DESC"; + $sql.= $db->plimit($NBMAX, 0); + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + $i = 0; + print ''; + print ''; + $var=False; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + print ''; + + // Ref + print ''; + + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + $i++; + $var=!$var; + } + + print "
'.$langs->trans("LastModifiedProposals",$NBMAX).'
'; + + $propalstatic->id=$objp->propalid; + $propalstatic->ref=$objp->ref; + + print ''; + print ''; + print ''; + print '
'; + print $propalstatic->getNomUrl(1); + print ''; + // TODO se baser sur datep ou fin_validite ? + if (($objp->fk_statut <= 1) && ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay))) print img_warning($langs->trans("Late")); + print ''; + $filename=dol_sanitizeFileName($objp->ref); + $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->propalid; + $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); + print '
'; + + print '
'; + $companystatic->id=$objp->socid; + $companystatic->name=$objp->name; + $companystatic->client=$objp->client; + $companystatic->canvas=$objp->canvas; + print $companystatic->getNomUrl(1,'customer',44); + print ''; + print dol_print_date($db->jdate($objp->dp),'day').''.price($objp->total_ht).''.$propalstatic->LibStatut($objp->fk_statut,3).'

"; + $db->free($resql); + } + else + { + dol_print_error($db,''); + } +} +*/ + /* * Last modified customers or prospects */ @@ -405,8 +486,7 @@ if ($user->rights->agenda->myactions->read) /* - * Derniers contrats - * + * Last contracts */ if ($conf->contrat->enabled && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT { @@ -465,8 +545,7 @@ if ($conf->contrat->enabled && $user->rights->contrat->lire && 0) // TODO A REFA } /* - * Propales ouvertes - * + * Opened proposals */ if ($conf->propal->enabled && $user->rights->propale->lire) { @@ -551,5 +630,5 @@ print ''; $db->close(); -llxFooter('$Date: 2011/08/08 12:22:52 $ - $Revision: 1.172 $'); +llxFooter('$Date: 2011/08/08 14:25:44 $ - $Revision: 1.173 $'); ?> \ No newline at end of file diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 22b79c8750b..ae8c8f82cd9 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -21,7 +21,7 @@ * \file htdocs/comm/propal/index.php * \ingroup propal * \brief Home page of proposal area - * \version $Id: index.php,v 1.7 2011/08/03 00:46:34 eldy Exp $ + * \version $Id: index.php,v 1.8 2011/08/08 14:25:44 eldy Exp $ */ require("../../main.inc.php"); @@ -47,7 +47,7 @@ if ($user->societe_id > 0) * View */ -$propal_static=new Propal($db); +$propalstatic=new Propal($db); $html = new Form($db); $formfile = new FormFile($db); $help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo Presupuestos"; @@ -122,12 +122,12 @@ if ($resql) $listofstatus=array(0,1,2,3,4); foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$propal_static->LibStatut($status,1),'values'=>array(0=>(isset($vals[$status])?$vals[$status]:0))); + $dataseries[]=array('label'=>$propalstatic->LibStatut($status,1),'values'=>array(0=>(isset($vals[$status])?$vals[$status]:0))); if (! $conf->use_javascript_ajax) { $var=!$var; print ""; - print ''.$propal_static->LibStatut($status,0).''; + print ''.$propalstatic->LibStatut($status,0).''; print ''.(isset($vals[$status])?$vals[$status]:0).''; print "\n"; } @@ -234,12 +234,12 @@ if ($resql) print ""; print ''; - $propal_static->id=$obj->rowid; - $propal_static->ref=$obj->ref; + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; } @@ -267,6 +267,85 @@ if ($resql) else dol_print_error($db); +/* + * Opened proposals + */ +if ($conf->propal->enabled && $user->rights->propale->lire) +{ + $langs->load("propal"); + + $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_soc = s.rowid"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql.= " ORDER BY p.rowid DESC"; + + $result=$db->query($sql); + if ($result) + { + $total = 0; + $num = $db->num_rows($result); + $i = 0; + if ($num > 0) + { + $var=true; + + print '
'; - print $propal_static->getNomUrl(1); + print $propalstatic->getNomUrl(1); print ''; @@ -257,7 +257,7 @@ if ($resql) print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.dol_print_date($db->jdate($obj->datec),'day').''.$propal_static->LibStatut($obj->fk_statut,5).''.$propalstatic->LibStatut($obj->fk_statut,5).'
'; + print ''; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; + print ''; + + // Ref + print '"; + + print ''."\n"; + print ''."\n"; + print ''; + print ''."\n"; + print ''."\n"; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) { + print '"; + } + print "
'.$langs->trans("ProposalsOpened").' ('.$num.')
'; + + $propalstatic->id=$obj->propalid; + $propalstatic->ref=$obj->ref; + + print ''; + print ''; + print ''; + print '
'; + print $propalstatic->getNomUrl(1); + print ''; + if ($db->jdate($obj->dp) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); + print '
'; + + print "
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,44).''; + print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut,3).'
'.$langs->trans("Total")."".price($total)." 

"; + } + } + else + { + dol_print_error($db); + } +} + /* * Proposals to process */ @@ -304,12 +383,12 @@ if ($conf->propal->enabled) print ""; print ''; - $propal_static->id=$obj->rowid; - $propal_static->ref=$obj->ref; + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -376,12 +455,12 @@ if ($conf->propal->enabled) print ""; print '
'; - print $propal_static->getNomUrl(1); + print $propalstatic->getNomUrl(1); print ''; @@ -327,7 +406,7 @@ if ($conf->propal->enabled) print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).''.$propal_static->LibStatut($obj->fk_statut,$obj->facture,5).''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).'
'; - $propal_static->id=$obj->rowid; - $propal_static->ref=$obj->ref; + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -415,6 +494,6 @@ print '
'; - print $propal_static->getNomUrl(1); + print $propalstatic->getNomUrl(1); print ''; @@ -399,7 +478,7 @@ if ($conf->propal->enabled) print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.$propal_static->LibStatut($obj->fk_statut,$obj->facture,5).''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).'
'; $db->close(); -llxFooter('$Date: 2011/08/03 00:46:34 $ - $Revision: 1.7 $'); +llxFooter('$Date: 2011/08/08 14:25:44 $ - $Revision: 1.8 $'); ?> diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 0efb704828f..2002f743795 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -21,7 +21,7 @@ * \file htdocs/compta/index.php * \ingroup compta * \brief Main page of accountancy area - * \version $Id: index.php,v 1.184 2011/08/03 00:46:24 eldy Exp $ + * \version $Id: index.php,v 1.185 2011/08/08 14:25:45 eldy Exp $ */ require('../main.inc.php'); @@ -347,7 +347,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) $i = 0; print ''; - print ''; + print ''; if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''; print ''; print ''; @@ -444,7 +444,7 @@ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $num = $db->num_rows($resql); print '
'.$langs->trans("BoxTitleLastCustomerBills",min($max,$num)).'
'.$langs->trans("BoxTitleLastCustomerBills",$max).''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").'
'; - print ''; + print ''; if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''; print ''; print ''; @@ -519,7 +519,7 @@ if ($conf->don->enabled && $user->rights->societe->lire) $i = 0; print '
'.$langs->trans("BoxTitleLastSupplierBills",min($max,$num)).'
'.$langs->trans("BoxTitleLastSupplierBills",$max).''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").'
'; - print ''; + print ''; print ''; print ''; print ''; @@ -588,7 +588,7 @@ if ($conf->deplacement->enabled && $user->rights->deplacement->lire) print '
'.$langs->trans("BoxTitleLastModifiedDonations",min($max,$num)).'
'.$langs->trans("BoxTitleLastModifiedDonations",$max).''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' 
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -838,7 +838,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) $i = 0; print '
'.$langs->trans("BoxTitleLastModifiedExpenses",min($max,$num)).''.$langs->trans("BoxTitleLastModifiedExpenses",$max).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'; - print ''; + print ''; if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''; print ''; print ''; @@ -943,7 +943,7 @@ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $num = $db->num_rows($resql); print '
'.$langs->trans("BillsCustomersUnpaid",min($conf->liste_limit,$num)).' ('.$num.')
'.$langs->trans("BillsCustomersUnpaid",$num).' ('.$num.')'.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Received").'
'; - print ''; + print ''; if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''; print ''; print ''; @@ -1031,5 +1031,5 @@ print '
'.$langs->trans("BillsSuppliersUnpaid",min($conf->liste_limit,$num)).' ('.$num.')
'.$langs->trans("BillsSuppliersUnpaid",$num).' ('.$num.')'.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").'
'; $db->close(); -llxFooter('$Date: 2011/08/03 00:46:24 $ - $Revision: 1.184 $'); +llxFooter('$Date: 2011/08/08 14:25:45 $ - $Revision: 1.185 $'); ?> diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2c127cb9efc..593ef6ef347 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -24,7 +24,7 @@ * \file htdocs/contrat/class/contrat.class.php * \ingroup contrat * \brief Fichier de la classe des contrats - * \version $Id: contrat.class.php,v 1.23 2011/07/31 23:50:01 eldy Exp $ + * \version $Id: contrat.class.php,v 1.24 2011/08/08 14:25:44 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); @@ -1542,8 +1542,8 @@ class ContratLigne /** - * \brief Constructeur d'objets ligne de contrat - * \param DB Database access handler + * Constructeur d'objets ligne de contrat + * @param DB Database access handler */ function ContratLigne($DB) { @@ -1552,9 +1552,9 @@ class ContratLigne /** - * \brief Return label of this contract line status - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \return string Libelle + * Return label of this contract line status + * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle */ function getLibStatut($mode) { @@ -1562,11 +1562,11 @@ class ContratLigne } /** - * \brief Return label of a contract line status - * \param statut id statut - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \param expired 0=Not expired, 1=Expired, -1=Both or unknown - * \return string Libelle + * Return label of a contract line status + * @param statut id statut + * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param expired 0=Not expired, 1=Expired, -1=Both or unknown + * @return string Libelle */ function LibStatut($statut,$mode,$expired=-1) { @@ -1623,10 +1623,10 @@ class ContratLigne } /** - \brief Renvoie nom clicable (avec eventuellement le picto) - \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - \return string Chaine avec URL - */ + * Renvoie nom clicable (avec eventuellement le picto) + * @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * @return string Chaine avec URL + */ function getNomUrl($withpicto=0,$maxlength=0) { global $langs; @@ -1647,10 +1647,10 @@ class ContratLigne } /** - * \brief Load object in memory from database - * \param id id object - * \param ref Ref of contract - * \return int <0 if KO, >0 if OK + * Load object in memory from database + * @param id id object + * @param ref Ref of contract + * @return int <0 if KO, >0 if OK */ function fetch($id, $ref='') { @@ -1752,11 +1752,11 @@ class ContratLigne } - /* - * \brief Update database for contract line - * \param user User that modify - * \param notrigger 0=no, 1=yes (no update trigger) - * \return int <0 if KO, >0 if OK + /** + * Update database for contract line + * @param user User that modify + * @param notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK */ function update($user, $notrigger=0) { @@ -1854,9 +1854,9 @@ class ContratLigne /** - * \brief Mise a jour en base des champs total_xxx de ligne - * \remarks Utilise par migration - * \return int <0 si ko, >0 si ok + * Mise a jour en base des champs total_xxx de ligne + * Used by migration process + * @return int <0 if KO, >0 if OK */ function update_total() { diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 49fbaddc963..1684c49b97f 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -20,8 +20,8 @@ /** * \file htdocs/contrat/index.php * \ingroup contrat - * \brief Page liste des contrats - * \version $Revision: 1.84 $ + * \brief Home page of contract area + * \version $Revision: 1.85 $ */ require ("../main.inc.php"); @@ -45,6 +45,14 @@ $result = restrictedArea($user, 'contrat',$contratid,''); $staticcompany=new Societe($db); $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); +$productstatic=new Product($db); + + +/* + * Action + */ + +// None /* @@ -355,13 +363,94 @@ else print '
'; - -// Not activated services -$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.description as note, cd.fk_contrat, s.nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; +// Last modified services +$sql = "SELECT c.ref, c.fk_soc, "; +$sql.= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,"; +$sql.= " s.nom,"; +$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype"; +$sql.= " FROM (".MAIN_DB_PREFIX."contratdet as cd"; $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; +$sql.= " WHERE cd.fk_contrat = c.rowid"; +$sql.= " AND c.fk_soc = s.rowid"; +$sql.= " AND s.entity = ".$conf->entity; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if ($socid) $sql.= " AND s.rowid = ".$socid; +$sql.= " ORDER BY cd.tms DESC"; + +$resql=$db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + print ''; + + print ''; + print "\n"; + + $var=True; + while ($i < min($num,$max)) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + $db->free(); + + print "
'.$langs->trans("LastModifiedServices",$max).'
'; + $staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat); + $staticcontrat->id=$obj->fk_contrat; + print $staticcontrat->getNomUrl(1,16); + //if (1 == 1) print img_warning($langs->trans("Late")); + print ''; + if ($obj->fk_product > 0) + { + $productstatic->id=$obj->fk_product; + $productstatic->type=$obj->ptype; + $productstatic->ref=$obj->pref; + print $productstatic->getNomUrl(1,'',20); + } + else + { + print ''.img_object($langs->trans("ShowService"),"service"); + if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + else print ' '.dol_trunc($obj->note,20); + } + print ''; + $staticcompany->id=$obj->fk_soc; + $staticcompany->nom=$obj->nom; + print $staticcompany->getNomUrl(1,'',20); + print ''; + $dateend=$db->jdate($obj->date_fin_validite); + print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now)?1:0); + print '
"; + +} +else +{ + dol_print_error($db); +} + +print '
'; + +// Not activated services +$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,"; +$sql.= " s.nom,"; +$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype"; +$sql.= " FROM (".MAIN_DB_PREFIX."contratdet as cd"; +$sql.= ", ".MAIN_DB_PREFIX."contrat as c"; +$sql.= ", ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " WHERE c.statut=1"; $sql.= " AND cd.statut = 0"; $sql.= " AND cd.fk_contrat = c.rowid"; @@ -379,7 +468,7 @@ if ($resql) print ''; - print ''; + print ''; print "\n"; $var=True; @@ -394,10 +483,21 @@ if ($resql) $staticcontrat->id=$obj->fk_contrat; print $staticcontrat->getNomUrl(1,16); print ''; - print ''; - else print ' '.dol_trunc($obj->note,20).''; + print ''; print '
'.$langs->trans("NotActivatedServices").'
'.$langs->trans("NotActivatedServices").' ('.$num.')
'; - print ''.img_object($langs->trans("ShowService"),"service"); - if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + if ($obj->fk_product > 0) + { + $productstatic->id=$obj->fk_product; + $productstatic->type=$obj->ptype; + $productstatic->ref=$obj->pref; + print $productstatic->getNomUrl(1,'',20); + } + else + { + print ''.img_object($langs->trans("ShowService"),"service"); + if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + else print ' '.dol_trunc($obj->note,20); + } + print ''; $staticcompany->id=$obj->fk_soc; $staticcompany->nom=$obj->nom; @@ -421,17 +521,19 @@ else print '
'; -// Last modified services -$max=5; - -$sql = "SELECT c.ref, c.fk_soc, "; -$sql.= " cd.rowid as cid, cd.statut, cd.label, cd.description as note, cd.fk_contrat, cd.date_fin_validite,"; -$sql.= " s.nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; +// Expired services +$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,"; +$sql.= " s.nom,"; +$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype"; +$sql.= " FROM (".MAIN_DB_PREFIX."contratdet as cd"; $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE cd.fk_contrat = c.rowid"; +$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; +$sql.= " WHERE c.statut=1"; +$sql.= " AND cd.statut = 4"; +$sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; +$sql.= " AND cd.fk_contrat = c.rowid"; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -446,32 +548,43 @@ if ($resql) print ''; - print ''; + print ''; print "\n"; $var=True; - while ($i < min($num,$max)) + while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print ''; + print ''; - print ''; - else print ' '.dol_trunc($obj->note,20).''; + print ''; print ''; - print ''; print "\n"; $i++; @@ -492,5 +605,5 @@ print '
'; $db->close(); -llxFooter('$Date: 2011/07/31 23:46:55 $ - $Revision: 1.84 $'); +llxFooter('$Date: 2011/08/08 14:25:44 $ - $Revision: 1.85 $'); ?> \ No newline at end of file diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index de125e85f65..3c828e438a6 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -21,7 +21,7 @@ * \file htdocs/contrat/services.php * \ingroup contrat * \brief Page to list services in contracts - * \version $Id: services.php,v 1.57 2011/07/31 23:46:55 eldy Exp $ + * \version $Id: services.php,v 1.58 2011/08/08 14:25:44 eldy Exp $ */ require ("../main.inc.php"); @@ -93,7 +93,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc if ($mode == "0") $sql.= " AND cd.statut = 0"; if ($mode == "4") $sql.= " AND cd.statut = 4"; if ($mode == "5") $sql.= " AND cd.statut = 5"; -if ($filter == "expired") $sql.= " AND date_fin_validite < ".$db->idate($now); +if ($filter == "expired") $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; if ($search_nom) $sql.= " AND s.nom like '%".$db->escape($search_nom)."%'"; if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'"; if ($search_service) $sql.= " AND (p.ref like '%".$db->escape($search_service)."%' OR p.description like '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; @@ -266,5 +266,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/31 23:46:55 $ - $Revision: 1.57 $'); +llxFooter('$Date: 2011/08/08 14:25:44 $ - $Revision: 1.58 $'); ?>
'.$langs->trans("LastModifiedServices",min($num,$max)).'
'.$langs->trans("ListOfExpiredServices").' ('.$num.')
'; $staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat); $staticcontrat->id=$obj->fk_contrat; print $staticcontrat->getNomUrl(1,16); - //if (1 == 1) print img_warning($langs->trans("Late")); print ''.img_object($langs->trans("ShowService"),"service"); - if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + if ($obj->fk_product > 0) + { + $productstatic->id=$obj->fk_product; + $productstatic->type=$obj->ptype; + $productstatic->ref=$obj->pref; + print $productstatic->getNomUrl(1,'',20); + } + else + { + print ''.img_object($langs->trans("ShowService"),"service"); + if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + else print ' '.dol_trunc($obj->note,20); + } + print ''; $staticcompany->id=$obj->fk_soc; $staticcompany->nom=$obj->nom; print $staticcompany->getNomUrl(1,'',20); print ''; - $dateend=$db->jdate($obj->date_fin_validite); - print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now)?1:0); + print ''; + print $staticcontratligne->LibStatut($obj->statut,3,1); print '