Move all output into template

This commit is contained in:
Laurent Destailleur 2011-04-11 07:35:15 +00:00
parent 92d6a056ab
commit dc25891c60
2 changed files with 71 additions and 61 deletions

View File

@ -115,9 +115,9 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$objsoc = new Societe($db); $objsoc = new Societe($db);
$objsoc->fetch($this->object->fk_soc); $objsoc->fetch($this->object->fk_soc);
$this->tpl['actionstodo']=show_actions_todo($conf,$langs,$db,$objsoc,$this->control->object); $this->tpl['actionstodo']=show_actions_todo($conf,$langs,$db,$objsoc,$this->control->object,1);
$this->tpl['actionsdone']=show_actions_done($conf,$langs,$db,$objsoc,$this->control->object); $this->tpl['actionsdone']=show_actions_done($conf,$langs,$db,$objsoc,$this->control->object,1);
} }
} }

View File

@ -530,11 +530,14 @@ function show_contacts($conf,$langs,$db,$object)
* @param db Object db * @param db Object db
* @param object Object third party * @param object Object third party
* @param objcon Object contact * @param objcon Object contact
* @param noprint Return string but does not output it
*/ */
function show_actions_todo($conf,$langs,$db,$object,$objcon='') function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0)
{ {
global $bc; global $bc;
$out='';
if ($conf->agenda->enabled) if ($conf->agenda->enabled)
{ {
require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php");
@ -542,14 +545,14 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='')
$userstatic=new User($db); $userstatic=new User($db);
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
print "\n"; $out.="\n";
if (is_object($objcon) && $objcon->id) print_titre($langs->trans("TasksHistoryForThisContact")); if (is_object($objcon) && $objcon->id) $out.=load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'','');
else print_titre($langs->trans("ActionsOnCompany")); else $out.=load_fiche_titre($langs->trans("ActionsOnCompany"),'','');
print '<table width="100%" class="noborder">'; $out.='<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; $out.='<tr class="liste_titre">';
print '<td colspan="7"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$object->id.'&amp;status=todo">'.$langs->trans("ActionsToDoShort").'</a></td><td align="right">&nbsp;</td>'; $out.='<td colspan="7"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$object->id.'&amp;status=todo">'.$langs->trans("ActionsToDoShort").'</a></td><td align="right">&nbsp;</td>';
print '</tr>'; $out.='</tr>';
$sql = "SELECT a.id, a.label,"; $sql = "SELECT a.id, a.label,";
$sql.= " a.datep as dp,"; $sql.= " a.datep as dp,";
@ -585,33 +588,33 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='')
$datep=$db->jdate($obj->dp); $datep=$db->jdate($obj->dp);
print "<tr ".$bc[$var].">"; $out.="<tr ".$bc[$var].">";
print '<td width="120" align="left" nowrap="nowrap">'.dol_print_date($datep,'dayhour')."</td>\n"; $out.='<td width="120" align="left" nowrap="nowrap">'.dol_print_date($datep,'dayhour')."</td>\n";
// Picto warning // Picto warning
print '<td width="16">'; $out.='<td width="16">';
if ($datep && $datep < (time()- ($conf->global->MAIN_DELAY_ACTIONS_TODO *60*60*24)) ) print ' '.img_warning($langs->trans("Late")); if ($datep && $datep < (time()- ($conf->global->MAIN_DELAY_ACTIONS_TODO *60*60*24)) ) $out.=' '.img_warning($langs->trans("Late"));
else print '&nbsp;'; else $out.='&nbsp;';
print '</td>'; $out.='</td>';
if ($obj->propalrowid) if ($obj->propalrowid)
{ {
print '<td width="140"><a href="propal.php?id='.$obj->propalrowid.'">'.img_object($langs->trans("ShowAction"),"task"); $out.='<td width="140"><a href="propal.php?id='.$obj->propalrowid.'">'.img_object($langs->trans("ShowAction"),"task");
$transcode=$langs->trans("Action".$obj->acode); $transcode=$langs->trans("Action".$obj->acode);
$libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle);
print $libelle; $out.=$libelle;
print '</a></td>'; $out.='</a></td>';
} }
else else
{ {
$actionstatic->type_code=$obj->acode; $actionstatic->type_code=$obj->acode;
$actionstatic->libelle=$obj->libelle; $actionstatic->libelle=$obj->libelle;
$actionstatic->id=$obj->id; $actionstatic->id=$obj->id;
print '<td width="140">'.$actionstatic->getNomUrl(1,16).'</td>'; $out.='<td width="140">'.$actionstatic->getNomUrl(1,16).'</td>';
} }
print '<td colspan="2">'.$obj->label.'</td>'; $out.='<td colspan="2">'.$obj->label.'</td>';
// Contact pour cette action // Contact pour cette action
if (! $objcon->id && $obj->fk_contact > 0) if (! $objcon->id && $obj->fk_contact > 0)
@ -619,23 +622,23 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='')
$contactstatic->name=$obj->name; $contactstatic->name=$obj->name;
$contactstatic->firstname=$obj->firstname; $contactstatic->firstname=$obj->firstname;
$contactstatic->id=$obj->fk_contact; $contactstatic->id=$obj->fk_contact;
print '<td width="120">'.$contactstatic->getNomUrl(1,'',10).'</td>'; $out.='<td width="120">'.$contactstatic->getNomUrl(1,'',10).'</td>';
} }
else else
{ {
print '<td>&nbsp;</td>'; $out.='<td>&nbsp;</td>';
} }
print '<td width="80" nowrap="nowrap">'; $out.='<td width="80" nowrap="nowrap">';
$userstatic->id=$obj->fk_user_author; $userstatic->id=$obj->fk_user_author;
$userstatic->login=$obj->login; $userstatic->login=$obj->login;
print $userstatic->getLoginUrl(1); $out.=$userstatic->getLoginUrl(1);
print '</td>'; $out.='</td>';
// Statut // Statut
print '<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($obj->percent,3).'</td>'; $out.='<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($obj->percent,3).'</td>';
print "</tr>\n"; $out.="</tr>\n";
$i++; $i++;
} }
} }
@ -650,10 +653,13 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='')
{ {
dol_print_error($db); dol_print_error($db);
} }
print "</table>\n"; $out.="</table>\n";
print "<br>\n"; $out.="<br>\n";
} }
if ($noprint) return $out;
else print $out;
} }
/** /**
@ -661,13 +667,15 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='')
* @param conf Object conf * @param conf Object conf
* @param langs Object langs * @param langs Object langs
* @param db Object db * @param db Object db
* @param objsoc Object third party * @param object Object third party
* @param objcon Object contact * @param objcon Object contact
* @param noprint Return string but does not output it
*/ */
function show_actions_done($conf,$langs,$db,$object,$objcon='') function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0)
{ {
global $bc; global $bc;
$out='';
$histo=array(); $histo=array();
$numaction = 0 ; $numaction = 0 ;
@ -770,67 +778,67 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='')
$orderstatic=new Commande($db); $orderstatic=new Commande($db);
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
print "\n"; $out.="\n";
print '<table class="noborder" width="100%">'; $out.='<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; $out.='<tr class="liste_titre">';
print '<td colspan="8"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$object->id.'&amp;status=done">'.$langs->trans("ActionsDoneShort").'</a></td>'; $out.='<td colspan="8"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$object->id.'&amp;status=done">'.$langs->trans("ActionsDoneShort").'</a></td>';
print '</tr>'; $out.='</tr>';
foreach ($histo as $key=>$value) foreach ($histo as $key=>$value)
{ {
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">"; $out.="<tr ".$bc[$var].">";
// Champ date // Champ date
print '<td width="120" nowrap="nowrap">'.dol_print_date($histo[$key]['date'],'dayhour')."</td>\n"; $out.='<td width="120" nowrap="nowrap">'.dol_print_date($histo[$key]['date'],'dayhour')."</td>\n";
// Picto // Picto
print '<td width="16">&nbsp;</td>'; $out.='<td width="16">&nbsp;</td>';
// Action // Action
print '<td width="140">'; $out.='<td width="140">';
if ($histo[$key]['type']=='action') if ($histo[$key]['type']=='action')
{ {
$actionstatic->type_code=$histo[$key]['acode']; $actionstatic->type_code=$histo[$key]['acode'];
$actionstatic->libelle=$histo[$key]['libelle']; $actionstatic->libelle=$histo[$key]['libelle'];
$actionstatic->id=$histo[$key]['id']; $actionstatic->id=$histo[$key]['id'];
print $actionstatic->getNomUrl(1,16); $out.=$actionstatic->getNomUrl(1,16);
} }
if ($histo[$key]['type']=='mailing') if ($histo[$key]['type']=='mailing')
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"),"email").' '; $out.='<a href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"),"email").' ';
$transcode=$langs->trans("Action".$histo[$key]['acode']); $transcode=$langs->trans("Action".$histo[$key]['acode']);
$libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing'); $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing');
print dol_trunc($libelle,30); $out.=dol_trunc($libelle,30);
} }
print '</td>'; $out.='</td>';
// Note // Note
print '<td>'.dol_trunc($histo[$key]['note'], 30).'</td>'; $out.='<td>'.dol_trunc($histo[$key]['note'], 30).'</td>';
// Objet lie // Objet lie
print '<td>'; $out.='<td>';
if ($histo[$key]['pid'] && $conf->propal->enabled) if ($histo[$key]['pid'] && $conf->propal->enabled)
{ {
$propalstatic->ref=$langs->trans("ProposalShort"); $propalstatic->ref=$langs->trans("ProposalShort");
$propalstatic->id=$histo[$key]['pid']; $propalstatic->id=$histo[$key]['pid'];
print $propalstatic->getNomUrl(1); $out.=$propalstatic->getNomUrl(1);
} }
elseif ($histo[$key]['oid'] && $conf->commande->enabled) elseif ($histo[$key]['oid'] && $conf->commande->enabled)
{ {
$orderstatic->ref=$langs->trans("Order"); $orderstatic->ref=$langs->trans("Order");
$orderstatic->id=$histo[$key]['oid']; $orderstatic->id=$histo[$key]['oid'];
print $orderstatic->getNomUrl(1); $out.=$orderstatic->getNomUrl(1);
} }
elseif ($histo[$key]['fid'] && $conf->facture->enabled) elseif ($histo[$key]['fid'] && $conf->facture->enabled)
{ {
$facturestatic->ref=$langs->trans("Invoice"); $facturestatic->ref=$langs->trans("Invoice");
$facturestatic->id=$histo[$key]['fid']; $facturestatic->id=$histo[$key]['fid'];
$facturestatic->type=$histo[$key]['ftype']; $facturestatic->type=$histo[$key]['ftype'];
print $facturestatic->getNomUrl(1,'compta'); $out.=$facturestatic->getNomUrl(1,'compta');
} }
else print '&nbsp;'; else $out.='&nbsp;';
print '</td>'; $out.='</td>';
// Contact pour cette action // Contact pour cette action
if (! $objcon->id && $histo[$key]['contact_id'] > 0) if (! $objcon->id && $histo[$key]['contact_id'] > 0)
@ -838,32 +846,34 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='')
$contactstatic->name=$histo[$key]['name']; $contactstatic->name=$histo[$key]['name'];
$contactstatic->firstname=$histo[$key]['firstname']; $contactstatic->firstname=$histo[$key]['firstname'];
$contactstatic->id=$histo[$key]['contact_id']; $contactstatic->id=$histo[$key]['contact_id'];
print '<td width="120">'.$contactstatic->getNomUrl(1,'',10).'</td>'; $out.='<td width="120">'.$contactstatic->getNomUrl(1,'',10).'</td>';
} }
else else
{ {
print '<td>&nbsp;</td>'; $out.='<td>&nbsp;</td>';
} }
// Auteur // Auteur
print '<td nowrap="nowrap" width="80">'; $out.='<td nowrap="nowrap" width="80">';
$userstatic->id=$histo[$key]['userid']; $userstatic->id=$histo[$key]['userid'];
$userstatic->login=$histo[$key]['login']; $userstatic->login=$histo[$key]['login'];
print $userstatic->getLoginUrl(1); $out.=$userstatic->getLoginUrl(1);
print '</td>'; $out.='</td>';
// Statut // Statut
print '<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($histo[$key]['percent'],3).'</td>'; $out.='<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($histo[$key]['percent'],3).'</td>';
print "</tr>\n"; $out.="</tr>\n";
$i++; $i++;
} }
print "</table>\n"; $out.="</table>\n";
print "<br>\n"; $out.="<br>\n";
$db->free($result); $db->free($result);
} }
if ($noprint) return $out;
else print $out;
} }
/** /**