Qual: Factorisation du code de gestion des onglets pour les propales

This commit is contained in:
Laurent Destailleur 2006-06-03 22:01:38 +00:00
parent 490e293947
commit 59a18bbb55
10 changed files with 863 additions and 991 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,12 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/propal.class.php');
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
if ($conf->projet->enabled) {
require_once(DOL_DOCUMENT_ROOT."/project.class.php");
}
$user->getrights('propale');
@ -40,22 +46,15 @@ $langs->load('propal');
$langs->load("bills");
$langs->load('compta');
require_once(DOL_DOCUMENT_ROOT.'/propal.class.php');
if ($conf->projet->enabled) {
require_once(DOL_DOCUMENT_ROOT."/project.class.php");
}
/*
* Sécurité accés client
*/
// Sécurité accés client
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
llxHeader();
$html = new Form($db);
@ -66,45 +65,17 @@ $html = new Form($db);
/* */
/* *************************************************************************** */
if ($_GET["propalid"] > 0) {
if ($_GET["propalid"] > 0)
{
$propal = new Propal($db);
if ( $propal->fetch($_GET["propalid"], $user->societe_id) > 0)
{
{
$soc = new Societe($db, $propal->socidp);
$soc->fetch($propal->socidp);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$hselected=$h;
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal'));
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'preview', $langs->trans('Proposal'));
/*
@ -131,18 +102,11 @@ if ($_GET["propalid"] > 0) {
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref_url.'</td></tr>';
$rowspan=3;
// ligne 1
// partie Gauche
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">';
if ($societe->client == 1)
{
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td>';
// partie Droite
print '<td align="left">'.$langs->trans("PaymentConditions").'</td>';
print '<td>'.'&nbsp;'.'</td>';

View File

@ -31,6 +31,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
$user->getrights('propale');
@ -110,37 +111,8 @@ if ($propalid > 0)
$societe = new Societe($db);
$societe->fetch($propal->socidp);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$hselected=$h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal'));
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'document', $langs->trans('Proposal'));
// Construit liste des fichiers
clearstatcache();
@ -178,17 +150,7 @@ if ($propalid > 0)
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref_url.'</td></tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">';
if ($societe->client == 1)
{
$url ='fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';

View File

@ -30,6 +30,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
$langs->load('propal');
$langs->load('compta');
@ -56,37 +57,9 @@ $propal->fetch($_GET['propalid']);
$societe = new Societe($db);
$societe->fetch($propal->soc_id);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal'));
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'info', $langs->trans('Proposal'));
$propal->info($propal->id);

View File

@ -31,6 +31,7 @@
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
$langs->load('propal');
$langs->load('compta');
@ -109,55 +110,27 @@ if ($_GET['propalid'])
$societe = new Societe($db);
if ( $societe->fetch($propal->soc_id) )
{
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal"));
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'note', $langs->trans('Proposal'));
print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref_url.'</td></tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">';
if ($societe->client == 1)
{
$url ='fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$societe->getCurrentDiscount();
print '. ';
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
print '.';
print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans('Date').'</td><td>';
print dolibarr_print_date($propal->date,'%a %d %B %Y');

View File

@ -30,6 +30,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php');
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
@ -121,37 +122,9 @@ if ($_GET["propalid"] > 0)
$propal = new Propal($db);
$propal->fetch($_GET["propalid"]);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$hselected=$h;
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal'));
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'compta', $langs->trans('Proposal'));
/*
@ -182,17 +155,7 @@ if ($_GET["propalid"] > 0)
$rowspan=9;
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">';
if ($societe->client == 1)
{
$url ='fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';

View File

@ -450,13 +450,13 @@ class Form
}
/**
* \brief Retourne la liste déroulante des sociétés
* \param selected Societe présélectionnée
* \param htmlname Nom champ formulaire
* \param filter Criteres optionnels de filtre
*/
function select_societes($selected='',$htmlname='soc_id',$filter='')
/**
* \brief Retourne la liste déroulante des sociétés
* \param selected Societe présélectionnée
* \param htmlname Nom champ formulaire
* \param filter Criteres optionnels de filtre
*/
function select_societes($selected='',$htmlname='soc_id',$filter='')
{
// On recherche les societes
$sql = "SELECT s.idp, s.nom FROM";
@ -494,6 +494,54 @@ class Form
}
/**
* \brief Retourne la liste déroulante des remises fixes
* \param selected Id remise fixe présélectionnée
* \param htmlname Nom champ formulaire
* \param filter Criteres optionnels de filtre
*/
function select_remises($selected='',$htmlname='remise_id',$filter='',$socid)
{
global $langs,$conf;
// On recherche les societes
$sql = "SELECT re.rowid, re.amount_ht as amount, re.description FROM";
$sql.= " ".MAIN_DB_PREFIX ."societe_remise_except as re";
$sql.= " WHERE fk_soc = ".$socid;
if ($filter) $sql.= " AND $filter";
$sql.= " ORDER BY re.description ASC";
$resql=$this->db->query($sql);
if ($resql)
{
print '<select class="flat" name="'.$htmlname.'">';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
print '<option value="0">&nbsp;</option>';
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($selected > 0 && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">'.dolibarr_trunc($obj->description,40).' ('.$obj->amount.' '.$langs->trans("Currency".$conf->monnaie).')'.'</option>';
}
else
{
print '<option value="'.$obj->rowid.'">'.dolibarr_trunc($obj->description,40).' ('.$obj->amount.' '.$langs->trans("Currency".$conf->monnaie).')'.'</option>';
}
$i++;
}
}
print '</select>';
}
else {
dolibarr_print_error($this->db);
}
}
/**
* \brief Retourne la liste déroulante des contacts d'une société donnée
* \param socid Id de la société
@ -1588,23 +1636,24 @@ class Form
/**
* \brief Affiche formulaire de selection de la remise avoir
* \brief Affiche formulaire de selection de la remise fixe
* \param page Page
* \param selected Valeur à appliquer
* \param htmlname Nom du formulaire select. Si none, non modifiable
*/
function form_remise($page, $selected='', $htmlname='remise')
function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid)
{
global $langs;
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setremise">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<input type="hidden" name="action" value="setabsolutediscount">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print '<input type="text" name="'.$htmlname.'" size="1" value="'.$selected.'">';
print $langs->trans("AvailableGlobalDiscounts").': ';
print $this->select_remises('',$htmlname,'fk_facture IS NULL',$socid);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("UseDiscount").'"></td>';
print '</tr></table></form>';
}
else

