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 ''.$langs->trans('RefCustomer').''; - print ''; + print ''; // Customer print ''; @@ -1069,9 +1069,9 @@ else print ''; print ''; - print $form->editfieldkey("RefCustomer",'ref_ext',$object->ref_ext,$object,$user->rights->contrat->creer); + print $form->editfieldkey("RefCustomer",'ref_supplier',$object->ref_supplier,$object,$user->rights->contrat->creer); print ''; - print $form->editfieldval("RefCustomer",'ref_ext',$object->ref_ext,$object,$user->rights->contrat->creer); + print $form->editfieldval("RefCustomer",'ref_supplier',$object->ref_supplier,$object,$user->rights->contrat->creer); print ''; print ''; diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 16586b9dd4c..985f8c5a04f 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -42,7 +42,7 @@ $offset = $limit * $page ; $search_nom=GETPOST('search_nom'); $search_contract=GETPOST('search_contract'); -$search_ref_ext=GETPOST('search_ref_ext','alpha'); +$search_ref_supplier=GETPOST('search_ref_supplier','alpha'); $sall=GETPOST('sall'); $statut=GETPOST('statut')?GETPOST('statut'):1; $socid=GETPOST('socid'); @@ -75,7 +75,7 @@ $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND $sql.= ' SUM('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,'; $sql.= " c.rowid as cid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid as socid"; -$sql.= " ,c.ref_ext"; +$sql.= " ,c.ref_supplier"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; @@ -90,8 +90,8 @@ if ($search_nom) { if ($search_contract) { $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); } -if (!empty($search_ref_ext)) { - $sql .= natural_search(array('c.ref_ext'), $search_ref_ext); +if (!empty($search_ref_supplier)) { + $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); } if ($sall) { $sql .= natural_search(array('s.nom', 'cd.label', 'cd.description'), $sall); @@ -114,9 +114,9 @@ if ($resql) print ''; $param='&search_contract='.$search_contract; $param.='&search_nom='.$search_nom; - $param.='&search_ref_ext='.$search_ref_ext; + $param.='&search_ref_supplier='.$search_ref_supplier; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RefCustomer"), $_SERVER["PHP_SELF"], "c.ref_ext","","$param",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefCustomer"), $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","$param",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateContract"), $_SERVER["PHP_SELF"], "c.date_contrat","","$param",'align="center"',$sortfield,$sortorder); @@ -134,7 +134,7 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -156,7 +156,7 @@ if ($resql) print img_object($langs->trans("ShowContract"),"contract").' '.(isset($obj->ref) ? $obj->ref : $obj->cid) .''; if ($obj->nb_late) print img_warning($langs->trans("Late")); print ''; - print ''.$obj->ref_ext.''; + print ''.$obj->ref_supplier.''; print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; //print ''.dol_print_date($obj->datec).''; print ''.dol_print_date($db->jdate($obj->date_contrat)).''; diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 30e010431cc..1e3072876eb 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -121,4 +121,4 @@ create table llx_accounting_fiscalyear fk_user_modif integer NULL )ENGINE=innodb; -ALTER TABLE llx_contrat ADD COLUMN ref_ext varchar(30) after ref; +ALTER TABLE llx_contrat ADD COLUMN ref_supplier varchar(30) after ref; diff --git a/htdocs/install/mysql/tables/llx_contrat.sql b/htdocs/install/mysql/tables/llx_contrat.sql index 9cef8fddb42..496ecd4c97d 100644 --- a/htdocs/install/mysql/tables/llx_contrat.sql +++ b/htdocs/install/mysql/tables/llx_contrat.sql @@ -22,7 +22,7 @@ create table llx_contrat ( rowid integer AUTO_INCREMENT PRIMARY KEY, ref varchar(30), -- contrat reference - ref_ext varchar(30), -- external contract ref + ref_supplier varchar(30), -- suplier contract ref entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp, datec datetime, -- creation date