';
+
+ // Ref
+ print ''.$langs->trans('Ref').' | '.$propal->ref_url.' |
';
+
+ $rowspan=9;
+
+ // Société
+ print ''.$langs->trans('Company').' | '.$societe->getNomUrl(1).' | ';
+ print '
';
- $rowspan=9;
-
- // Société
- print ''.$langs->trans('Company').' | ';
- if ($societe->client == 1)
- {
- $url ='fiche.php?socid='.$societe->id;
- }
- else
- {
- $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
- }
- print ''.$societe->nom.'';
- print ' | ';
- print '
';
-
// Ligne info remises tiers
- print ''.$langs->trans('Discounts').' | ';
+ print ' |
'.$langs->trans('Discounts').' | ';
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$societe->getCurrentDiscount();
@@ -623,56 +586,57 @@
{
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
print '.';
+// print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id);
}
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print ' |
';
-
- // Dates
- print ''.$langs->trans('Date').' | ';
- print dolibarr_print_date($propal->date,'%a %d %B %Y');
- print ' | ';
-
- if ($conf->projet->enabled) $rowspan++;
- if ($conf->global->PROPAL_ADD_SHIPPING_DATE) $rowspan++;
- if ($conf->global->PROPAL_ADD_DELIVERY_ADDRESS) $rowspan++;
-
- // Notes
- print ''.$langs->trans('NotePublic').' : '. nl2br($propal->note_public).' | ';
- print '
';
-
- // Date fin propal
- print '';
+
+ // Dates
+ print '
'.$langs->trans('Date').' | ';
+ print dolibarr_print_date($propal->date,'%a %d %B %Y');
+ print ' | ';
+
+ if ($conf->projet->enabled) $rowspan++;
+ if ($conf->global->PROPAL_ADD_SHIPPING_DATE) $rowspan++;
+ if ($conf->global->PROPAL_ADD_DELIVERY_ADDRESS) $rowspan++;
+
+ // Notes
+ print ''.$langs->trans('NotePublic').' : '. nl2br($propal->note_public).' | ';
+ print '
';
+
+ // Date fin propal
+ print '';
print '';
print '';
- print ' | ';
- if ($propal->brouillon && $_GET['action'] == 'editecheance')
- {
- print '';
- }
- else
- {
- if ($propal->fin_validite)
- {
- print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
- if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
- }
- else
- {
- print $langs->trans("Unknown");
- }
- }
- print ' | ';
- print '
';
-
-
+ print '';
+ if ($propal->brouillon && $_GET['action'] == 'editecheance')
+ {
+ print '';
+ }
+ else
+ {
+ if ($propal->fin_validite)
+ {
+ print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
+ if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
+ }
+ else
+ {
+ print $langs->trans("Unknown");
+ }
+ }
+ print ' | ';
+ print '';
+
+
// date de livraison (conditonné sur PROPAL_ADD_SHIPPING_DATE car carac à
// gérer par les commandes et non les propal
if ($conf->global->PROPAL_ADD_SHIPPING_DATE)
@@ -687,10 +651,10 @@
if ($_GET['action'] == 'editdate_livraison')
{
print '';
+ print '';
+ $html->select_date($propal->date_livraison,'liv_','','','',"editdate_livraison");
+ print '';
+ print '';
}
else
{
@@ -699,30 +663,30 @@
print '';
print '';
}
-
+
// adresse de livraison
if ($conf->global->PROPAL_ADD_DELIVERY_ADDRESS)
- {
- print '';
- print '';
- print ' | ';
-
- if ($_GET['action'] == 'editdelivery_adress')
- {
- $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'adresse_livraison_id','propal',$propal->id);
- }
- else
- {
- $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'none','propal',$propal->id);
- }
- print ' |
';
+ {
+ print '';
+ print '';
+ print ' | ';
+
+ if ($_GET['action'] == 'editdelivery_adress')
+ {
+ $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'adresse_livraison_id','propal',$propal->id);
+ }
+ else
+ {
+ $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'none','propal',$propal->id);
+ }
+ print ' |
';
}
-
+
// Conditions et modes de réglement
print '';
print ' ';
-
- /*
- * Lignes de propale
- *
- */
- print '';
-
- $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,';
- $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
- $sql.= ' p.description as product_desc';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
- $sql.= ' WHERE pt.fk_propal = '.$propal->id;
- $sql.= ' ORDER BY pt.rang ASC, pt.rowid';
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0; $total = 0;
-
- if ($num)
- {
- print '';
- print ''.$langs->trans('Description').' | ';
- print ''.$langs->trans('VAT').' | ';
- print ''.$langs->trans('PriceUHT').' | ';
- print ''.$langs->trans('Qty').' | ';
- print ''.$langs->trans('ReductionShort').' | ';
- print ''.$langs->trans('AmountHT').' | ';
- print ' | ';
- print ' | ';
+ if ($conf->projet->enabled)
+ {
+ $langs->load("projects");
+ print ' '.$langs->trans('Project').' | ';
+ $numprojet = $societe->has_projects();
+ if (! $numprojet)
+ {
+ print '';
+ print $langs->trans("NoProject").' | ';
+ print 'id.'&action=create>'.$langs->trans('AddProject').'';
+ print ' | ';
+ }
+ else
+ {
+ if ($propal->statut == 0 && $user->rights->propale->creer)
+ {
+ print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
+ }
+ else
+ {
+ if (!empty($propal->projetidp))
+ {
+ print '';
+ $proj = new Project($db);
+ $proj->fetch($propal->projetidp);
+ print '';
+ print $proj->title;
+ print '';
+ print ' | ';
+ }
+ else {
+ print ' | ';
+ }
+ }
+ }
+ print ' ';
+ }
+
+ // Amount
+ print ''.$langs->trans('AmountHT').' | ';
+ print ''.price($propal->price).' | ';
+ print ''.$langs->trans("Currency".$conf->monnaie).' | ';
+
+ print ''.$langs->trans('AmountVAT').' | '.price($propal->total_tva).' | ';
+ print ''.$langs->trans("Currency".$conf->monnaie).' | ';
+ print ''.$langs->trans('AmountTTC').' | '.price($propal->total_ttc).' | ';
+ print ''.$langs->trans("Currency".$conf->monnaie).' | ';
+
+ // Statut
+ print ''.$langs->trans('Status').' | '.$propal->getLibStatut(4).' | ';
+ print ' ';
+
+ /*
+ * Lignes de propale
+ *
+ */
+ print '';
+
+ $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,';
+ $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
+ $sql.= ' p.description as product_desc';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
+ $sql.= ' WHERE pt.fk_propal = '.$propal->id;
+ $sql.= ' ORDER BY pt.rang ASC, pt.rowid';
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0; $total = 0;
+
+ if ($num)
+ {
+ print '';
+ print ''.$langs->trans('Description').' | ';
+ print ''.$langs->trans('VAT').' | ';
+ print ''.$langs->trans('PriceUHT').' | ';
+ print ''.$langs->trans('Qty').' | ';
+ print ''.$langs->trans('ReductionShort').' | ';
+ print ''.$langs->trans('AmountHT').' | ';
print ' | ';
- print " \n";
- }
- $var=true;
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
- $var=!$var;
-
- // Ligne en mode visu
- if ($_GET['action'] != 'editline' || $_GET['ligne'] != $objp->rowid)
- {
- print '';
- if ($objp->fk_product > 0)
- {
- print '';
- if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
- else print img_object($langs->trans('ShowProduct'),'product');
- print ' '.$objp->ref.'';
- print ' - '.nl2br(stripslashes($objp->product));
-
- if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
- {
- print ' '.nl2br(stripslashes($objp->product_desc));
- }
-
- if ($objp->date_start && $objp->date_end)
- {
- print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
- }
- if ($objp->date_start && ! $objp->date_end)
- {
- print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
- }
- if (! $objp->date_start && $objp->date_end)
- {
- print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
- }
- print ($objp->description && $objp->description!=$objp->product)?' '.stripslashes(nl2br($objp->description)):'';
- print ' | ';
- }
- else
- {
- print ''.stripslashes(nl2br($objp->description));
- if ($objp->date_start && $objp->date_end)
- {
- print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
- }
- if ($objp->date_start && ! $objp->date_end)
- {
- print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
- }
- if (! $objp->date_start && $objp->date_end)
- {
- print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
- }
- print " | \n";
- }
- print ''.$objp->tva_tx.'% | ';
- print ''.price($objp->subprice)." | \n";
- print ''.$objp->qty.' | ';
- if ($objp->remise_percent > 0)
- {
- print ''.$objp->remise_percent."% | \n";
- }
- else
- {
- print ' | ';
- }
- print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)." | \n";
-
- // Icone d'edition et suppression
- if ($propal->statut == 0 && $user->rights->propale->creer)
- {
- print 'id.'&action=editline&ligne='.$objp->rowid.'">';
- print img_edit();
- print ' | ';
- print 'id.'&action=del_ligne&ligne='.$objp->rowid.'">';
- print img_delete();
- print ' | ';
- print '';
- if ($i > 0)
- {
- print 'id.'&action=up&rowid='.$objp->rowid.'">';
- print img_up();
- print '';
- }
- if ($i < $num-1)
- {
- print 'id.'&action=down&rowid='.$objp->rowid.'">';
- print img_down();
- print '';
- }
- print ' | ';
- }
- else
- {
- print ' | ';
- }
-
- print ' ';
- }
-
- // Ligne en mode update
- if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["ligne"] == $objp->rowid)
- {
- print '\n";
- }
-
- $total = $total + ($objp->qty * $objp->price);
- $i++;
- }
-
- $db->free($resql);
- }
- else
- {
- dolibarr_print_error($db);
- }
-
+ print "\n";
+ }
+
+ $total = $total + ($objp->qty * $objp->price);
+ $i++;
+ }
+
+ $db->free($resql);
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+
/*
- * Lignes de remise
- */
-
- // Réductions relatives (Remises-Ristournes-Rabbais)
-/* Une réduction doit s'appliquer obligatoirement sur des lignes de factures
+ * Lignes de remise
+ */
+
+ // Réductions relatives (Remises-Ristournes-Rabbais)
+ /* Une réduction doit s'appliquer obligatoirement sur des lignes de factures
$var=!$var;
print '';
-*/
+ */
- // Réductions absolues (Remises-Ristournes-Rabbais)
-/* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées
+ // Réductions absolues (Remises-Ristournes-Rabbais)
+ /* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées
$var=!$var;
print '';
+ */
+
+ /*
+ * Ajouter une ligne
+ */
+ if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline')
+ {
+ print '';
+ print ''.$langs->trans('Description').' | ';
+ print ''.$langs->trans('VAT').' | ';
+ print ''.$langs->trans('PriceUHT').' | ';
+ print ''.$langs->trans('Qty').' | ';
+ print ''.$langs->trans('ReductionShort').' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print " \n";
+
+ // Ajout produit produits/services personalisés
+ print '';
+
+ // Ajout de produits/services prédéfinis
+ if ($conf->produit->enabled)
{
+ print '';
}
- print ' | ';
}
- else
- {
- print ' | ';
- }
- print '';
- print '';
-*/
-
- /*
- * Ajouter une ligne
- */
- if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline')
- {
- print '';
- print ''.$langs->trans('Description').' | ';
- print ''.$langs->trans('VAT').' | ';
- print ''.$langs->trans('PriceUHT').' | ';
- print ''.$langs->trans('Qty').' | ';
- print ''.$langs->trans('ReductionShort').' | ';
- print ' | ';
- print ' | ';
- print ' | ';
- print ' | ';
- print " \n";
-
- // Ajout produit produits/services personalisés
- print '';
- // Ajout de produits/services prédéfinis
- if ($conf->produit->enabled)
- {
- print '';
- }
- }
+ print ' ';
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
- print ' |
';
- }
- }
- else
- {
- dolibarr_print_error($db);
- }
-
print '';
print "\n";
/*
- * Formulaire cloture (signé ou non)
- */
- if ($_GET['action'] == 'statut')
- {
- print '';
- print "';
print ''.$langs->trans('Ref').' | '.$propal->ref_url.' |
';
// Société
- print ''.$langs->trans('Company').' | ';
- if ($societe->client == 1)
- {
- $url ='fiche.php?socid='.$societe->id;
- }
- else
- {
- $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
- }
- print ''.$societe->nom.' | ';
- print '
';
+ print ''.$langs->trans('Company').' | '.$societe->getNomUrl(1).' |
';
+ // Ligne info remises tiers
+ print ''.$langs->trans('Discounts').' | ';
+ 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 ' |
';
+
// Date
print ''.$langs->trans('Date').' | ';
print dolibarr_print_date($propal->date,'%a %d %B %Y');
diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php
index 105c73b2b702e..f535d5daf6bb7 100644
--- a/htdocs/compta/propal.php
+++ b/htdocs/compta/propal.php
@@ -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 @@
$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 @@
$rowspan=9;
// Société
- print ' |
'.$langs->trans('Company').' | ';
- if ($societe->client == 1)
- {
- $url ='fiche.php?socid='.$societe->id;
- }
- else
- {
- $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
- }
- print ''.$societe->nom.' | ';
- print '
';
+ print ''.$langs->trans('Company').' | '.$societe->getNomUrl(1).' |
';
// Ligne info remises tiers
print ''.$langs->trans('Discounts').' | ';
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 1d56818a26398..0865827c189a1 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -450,13 +450,13 @@ function select_type_comptes_financiers($selected=1,$htmlname='type')
}
- /**
- * \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 @@ function select_societes($selected='',$htmlname='soc_id',$filter='')
}
+ /**
+ * \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 '';
+ }
+ 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 @@ function form_remise_percent($page, $selected='', $htmlname='remise_percent')
/**
- * \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 ' |