From c99f3d7d2649b57133111f5e62ecd49a06234630 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Sep 2007 02:09:43 +0000 Subject: [PATCH] Feature: Choix du destinataire (adresse tiers ou adresse contact propal) sur les propales. --- htdocs/admin/facture.php | 1 - htdocs/admin/propale.php | 51 ++++++++----- htdocs/commonobject.class.php | 5 +- .../modules/facture/pdf_crabe.modules.php | 69 ++++++++++++------ .../propale/pdf_propale_azur.modules.php | 72 ++++++++++++++----- htdocs/langs/en_US/propal.lang | 2 +- htdocs/langs/fr_FR/propal.lang | 1 + mysql/migration/2.1.0-2.2.0.sql | 9 ++- mysql/tables/llx_element_contact.key.sql | 10 ++- 9 files changed, 156 insertions(+), 64 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index c4b8be07e9e..8d2bfda24b6 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -550,7 +550,6 @@ print '' print "\n"; print ''; -// Active la possibilité d'éditer/supprimer une facture validée sans paiement $var=! $var; print '
'; print ''; diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 795f8ad59b6..1831d3f3662 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -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.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$propale); if ($nextval != $langs->trans("NotAvailable")) { - $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; + $htmltooltip.=''.$langs->trans("NextValue").': '.$nextval; } print ''; print $html->textwithhelp('',$htmltooltip,1,0); @@ -382,26 +393,16 @@ $var=true; print ""; print ""; print "\n"; -print "\n"; +print '\n"; print "\n"; print ""; -$var=!$var; -print ""; -print ""; -print ""; -print ''; -print ""; -print ''; -print ''; -print ''; - $var=!$var; print ""; print ""; print ""; print ''; -print ""; +print '"; print ''; print ''; print ''; @@ -411,7 +412,7 @@ print ""; print ""; print ""; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -421,11 +422,23 @@ print ""; print ""; print ""; print ''; -print ''; +print ''; print ''; print ''; print ''; +$var=! $var; +print ''; +print ''; +print '\n"; +print ''; + if ($conf->commande->enabled) { $var=!$var; @@ -433,7 +446,7 @@ if ($conf->commande->enabled) print ""; print ""; print ''; - print ""; print ''; diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index c0691e48b1a..72d3745c61a 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -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) { diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index b0df392c2b3..ab6c6057757 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -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); } } diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index d32e9fc6557..e4811be7288 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -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); + } } } diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 8fea3c85403..a9cbbe48cc6 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -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...) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 2fe3774e2bf..a92ae105dff 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -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...) \ No newline at end of file diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 0ae6d0e97d4..eb02409bcad 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -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; \ No newline at end of file +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); diff --git a/mysql/tables/llx_element_contact.key.sql b/mysql/tables/llx_element_contact.key.sql index d52a873b7da..506010213f1 100644 --- a/mysql/tables/llx_element_contact.key.sql +++ b/mysql/tables/llx_element_contact.key.sql @@ -1,5 +1,6 @@ -- ============================================================================ --- Copyright (C) 2005 patrick Rouillon +-- Copyright (C) 2005 patrick Rouillon +-- Copyright (C) 2007 Laurent Destailleur -- -- 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); + \ No newline at end of file
".$langs->trans("Parameter")."".$langs->trans("Value")."'.$langs->trans("Value")." 
'.$langs->trans("NumberOfProductLines").'global->PROPALE_NEW_FORM_NB_PRODUCT."\">
'.$langs->trans("DefaultProposalDurationValidity").'global->PROPALE_VALIDITY_DURATION."\">'."global->PROPALE_VALIDITY_DURATION."\">
'.$langs->trans("AddShippingDateAbility").''.$html->selectyesno('value',$conf->global->PROPALE_ADD_SHIPPING_DATE,1).''.$html->selectyesno('value',$conf->global->PROPALE_ADD_SHIPPING_DATE,1).'
'.$langs->trans("AddDeliveryAddressAbility").''.$html->selectyesno('value',$conf->global->PROPALE_ADD_DELIVERY_ADDRESS,1).''.$html->selectyesno('value',$conf->global->PROPALE_ADD_DELIVERY_ADDRESS,1).'
'; +print $langs->trans("UseCustomerContactAsPropalRecipientIfExist"); +print ''; +print $html->selectyesno("use_customer_contact_as_recipient",$conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1); +print ''; +print ''; +print "
'.$langs->trans("ClassifiedInvoicedWithOrder").'"; + print ''; print $html->selectyesno('value',$conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER,1); print "