diff --git a/ChangeLog b/ChangeLog index cc29d46bd26..5fdc485df86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -43,7 +43,7 @@ For users: - Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action - Fix: [ bug #1506, #1507 ] ECM trigger error problem - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message -- New: [ task #1204 ] add a External reference to contract +- New: [ task #1204 ] add a Supplier reference to contract For translators: - Update language files. diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7e5af441280..9b0e236af35 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -593,6 +593,8 @@ class Facture extends CommonInvoice // Load source object $objFrom = dol_clone($this); + + // Change socid if needed if (! empty($socid) && $socid != $this->socid) @@ -635,10 +637,22 @@ class Facture extends CommonInvoice unset($this->products[$i]); // Tant que products encore utilise } } - + // Create clone $result=$this->create($user); if ($result < 0) $error++; + else { + // copy internal contacts + if ($this->copy_linked_contact($objFrom, 'internal') < 0) + $error++; + + // copy external contacts if same company + elseif ($objFrom->socid == $this->socid) + { + if ($this->copy_linked_contact($objFrom, 'external') < 0) + $error++; + } + } if (! $error) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9c57ff9f570..66de1e3eaa7 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -44,7 +44,7 @@ class Contrat extends CommonObject var $id; var $ref; - var $ref_ext; + var $ref_supplier; var $socid; var $societe; // Objet societe var $statut=0; // 0=Draft, @@ -400,7 +400,7 @@ class Contrat extends CommonObject $sql.= " fk_projet,"; $sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " note_private, note_public, extraparams"; - $sql.= " ,ref_ext"; + $sql.= " ,ref_supplier"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; if ($ref) { @@ -419,7 +419,7 @@ class Contrat extends CommonObject { $this->id = $result["rowid"]; $this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"]; - $this->ref_ext = $result["ref_ext"]; + $this->ref_supplier = $result["ref_supplier"]; $this->statut = $result["statut"]; $this->mise_en_service = $this->db->jdate($result["datemise"]); $this->date_contrat = $this->db->jdate($result["datecontrat"]); @@ -720,7 +720,7 @@ class Contrat extends CommonObject // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity, note_private, note_public, ref_ext)"; + $sql.= " ref, entity, note_private, note_public, ref_supplier)"; $sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; $sql.= ", '".$this->db->idate($this->date_contrat)."'"; $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); @@ -730,7 +730,7 @@ class Contrat extends CommonObject $sql.= ", ".$conf->entity; $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); + $sql.= ", ".(!empty($this->ref_supplier)?("'".$this->db->escape($this->ref_supplier)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); if ($resql) @@ -965,7 +965,7 @@ class Contrat extends CommonObject // Clean parameters if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext); + if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); if (isset($this->entity)) $this->entity=trim($this->entity); if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->fk_soc)) $this->fk_soc=trim($this->fk_soc); @@ -988,7 +988,7 @@ class Contrat extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").","; + $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; $sql.= " entity=".$conf->entity.","; $sql.= " date_contrat=".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; $sql.= " statut=".(isset($this->statut)?$this->statut:"null").","; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index e073566c55f..708ee6e59d9 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -206,7 +206,7 @@ if ($action == 'add' && $user->rights->contrat->creer) $object->fk_project = GETPOST('projectid','int'); $object->remise_percent = GETPOST('remise_percent','alpha'); $object->ref = GETPOST('ref','alpha'); - $object->ref_ext = GETPOST('ref_ext','alpha'); + $object->ref_supplier = GETPOST('ref_supplier','alpha'); // If creation from another object of another module (Example: origin=propal, originid=1) if ($_POST['origin'] && $_POST['originid']) @@ -713,17 +713,17 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra $action = 'edit_extras'; setEventMessage($object->error,'errors'); } -} elseif ($action=='setref_ext') { +} elseif ($action=='setref_supplier') { $result = $object->fetch($id); if ($result < 0) { setEventMessage($object->errors,'errors'); } - $object->ref_ext=GETPOST('ref_ext','alpha'); + $object->ref_supplier=GETPOST('ref_supplier','alpha'); $result = $object->update($user); if ($result < 0) { setEventMessage($object->errors,'errors'); - $action='editref_ext'; + $action='editref_supplier'; } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -878,7 +878,7 @@ if ($action == 'create') // Ref Int print '