Fix missing transaction in update_perso function
This commit is contained in:
parent
cc21909909
commit
75b909ce93
@ -474,13 +474,16 @@ class Contact extends CommonObject
|
||||
*
|
||||
* @param int $id Id of contact
|
||||
* @param User $user User asking to change alert or birthday
|
||||
* @param int $notrigger 0=no, 1=yes
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function update_perso($id, $user=null)
|
||||
function update_perso($id, $user=null, $notrigger=0)
|
||||
{
|
||||
$error=0;
|
||||
$result=false;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Mis a jour contact
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET";
|
||||
$sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
|
||||
@ -531,6 +534,26 @@ class Contact extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('CONTACT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -$error;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -135,11 +135,9 @@ $object->fetch($id, $user);
|
||||
|
||||
$head = contact_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'perso', $title, 0, 'contact');
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
|
||||
@ -148,6 +146,8 @@ if ($action == 'edit')
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
dol_fiche_head($head, 'perso', $title, 0, 'contact');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
@ -213,8 +213,10 @@ if ($action == 'edit')
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print "</table><br>";
|
||||
print "</table>";
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
@ -227,6 +229,8 @@ else
|
||||
{
|
||||
// View mode
|
||||
|
||||
dol_fiche_head($head, 'perso', $title, 0, 'contact');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '');
|
||||
@ -285,16 +289,17 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.$langs->trans("Unknown")."</td>";
|
||||
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3"></td>';
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
if ($action != 'edit')
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user