Remane contract ref_ext to ref_supplier

This commit is contained in:
Florian HENRY 2014-07-21 08:36:59 +02:00
parent 7ac4a6f43c
commit cf63f1a40d
7 changed files with 40 additions and 26 deletions

View File

@ -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.

View File

@ -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)
{

View File

@ -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").",";

View File

@ -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 '<tr><td>'.$langs->trans('RefCustomer').'</td>';
print '<td colspan="2"><input type="text" siez="5" name="ref_ext" id="ref_ext" value="'.GETPOST('ref_ext','alpha').'"></td></tr>';
print '<td colspan="2"><input type="text" siez="5" name="ref_supplier" id="ref_supplier" value="'.GETPOST('ref_supplier','alpha').'"></td></tr>';
// Customer
print '<tr>';
@ -1069,9 +1069,9 @@ else
print '<tr>';
print '<td width="20%">';
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 '</td><td>';
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 '</td>';
print '</tr>';

View File

@ -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 '<tr class="liste_titre">';
$param='&amp;search_contract='.$search_contract;
$param.='&amp;search_nom='.$search_nom;
$param.='&amp;search_ref_ext='.$search_ref_ext;
$param.='&amp;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 '<input type="text" class="flat" size="3" name="search_contract" value="'.$search_contract.'">';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="7" name="search_ref_ext" value="'.$search_ref_ext.'">';
print '<input type="text" class="flat" size="7" name="search_ref_supplier" value="'.$search_ref_supplier.'">';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="24" name="search_nom" value="'.$search_nom.'">';
@ -156,7 +156,7 @@ if ($resql)
print img_object($langs->trans("ShowContract"),"contract").' '.(isset($obj->ref) ? $obj->ref : $obj->cid) .'</a>';
if ($obj->nb_late) print img_warning($langs->trans("Late"));
print '</td>';
print '<td>'.$obj->ref_ext.'</td>';
print '<td>'.$obj->ref_supplier.'</td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
//print '<td align="center">'.dol_print_date($obj->datec).'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->date_contrat)).'</td>';

View File

@ -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;

View File

@ -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