Boxes area output is now in a function.

Contracts boxes show status of each services (status of contracts is deprecated).
This commit is contained in:
Laurent Destailleur 2010-04-20 18:23:55 +00:00
parent 56942f72d1
commit e1c01ac3c8
6 changed files with 233 additions and 199 deletions

View File

@ -20,7 +20,7 @@
/** /**
* \file htdocs/admin/boxes.php * \file htdocs/admin/boxes.php
* \brief Page d'administration/configuration des boites * \brief Page to setup boxes
* \version $Id$ * \version $Id$
*/ */

View File

@ -28,6 +28,149 @@
/**
* \brief Show a HTML Tab with boxes of a particular area including personalized choices of user
* \param user User
* \param areacode Code of area for pages (0=value for Home page)
* \return int <0 if KO, Nb of boxes shown of OK (0 to n)
*/
function printBoxesArea($user,$areacode)
{
global $conf,$langs,$db;
$infobox=new InfoBox($db);
$boxarray=$infobox->listboxes($areacode,$user);
//$boxid_left = array();
//$boxid_right = array();
if (sizeof($boxarray))
{
print_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes');
print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td class="notopnoleftnoright">'."\n";
print '<table width="100%" style="border-collapse: collapse; border: 0px; margin: 0px; padding: 0px;"><tr>';
// Affichage colonne gauche
print '<td width="50%" valign="top">'."\n";
print "\n<!-- Box left container -->\n";
print '<div id="left">'."\n";
$ii=0;
foreach ($boxarray as $key => $box)
{
if (preg_match('/^A/i',$box->box_order)) // column A
{
$ii++;
//print 'box_id '.$boxarray[$ii]->box_id.' ';
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
//$boxid_left[$key] = $box->box_id;
// Affichage boite key
$box->loadBox($conf->box_max_lines);
$box->showBox();
}
}
// If no box on left, we add an invisible empty box
if ($ii==0)
{
$emptybox=new ModeleBoxes($db);
$emptybox->box_id='A';
$emptybox->info_box_head=array();
$emptybox->info_box_contents=array();
$emptybox->showBox(array(),array());
}
print "</div>\n";
print "<!-- End box container -->\n";
print "</td>\n";
// Affichage colonne droite
print '<td width="50%" valign="top">';
print "\n<!-- Box right container -->\n";
print '<div id="right">'."\n";
$ii=0;
foreach ($boxarray as $key => $box)
{
if (preg_match('/^B/i',$box->box_order)) // colonne B
{
$ii++;
//print 'box_id '.$boxarray[$ii]->box_id.' ';
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
//$boxid_right[$key] = $boxarray[$key]->box_id;
// Affichage boite key
$box->loadBox($conf->box_max_lines);
$box->showBox();
}
}
// If no box on right, we show add an invisible empty box
if ($ii==0)
{
$emptybox=new ModeleBoxes($db);
$emptybox->box_id='B';
$emptybox->info_box_head=array();
$emptybox->info_box_contents=array();
$emptybox->showBox(array(),array());
}
print "</div>\n";
print "<!-- End box container -->\n";
print "</td>";
print "</tr></table>\n";
print "\n";
print "</td></tr>";
print "</table>";
if ($conf->use_javascript_ajax)
{
print "\n";
print '<script type="text/javascript" language="javascript">';
print 'function updateOrder(){';
print 'var left_list = cleanSerialize(Sortable.serialize(\'left\'));';
print 'var right_list = cleanSerialize(Sortable.serialize(\'right\'));';
print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;';
//alert( \'boxorder=\' + boxorder );
print 'var userid = \''.$user->id.'\';';
print 'var url = "ajaxbox.php";';
print 'o_options = new Object();';
print 'o_options = {asynchronous:true,method: \'get\',parameters: \'boxorder=\' + boxorder + \'&userid=\' + userid};';
print 'var myAjax = new Ajax.Request(url, o_options);';
print '}';
print "\n";
print '// <![CDATA['."\n";
print 'Sortable.create(\'left\', {'."\n";
print ' tag:\'div\', '."\n";
print ' containment:["left","right"], '."\n";
print ' constraint:false, '."\n";
print " handle: 'boxhandle',"."\n";
print ' onUpdate:updateOrder';
print " });\n";
print 'Sortable.create(\'right\', {'."\n";
print ' tag:\'div\', '."\n";
print ' containment:["right","left"], '."\n";
print ' constraint:false, '."\n";
print " handle: 'boxhandle',"."\n";
print ' onUpdate:updateOrder';
print " });\n";
print '// ]]>'."\n";
print '</script>'."\n";
}
}
return sizeof($boxarray);
}
/** /**
* \class InfoBox * \class InfoBox
* \brief Classe permettant la gestion des boxes sur une page * \brief Classe permettant la gestion des boxes sur une page
@ -287,5 +430,10 @@ class InfoBox
return -1; return -1;
} }
} }
} }
?> ?>

View File

@ -1075,12 +1075,16 @@ class Contrat extends CommonObject
if ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4'); } if ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4'); }
if ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6'); } if ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6'); }
} }
if ($mode == 4) if ($mode == 4 || $mode == 6)
{ {
$line=new ContratLigne($this->db); $line=new ContratLigne($this->db);
$text=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); $text='';
$text.=' '.$langs->trans("Services"); if ($mode == 4)
$text.=': &nbsp; &nbsp; '; {
$text=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed);
$text.=' '.$langs->trans("Services");
$text.=': &nbsp; &nbsp; ';
}
$text.=$this->nbofserviceswait.' '.$line->LibStatut(0,3).' &nbsp; '; $text.=$this->nbofserviceswait.' '.$line->LibStatut(0,3).' &nbsp; ';
$text.=$this->nbofservicesopened.' '.$line->LibStatut(4,3,0).' &nbsp; '; $text.=$this->nbofservicesopened.' '.$line->LibStatut(4,3,0).' &nbsp; ';
$text.=$this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).' &nbsp; '; $text.=$this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).' &nbsp; ';

View File

@ -71,8 +71,7 @@ class box_contracts extends ModeleBoxes {
{ {
$sql = "SELECT s.nom, s.rowid as socid,"; $sql = "SELECT s.nom, s.rowid as socid,";
$sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.entity = ".$conf->entity;
@ -96,16 +95,21 @@ class box_contracts extends ModeleBoxes {
$datec=$db->jdate($objp->datec); $datec=$db->jdate($objp->datec);
$dateterm=$db->jdate($objp->fin_validite); $dateterm=$db->jdate($objp->fin_validite);
$dateclose=$db->jdate($objp->date_cloture); $dateclose=$db->jdate($objp->date_cloture);
$late = ''; $late = '';
if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
$contractstatic->statut=$objp->fk_statut;
$contractstatic->id=$objp->rowid;
$result=$contractstatic->fetch_lignes();
// fin_validite is no more on contract but on services
// if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg, 'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"', $this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->ref, 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref
'text2'=> $late, 'text2'=> $late,
'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/contrat/fiche.php?id=".$objp->rowid);
@ -120,8 +124,10 @@ class box_contracts extends ModeleBoxes {
$this->info_box_contents[$i][4] = array('td' => 'align="right"', $this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day')); 'text' => dol_print_date($datec,'day'));
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', $this->info_box_contents[$i][5] = array('td' => 'align="right" nowrap="nowrap"',
'text' => $contractstatic->LibStatut($objp->fk_statut,3)); 'text' => $contractstatic->getLibStatut(6),
'asis'=>1
);
$i++; $i++;
} }

View File

@ -90,7 +90,7 @@ class ModeleBoxes
/** /**
* \brief Methode standard d'affichage des boites * \brief Standard method to show a box (usage by boxes not mandatory, a box can still use its own function)
* \param $head tableau des caracteristiques du titre * \param $head tableau des caracteristiques du titre
* \param $contents tableau des lignes de contenu * \param $contents tableau des lignes de contenu
*/ */
@ -186,7 +186,8 @@ class ModeleBoxes
print '<td'.$tdparam.'>'; print '<td'.$tdparam.'>';
// Url // Url
if (! empty($contents[$i][$j]['url'])) { if (! empty($contents[$i][$j]['url']))
{
print '<a href="'.$contents[$i][$j]['url'].'" title="'.$textewithnotags.'"'; print '<a href="'.$contents[$i][$j]['url'].'" title="'.$textewithnotags.'"';
//print ' alt="'.$textewithnotags.'"'; // Pas de alt sur un "<a href>" //print ' alt="'.$textewithnotags.'"'; // Pas de alt sur un "<a href>"
print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':''; print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':'';
@ -204,13 +205,13 @@ class ModeleBoxes
if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength']; if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
if ($maxlength) $textewithnotags=dol_trunc($textewithnotags,$maxlength); if ($maxlength) $textewithnotags=dol_trunc($textewithnotags,$maxlength);
if (preg_match('/^<img/i',$texte)) print $texte; // show text with no html cleaning if (preg_match('/^<img/i',$texte) || $contents[$i][$j]['asis']) print $texte; // show text with no html cleaning
else print $textewithnotags; // show text with html cleaning else print $textewithnotags; // show text with html cleaning
// End Url // End Url
if (! empty($contents[$i][$j]['url'])) print '</a>'; if (! empty($contents[$i][$j]['url'])) print '</a>';
if (preg_match('/^<img/i',$texte2)) print $texte2; // show text with no html cleaning if (preg_match('/^<img/i',$texte2 || $contents[$i][$j]['asis2'])) print $texte2; // show text with no html cleaning
else print $texte2withnotags; // show text with html cleaning else print $texte2withnotags; // show text with html cleaning
print "</td>"; print "</td>";

View File

@ -560,140 +560,15 @@ if ($nboflate > 0)
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '<br>';
/* /*
* Show boxes * Show boxes
*/ */
$infobox=new InfoBox($db);
$boxarray=$infobox->listboxes("0",$user); // 0=value for home page
//$boxid_left = array(); printBoxesArea($user,"0");
//$boxid_right = array();
if (sizeof($boxarray))
{
print '<br>';
print_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes');
print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td class="notopnoleftnoright">'."\n";
print '<table width="100%" style="border-collapse: collapse; border: 0px; margin: 0px; padding: 0px;"><tr>';
// Affichage colonne gauche
print '<td width="50%" valign="top">'."\n";
print "\n<!-- Box left container -->\n";
print '<div id="left">'."\n";
$ii=0;
foreach ($boxarray as $key => $box)
{
if (preg_match('/^A/i',$box->box_order)) // column A
{
$ii++;
//print 'box_id '.$boxarray[$ii]->box_id.' ';
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
//$boxid_left[$key] = $box->box_id;
// Affichage boite key
$box->loadBox($conf->box_max_lines);
$box->showBox();
}
}
// If no box on left, we add an invisible empty box
if ($ii==0)
{
$emptybox=new ModeleBoxes($db);
$emptybox->box_id='A';
$emptybox->info_box_head=array();
$emptybox->info_box_contents=array();
$emptybox->showBox(array(),array());
}
print "</div>\n";
print "<!-- End box container -->\n";
print "</td>\n";
// Affichage colonne droite
print '<td width="50%" valign="top">';
print "\n<!-- Box right container -->\n";
print '<div id="right">'."\n";
$ii=0;
foreach ($boxarray as $key => $box)
{
if (preg_match('/^B/i',$box->box_order)) // colonne B
{
$ii++;
//print 'box_id '.$boxarray[$ii]->box_id.' ';
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
//$boxid_right[$key] = $boxarray[$key]->box_id;
// Affichage boite key
$box->loadBox($conf->box_max_lines);
$box->showBox();
}
}
// If no box on right, we show add an invisible empty box
if ($ii==0)
{
$emptybox=new ModeleBoxes($db);
$emptybox->box_id='B';
$emptybox->info_box_head=array();
$emptybox->info_box_contents=array();
$emptybox->showBox(array(),array());
}
print "</div>\n";
print "<!-- End box container -->\n";
print "</td>";
print "</tr></table>\n";
print "\n";
print "</td></tr>";
print "</table>";
if ($conf->use_javascript_ajax)
{
print "\n";
print '<script type="text/javascript" language="javascript">';
print 'function updateOrder(){';
print 'var left_list = cleanSerialize(Sortable.serialize(\'left\'));';
print 'var right_list = cleanSerialize(Sortable.serialize(\'right\'));';
print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;';
//alert( \'boxorder=\' + boxorder );
print 'var userid = \''.$user->id.'\';';
print 'var url = "ajaxbox.php";';
print 'o_options = new Object();';
print 'o_options = {asynchronous:true,method: \'get\',parameters: \'boxorder=\' + boxorder + \'&userid=\' + userid};';
print 'var myAjax = new Ajax.Request(url, o_options);';
print '}';
print "\n";
print '// <![CDATA['."\n";
print 'Sortable.create(\'left\', {'."\n";
print ' tag:\'div\', '."\n";
print ' containment:["left","right"], '."\n";
print ' constraint:false, '."\n";
print " handle: 'boxhandle',"."\n";
print ' onUpdate:updateOrder';
print " });\n";
print 'Sortable.create(\'right\', {'."\n";
print ' tag:\'div\', '."\n";
print ' containment:["right","left"], '."\n";
print ' constraint:false, '."\n";
print " handle: 'boxhandle',"."\n";
print ' onUpdate:updateOrder';
print " });\n";
print '// ]]>'."\n";
print '</script>'."\n";
}
}
/* /*