View File

@ -82,6 +82,8 @@ CompanyHasAbsoluteDiscount=This customer has a %s %s discount credit
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users)
CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself)
DefaultDiscount=Default discount
AvailableGlobalDiscounts=Absolute discounts available
DiscountNone=None
Supplier=Supplier
CompanyList=Companies' list

View File

@ -83,6 +83,7 @@ CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remises fixes disponib
CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur)
CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement)
DefaultDiscount=Remise par défaut
AvailableGlobalDiscounts=Remises fixes disponibles
DiscountNone=Aucune
Supplier=Fournisseur
CompanyList=Liste des sociétés

View File

@ -532,6 +532,27 @@ function dolibarr_trunc($string,$size=40)
return $string;
}
/**
\brief Complète une chaine à une taille donnée par des espaces
\param string Chaine à compléter
\param size Longueur de la chaine.
\param side 0=Complétion à droite, 1=Complétion à gauche
\param char Chaine de complétion
\return string Chaine complétée
*/
function dolibarr_pad($string,$size,$side,$char=' ')
{
$taille=sizeof($string);
$i=0;
while($i < ($size - $taille))
{
if ($side > 0) $string.=$char;
else $string=$char.$string;
$i++;
}
return $string;
}
/**
\brief Affiche picto propre à une notion/module (fonction générique)
\param alt Texte sur le alt de l'image