Use contact if defined by default for address instead of third party.

This commit is contained in:
Laurent Destailleur 2009-06-14 17:48:08 +00:00
parent 8bb947486a
commit 3465ecad0f
11 changed files with 91 additions and 34 deletions

View File

@ -104,7 +104,7 @@ if ($_GET["action"] == 'del')
$sql.= " WHERE nom = '".$_GET["value"];
$sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
if ($db->query($sql))
{
@ -447,6 +447,7 @@ print '</form>';
*/
// Utiliser le contact de la commande dans le document
/*
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -457,6 +458,7 @@ print '<td width="60" align="center">'.$html->selectyesno("use_customer_contact_
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">';

View File

@ -597,6 +597,7 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
print "</td></tr>\n";
print '</form>';
/*
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -609,6 +610,7 @@ print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
*/
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';

View File

@ -435,6 +435,7 @@ print '<td align="right"><input type="submit" class="button" value="'.$langs->tr
print '</tr>';
print '</form>';
/*
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -447,6 +448,7 @@ 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)
{

View File

@ -347,13 +347,13 @@ class pdf_edison extends ModelePDFCommandes
}
function _pagehead(&$pdf, $com, $showaddress=1, $outputlangs)
function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
{
global $conf,$langs,$mysoc;
$langs->load("orders");
//Affiche le filigrane brouillon - Print Draft Watermark
if($com->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
{
$watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5;
@ -421,23 +421,75 @@ class pdf_edison extends ModelePDFCommandes
$pdf->MultiCell(80, 4, $carac_emetteur);
// Client destinataire
$client = new Societe($this->db);
$client->fetch($object->socid);
$object->client = $client;
// If CUSTOMER contact defined on invoice, we use it
$usecontact=false;
//if ($conf->global->COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT)
//{
$arrayidcontact=$object->getIdContact('external','CUSTOMER');
if (sizeof($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
//}
if ($usecontact)
{
// Nom societe
$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
// Customer name
$carac_client = "\n".$object->contact->getFullName($outputlangs,1,1);
// Customer properties
$carac_client.="\n".$outputlangs->convToOutputCharset($object->contact->address);
$carac_client.="\n".$outputlangs->convToOutputCharset($object->contact->cp) . " " . $outputlangs->convToOutputCharset($object->contact->ville)."\n";
if ($object->contact->pays_code != $this->emetteur->pays_code) $carac_client.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->contact->pays_code))."\n";
}
else
{
// Customer name
$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
// Nom du contact suivi commande si c'est une soci<63>t<EFBFBD>
$arrayidcontact = $object->getIdContact('external','CUSTOMER');
if (sizeof($arrayidcontact) > 0)
{
$object->fetch_contact($arrayidcontact[0]);
// On verifie si c'est une societe ou un particulier
if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) )
{
$carac_client .= "\n".$object->contact->getFullName($outputlangs,1,1);
}
}
// Caracteristiques client
$carac_client.="\n".$outputlangs->convToOutputCharset($object->client->adresse);
$carac_client.="\n".$outputlangs->convToOutputCharset($object->client->cp) . " " . $outputlangs->convToOutputCharset($object->client->ville)."\n";
if ($object->client->pays_code != $this->emetteur->pays_code) $carac_client.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->client->pays_code))."\n";
}
// Numero TVA intracom
if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($object->client->tva_intra);
// Show customer/recipient
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12);
$client = new Societe($this->db);
$client->fetch($com->socid);
$com->client = $client;
$pdf->SetXY(102,42);
$pdf->MultiCell(96, 5, $outputlangs->convToOutputCharset($com->client->nom));
$pdf->MultiCell(96, 5, $carac_client_name);
$pdf->SetFont('Arial','',11);
$pdf->SetXY(102,$pdf->GetY());
$pdf->MultiCell(96, 5, $outputlangs->convToOutputCharset($com->client->adresse) . "\n" . $outputlangs->convToOutputCharset($com->client->cp) . " " . $outputlangs->convToOutputCharset($com->client->ville));
$pdf->rect(100, 40, 100, 40);
$pdf->MultiCell(96, 5, $carac_client);
$pdf->rect(100, 40, 100, 40);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',12);
$pdf->Text(11, 88, $outputlangs->transnoentities("Date")." : " . dol_print_date($com->date,'day',false,$outputlangs));
$pdf->Text(11, 94, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($com->ref));
$pdf->Text(11, 88, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs));
$pdf->Text(11, 94, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref));
}
/*

View File

@ -827,15 +827,15 @@ class pdf_einstein extends ModelePDFCommandes
// If CUSTOMER contact defined on invoice, we use it
$usecontact=false;
if ($conf->global->COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT)
{
//if ($conf->global->COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT)
//{
$arrayidcontact=$object->getIdContact('external','CUSTOMER');
if (sizeof($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
}
//}
if ($usecontact)
{

View File

@ -483,9 +483,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$object->fetch_client();
/**********************************/
//Emplacement Informations Destinataire
/**********************************/
// If SHIPPING contact defined on invoice, we use it
$usecontact=false;
//if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT)
//{

View File

@ -75,7 +75,8 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
*/
function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
{
global $conf;
global $conf,$langs,$mysoc;
$langs->load("orders");
if ($conf->barcode->enabled)
{

View File

@ -1104,15 +1104,15 @@ class pdf_crabe extends ModelePDFFactures
// If BILLING contact defined on invoice, we use it
$usecontact=false;
if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT)
{
//if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT)
//{
$arrayidcontact=$object->getIdContact('external','BILLING');
if (sizeof($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
}
//}
if ($usecontact)
{
// On peut utiliser le nom de la societe du contact

View File

@ -883,15 +883,15 @@ class pdf_oursin extends ModelePDFFactures
// If BILLING contact defined on invoice, we use it
$usecontact=false;
if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT)
{
//if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT)
//{
$arrayidcontact=$object->getIdContact('external','BILLING');
if (sizeof($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
}
//}
if ($usecontact)
{
// On peut utiliser le nom de la societe du contact facturation

View File

@ -897,19 +897,19 @@ class pdf_propale_azur extends ModelePDFPropales
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
// If BILLING contact defined, we use it
$pdf->SetTextColor(0,0,0);
// If CUSTOMER contact defined, we use it
$usecontact=false;
if ($conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT)
{
//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]);
}
}
//}
if ($usecontact)
{
// On peut utiliser le nom de la societe du contact

View File

@ -436,19 +436,19 @@ class pdf_propale_jaune extends ModelePDFPropales
$posy=39;
// If BILLING contact defined, we use it
$pdf->SetTextColor(0,0,0);
// If CUSTOMER contact defined, we use it
$usecontact=false;
if ($conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT)
{
//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]);
}
}
//}
if ($usecontact)
{
// Nom societe