Feature: Choix du destinataire (adresse tiers ou adresse contact propal) sur les propales.

This commit is contained in:
Laurent Destailleur 2007-09-16 02:09:43 +00:00
parent b68ad5130b
commit c99f3d7d26
9 changed files with 156 additions and 64 deletions

View File

@ -550,7 +550,6 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
print "</td></tr>\n";
print '</form>';
// Active la possibilité d'éditer/supprimer une facture validée sans paiement
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="set_use_bill_contact_as_recipient">';

View File

@ -107,6 +107,16 @@ if ($_POST["action"] == 'setclassifiedinvoiced')
exit;
}
if ($_POST["action"] == 'set_use_customer_contact_as_recipient')
{
dolibarr_set_const($db, "PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT",$_POST["use_customer_contact_as_recipient"]);
Header("Location: propale.php");
exit;
}
if ($_GET["action"] == 'set')
{
$type='propal';
@ -233,12 +243,13 @@ if ($handle)
$propale=new Propal($db);
// Info
$htmltooltip='';
$nextval=$module->getNextValue($mysoc,$propale);
// Info
$htmltooltip='';
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
$nextval=$module->getNextValue($mysoc,$propale);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;
$htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;
}
print '<td align="center">';
print $html->textwithhelp('',$htmltooltip,1,0);
@ -382,26 +393,16 @@ $var=true;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>".$langs->trans("Parameter")."</td>\n";
print "<td align=\"left\">".$langs->trans("Value")."</td>\n";
print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
print "<td>&nbsp;</td>\n";
print "</tr>";
$var=!$var;
print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print "<input type=\"hidden\" name=\"action\" value=\"setnbprod\">";
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("NumberOfProductLines").'</td>';
print "<td align=\"left\"><input size=\"3\" class=\"flat\" type=\"text\" name=\"value\" value=\"".$conf->global->PROPALE_NEW_FORM_NB_PRODUCT."\"></td>";
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr>';
print '</form>';
$var=!$var;
print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print "<input type=\"hidden\" name=\"action\" value=\"setdefaultduration\">";
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("DefaultProposalDurationValidity").'</td>';
print "<td align=\"left\"><input size=\"3\" class=\"flat\" type=\"text\" name=\"value\" value=\"".$conf->global->PROPALE_VALIDITY_DURATION."\"></td>";
print '<td width="60" align="center">'."<input size=\"3\" class=\"flat\" type=\"text\" name=\"value\" value=\"".$conf->global->PROPALE_VALIDITY_DURATION."\"></td>";
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr>';
print '</form>';
@ -411,7 +412,7 @@ print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print "<input type=\"hidden\" name=\"action\" value=\"setaddshippingdate\">";
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("AddShippingDateAbility").'</td>';
print '<td>'.$html->selectyesno('value',$conf->global->PROPALE_ADD_SHIPPING_DATE,1).'</td>';
print '<td width="60" align="center">'.$html->selectyesno('value',$conf->global->PROPALE_ADD_SHIPPING_DATE,1).'</td>';
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr>';
print '</form>';
@ -421,11 +422,23 @@ print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print "<input type=\"hidden\" name=\"action\" value=\"setadddeliveryaddress\">";
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("AddDeliveryAddressAbility").'</td>';
print '<td>'.$html->selectyesno('value',$conf->global->PROPALE_ADD_DELIVERY_ADDRESS,1).'</td>';
print '<td width="60" align="center">'.$html->selectyesno('value',$conf->global->PROPALE_ADD_DELIVERY_ADDRESS,1).'</td>';
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr>';
print '</form>';
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="set_use_customer_contact_as_recipient">';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("UseCustomerContactAsPropalRecipientIfExist");
print '</td><td width="60" align="center">';
print $html->selectyesno("use_customer_contact_as_recipient",$conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
if ($conf->commande->enabled)
{
$var=!$var;
@ -433,7 +446,7 @@ if ($conf->commande->enabled)
print "<input type=\"hidden\" name=\"action\" value=\"setclassifiedinvoiced\">";
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("ClassifiedInvoicedWithOrder").'</td>';
print "<td align=\"left\">";
print '<td width="60" align="center">';
print $html->selectyesno('value',$conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER,1);
print "</td>";
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';

View File

@ -184,6 +184,7 @@ class CommonObject
if ($statut >= 0) $sql.= " AND ec.statut = '".$statut."'";
$sql.=" ORDER BY t.name ASC";
dolibarr_syslog("CommonObject::liste_contact sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
@ -281,7 +282,7 @@ class CommonObject
}
/**
* \brief Retourne id des contacts d'une source et d'un type donné
* \brief Retourne id des contacts d'une source et d'un type actif donné
* Exemple: contact client de facturation ('external', 'BILLING')
* Exemple: contact client de livraison ('external', 'SHIPPING')
* Exemple: contact interne suivi paiement ('internal', 'SALESREPFOLL')
@ -298,8 +299,10 @@ class CommonObject
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$this->element."'";
$sql.= " AND tc.source = '".$source."'";
$sql.= " AND tc.active = 1";
$sql.= " AND tc.code = '".$code."'";
dolibarr_syslog("CommonObject::getIdContact sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -1017,38 +1017,61 @@ class pdf_crabe extends ModelePDFFactures
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
// If invoice contact defined on invoice, we use it
$receiver=0;
// If BILLING contact defined on invoice, we use it
$usecontact=false;
if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT)
{
$arrayidcontact=$object->getIdContact('external','BILLING');
if (sizeof($arrayidcontact) > 0)
{
$idcontact=$arrayidcontact[0];
$result=$object->fetch_contact($idcontact);
if ($result > 0) $receiver=$object->contact;
$receiver=$object->contact;
$receiver->nom = $receiver->fullname;
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
}
if (! $receiver) $receiver=$object->client;
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $receiver->nom, 0, 'L');
// Caractéristiques client
$carac_client=$receiver->adresse;
$carac_client.="\n".$receiver->cp . " " . $receiver->ville."\n";
if ($this->emetteur->pays_code != $receiver->pays_code)
if ($usecontact)
{
$carac_client.=$receiver->pays."\n";
// Nom societe
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $object->client->nom, 0, 'L');
$posy+=4;
// Nom client
$pdf->SetXY(102,$posy+4);
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(106,4, $object->contact->nom, 0, 'L');
// Caractéristiques client
$carac_client=$object->contact->adresse;
$carac_client.="\n".$object->contact->cp . " " . $object->contact->ville."\n";
if ($this->emetteur->pays_code != $object->contact->pays_code)
{
$carac_client.=$object->contact->pays."\n";
}
if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
else
{
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $object->client->nom, 0, 'L');
// Caractéristiques client
$carac_client=$object->client->adresse;
$carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n";
if ($this->emetteur->pays_code != $object->client->pays_code)
{
$carac_client.=$object->client->pays."\n";
}
if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
if ($receiver->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$receiver->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
}

View File

@ -330,7 +330,7 @@ class pdf_propale_azur extends ModelePDFPropales
//on compte le nombre de ligne afin de vérifier la place disponible
$nblineFollowDesc = (num_lines($follow_descproduitservice)*4);
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
{
if ($pagenb == 1)
{
@ -892,22 +892,62 @@ class pdf_propale_azur extends ModelePDFPropales
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $object->client->nom, 0, 'L');
// If BILLING contact defined on invoice, we use it
$usecontact=false;
if ($conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT)
{
$arrayidcontact=$object->getIdContact('external','CUSTOMER');
if (sizeof($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
}
// Caractéristiques client
$carac_client=$object->client->adresse;
$carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n";
if ($this->emetteur->pays_code != $object->client->pays_code)
{
$carac_client.=$object->client->pays."\n";
}
if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
if ($usecontact)
{
// Nom societe
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $object->client->nom, 0, 'L');
$posy+=4;
// Nom client
$pdf->SetXY(102,$posy+4);
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(106,4, $object->contact->nom, 0, 'L');
// Caractéristiques client
$carac_client=$object->contact->adresse;
$carac_client.="\n".$object->contact->cp . " " . $object->contact->ville."\n";
if ($this->emetteur->pays_code != $object->contact->pays_code)
{
$carac_client.=$object->contact->pays."\n";
}
if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
else
{
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $object->client->nom, 0, 'L');
// Caractéristiques client
$carac_client=$object->client->adresse;
$carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n";
if ($this->emetteur->pays_code != $object->client->pays_code)
{
$carac_client.=$object->client->pays."\n";
}
if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
}
}

View File

@ -74,7 +74,7 @@ SetDateLivraison=Set shipping date
CopyPropalFrom=Create commercial proposal by copying existing proposal
CreateEmptyPropal=Create empty commercial proposals vierge or from list of products/services
DefaultProposalDurationValidity=Default commercial proposal validity duration (in days)
UseCustomerContactAsPropalRecipientIfExist=Use customer contact adress if defined instead of third party address as proposal recipient address
# azur PDF Model
PDFAzurDescription=A complete proposal model (logo...)

View File

@ -74,6 +74,7 @@ SetDateLivraison=D
CopyPropalFrom=Créer proposition/devis par recopie d'un proposition existante
CreateEmptyPropal=Créer proposition/devis vierge ou depuis liste de produits prédéfinis
DefaultProposalDurationValidity=Délai de validité par défaut (en jours)
UseCustomerContactAsPropalRecipientIfExist=Utiliser adresse contact suivi client si défini plutot que adresse tiers comme destinataire des propositions
# azur PDF Model
PDFAzurDescription=Modèle de propositions commerciales complet (logo...)

View File

@ -873,4 +873,11 @@ ALTER TABLE llx_product_fournisseur_price_log CHANGE fk_product fk_product_fourn
ALTER TABLE llx_commande_fournisseurdet MODIFY fk_commande integer NOT NULL;
ALTER TABLE llx_product ADD COLUMN partnumber varchar(32) after gencode;
ALTER TABLE llx_product ADD COLUMN partnumber varchar(32) after gencode;
-- Supprimme orphelins pour permettre montée de la clé
-- V4 DELETE llx_element_contact FROM llx_element_contact LEFT JOIN llx_socpeople ON llx_element_contact.fk_socpeople = llx_socpeople.rowid WHERE llx_socpeople.rowid IS NULL;
ALTER TABLE llx_element_contact ADD INDEX idx_element_contact_fk_socpeople (fk_socpeople);
ALTER TABLE llx_element_contact ADD CONSTRAINT fk_element_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople (rowid);

View File

@ -1,5 +1,6 @@
-- ============================================================================
-- Copyright (C) 2005 patrick Rouillon <patrick@rouillon.net>
-- Copyright (C) 2005 patrick Rouillon <patrick@rouillon.net>
-- Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -17,7 +18,6 @@
--
-- $Id$
-- $Source$
--
-- ============================================================================
@ -27,3 +27,9 @@ ALTER TABLE llx_element_contact
ALTER TABLE llx_element_contact
ADD CONSTRAINT fk_element_contact_fk_c_type_contact
FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid);
ALTER TABLE llx_element_contact ADD INDEX idx_element_contact_fk_socpeople (fk_socpeople);
ALTER TABLE llx_element_contact ADD CONSTRAINT fk_element_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople (rowid);