[ task #1204 ] Add ref_int contract field
This commit is contained in:
parent
fb3392a7b2
commit
c7d31f4570
@ -26,6 +26,7 @@ For users:
|
||||
- Fix: [ bug #1494 ] CATEGORY_CREATE and CATEGORY_MODIFY triggers do not intercept trigger action
|
||||
- Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action
|
||||
- Fix: [ bug #1505, #1504] Project trigger problem
|
||||
- New: [ task #1204 ] add a ref_int contract field
|
||||
|
||||
For translators:
|
||||
- Update language files.
|
||||
|
||||
@ -44,6 +44,7 @@ class Contrat extends CommonObject
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $ref_int;
|
||||
var $socid;
|
||||
var $societe; // Objet societe
|
||||
var $statut=0; // 0=Draft,
|
||||
@ -399,6 +400,7 @@ class Contrat extends CommonObject
|
||||
$sql.= " fk_projet,";
|
||||
$sql.= " fk_commercial_signature, fk_commercial_suivi,";
|
||||
$sql.= " note_private, note_public, extraparams";
|
||||
$sql.= " ,ref_int";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
|
||||
if ($ref)
|
||||
{
|
||||
@ -417,6 +419,7 @@ class Contrat extends CommonObject
|
||||
{
|
||||
$this->id = $result["rowid"];
|
||||
$this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"];
|
||||
$this->ref_int = $result["ref_int"];
|
||||
$this->statut = $result["statut"];
|
||||
$this->mise_en_service = $this->db->jdate($result["datemise"]);
|
||||
$this->date_contrat = $this->db->jdate($result["datecontrat"]);
|
||||
@ -717,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)";
|
||||
$sql.= " ref, entity, note_private, note_public, ref_int)";
|
||||
$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");
|
||||
@ -727,6 +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_int)?("'".$this->db->escape($this->ref_int)."'"):"NULL");
|
||||
$sql.= ")";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -948,6 +952,102 @@ class Contrat extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user=0, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->ref)) $this->ref=trim($this->ref);
|
||||
if (isset($this->ref_int)) $this->ref_int=trim($this->ref_int);
|
||||
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);
|
||||
if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet);
|
||||
if (isset($this->fk_commercial_signature)) $this->fk_commercial_signature=trim($this->fk_commercial_signature);
|
||||
if (isset($this->fk_commercial_suivi)) $this->fk_commercial_suivi=trim($this->fk_commercial_suivi);
|
||||
if (isset($this->fk_user_mise_en_service)) $this->fk_user_mise_en_service=trim($this->fk_user_mise_en_service);
|
||||
if (isset($this->fk_user_cloture)) $this->fk_user_cloture=trim($this->fk_user_cloture);
|
||||
if (isset($this->note_private)) $this->note_private=trim($this->note_private);
|
||||
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
|
||||
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
|
||||
if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams);
|
||||
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add a control on parameters values
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET";
|
||||
|
||||
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
||||
$sql.= " ref_int=".(isset($this->ref_int)?"'".$this->db->escape($this->ref_int)."'":"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").",";
|
||||
$sql.= " mise_en_service=".(dol_strlen($this->mise_en_service)!=0 ? "'".$this->db->idate($this->mise_en_service)."'" : 'null').",";
|
||||
$sql.= " fin_validite=".(dol_strlen($this->fin_validite)!=0 ? "'".$this->db->idate($this->fin_validite)."'" : 'null').",";
|
||||
$sql.= " date_cloture=".(dol_strlen($this->date_cloture)!=0 ? "'".$this->db->idate($this->date_cloture)."'" : 'null').",";
|
||||
$sql.= " fk_soc=".(isset($this->fk_soc)?$this->fk_soc:"null").",";
|
||||
$sql.= " fk_projet=".(isset($this->fk_projet)?$this->fk_projet:"null").",";
|
||||
$sql.= " fk_commercial_signature=".(isset($this->fk_commercial_signature)?$this->fk_commercial_signature:"null").",";
|
||||
$sql.= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi)?$this->fk_commercial_suivi:"null").",";
|
||||
$sql.= " fk_user_mise_en_service=".(isset($this->fk_user_mise_en_service)?$this->fk_user_mise_en_service:"null").",";
|
||||
$sql.= " fk_user_cloture=".(isset($this->fk_user_cloture)?$this->fk_user_cloture:"null").",";
|
||||
$sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
|
||||
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
|
||||
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").",";
|
||||
$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null")."";
|
||||
|
||||
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -205,6 +205,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_int = GETPOST('ref_int','alpha');
|
||||
|
||||
// If creation from another object of another module (Example: origin=propal, originid=1)
|
||||
if ($_POST['origin'] && $_POST['originid'])
|
||||
@ -711,6 +712,21 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
|
||||
$action = 'edit_extras';
|
||||
setEventMessage($object->error,'errors');
|
||||
}
|
||||
} elseif ($action=='setref_int') {
|
||||
$result = $object->fetch($id);
|
||||
if ($result < 0) {
|
||||
setEventMessage($object->errors,'errors');
|
||||
}
|
||||
$object->ref_int=GETPOST('ref_int','alpha');
|
||||
|
||||
$result = $object->update($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($object->errors,'errors');
|
||||
$action='editref_int';
|
||||
} else {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer)
|
||||
@ -858,6 +874,10 @@ if ($action == 'create')
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>';
|
||||
|
||||
// Ref Int
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('InternalRef').'</td>';
|
||||
print '<td colspan="2"><input type="text" siez="5" name="ref_int" id="ref_int" value="'.GETPOST('ref_int','alpha').'"></td></tr>';
|
||||
|
||||
// Customer
|
||||
print '<tr>';
|
||||
@ -1046,6 +1066,14 @@ else
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr>';
|
||||
print '<td width="20%">';
|
||||
print $form->editfieldkey("InternalRef",'ref_int',$object->ref_int,$object,$user->rights->contrat->creer);
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("InternalRef",'ref_int',$object->ref_int,$object,$user->rights->contrat->creer);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
||||
|
||||
@ -40,6 +40,7 @@ $offset = $limit * $page ;
|
||||
|
||||
$search_nom=GETPOST('search_nom');
|
||||
$search_contract=GETPOST('search_contract');
|
||||
$search_ref_int=GETPOST('search_ref_int','alpha');
|
||||
$sall=GETPOST('sall');
|
||||
$statut=GETPOST('statut')?GETPOST('statut'):1;
|
||||
$socid=GETPOST('socid');
|
||||
@ -72,6 +73,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_int";
|
||||
$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";
|
||||
@ -86,6 +88,9 @@ if ($search_nom) {
|
||||
if ($search_contract) {
|
||||
$sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);
|
||||
}
|
||||
if (!empty($search_ref_int)) {
|
||||
$sql .= natural_search(array('c.ref_int'), $search_ref_int);
|
||||
}
|
||||
if ($sall) {
|
||||
$sql .= natural_search(array('s.nom', 'cd.label', 'cd.description'), $sall);
|
||||
}
|
||||
@ -107,7 +112,9 @@ if ($resql)
|
||||
print '<tr class="liste_titre">';
|
||||
$param='&search_contract='.$search_contract;
|
||||
$param.='&search_nom='.$search_nom;
|
||||
$param.='&search_ref_int='.$search_ref_int;
|
||||
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("InternalRef"), $_SERVER["PHP_SELF"], "c.ref_int","","$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);
|
||||
@ -125,6 +132,9 @@ 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_int" value="'.$search_ref_int.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" class="flat" size="24" name="search_nom" value="'.$search_nom.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
@ -144,6 +154,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_int.'</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>';
|
||||
|
||||
@ -113,3 +113,4 @@ create table llx_accounting_fiscalyear
|
||||
fk_user_modif integer NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_contrat ADD COLUMN ref_int varchar(30) after ref;
|
||||
@ -20,11 +20,12 @@
|
||||
|
||||
create table llx_contrat
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
ref varchar(30), -- reference de contrat
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
ref varchar(30), -- contrat reference
|
||||
ref_int varchar(30), -- internal contract ref
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
tms timestamp,
|
||||
datec datetime, -- date de creation de l enregistrement
|
||||
datec datetime, -- creation date
|
||||
date_contrat datetime,
|
||||
statut smallint DEFAULT 0,
|
||||
mise_en_service datetime,
|
||||
@ -40,7 +41,7 @@ create table llx_contrat
|
||||
note_private text,
|
||||
note_public text,
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for stock other parameters with json format
|
||||
|
||||
extraparams varchar(255)
|
||||
|
||||
)ENGINE=innodb;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user