Skip to content
Snippets Groups Projects
Commit 85f0d6c3 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Edition of event

parent bb852592
Branches
Tags
No related merge requests found
......@@ -170,7 +170,7 @@ if ($action == 'add')
}
// Initialisation objet cactioncomm
if (! GETPOST('actioncode') > 0)
if (! GETPOST('actioncode') > 0) // actioncode is id
{
$error++; $donotclearsession=1;
$action = 'create';
......@@ -178,12 +178,12 @@ if ($action == 'add')
}
else
{
$result=$cactioncomm->fetch(GETPOST('actioncode'));
$object->type_code = GETPOST('actioncode');
}
if (! $error)
{
// Initialisation objet actioncomm
$object->type_id = $cactioncomm->id;
$object->type_code = $cactioncomm->code;
$object->priority = GETPOST("priority")?GETPOST("priority"):0;
$object->fulldayevent = (! empty($fulldayevent)?1:0);
$object->location = GETPOST("location");
......@@ -232,8 +232,9 @@ if ($action == 'add')
$i++;
}
}
if (! empty($conf->global->AGENDA_ENABLE_DONEBY))
if (! $error && ! empty($conf->global->AGENDA_ENABLE_DONEBY))
{
$userdone=new User($db);
if ($_POST["doneby"] > 0)
......@@ -250,10 +251,10 @@ if ($action == 'add')
if (GETPOST('socid','int') > 0)
{
$societe = new Societe($db);
$societe->fetch(GETPOST('socid','int'));
$object->societe = $societe; // deprecated
$object->thirdparty = $societe;
$object->socid=GETPOST('socid','int');
$object->fetch_thirdparty();
$object->societe = $object->thirdparty; // For backward compatibility
}
// Special for module webcal and phenix
......@@ -607,6 +608,7 @@ if ($action == 'create')
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="donotclearsession" value="1">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) print '<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db, 'AC_OTH', 'c_actioncomm').'">';
if (GETPOST("actioncode") == 'AC_RDV') print_fiche_titre($langs->trans("AddActionRendezVous"));
else print_fiche_titre($langs->trans("AddAnAction"));
......@@ -620,7 +622,6 @@ if ($action == 'create')
$formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
print '</td></tr>';
}
else print '<input type="hidden" name="actioncode" value="AC_OTH">';
// Title
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td><input type="text" id="label" name="label" size="60" value="'.GETPOST('label').'"></td></tr>';
......@@ -864,6 +865,7 @@ if ($id > 0)
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="ref_ext" value="'.$object->ref_ext.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1'? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">';
dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');
......@@ -879,7 +881,6 @@ if ($id > 0)
$formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
print '</td></tr>';
}
else print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">';
// Title
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" size="50" value="'.$object->label.'"></td></tr>';
......
......@@ -108,7 +108,8 @@ class ActionComm extends CommonObject
}
/**
* Add an action/event into database
* Add an action/event into database.
* $this->type_id OR $this->type_code must be set.
*
* @param User $user Object user making action
* @param int $notrigger 1 = disable triggers, 0 = enable triggers
......@@ -144,20 +145,22 @@ class ActionComm extends CommonObject
$userownerid=isset($this->usertodo->id)?$this->usertodo->id:$this->userownerid; // For backward compatibility
$userdoneid=isset($this->userdone->id)?$this->userdone->id:$this->userdoneid; // For backward compatibility
if (! $this->type_id && $this->type_code)
if (! $this->type_id || ! $this->type_code)
{
$key=empty($this->type_id)?$this->type_code:$this->type_id;
// Get id from code
$cactioncomm=new CActionComm($this->db);
$result=$cactioncomm->fetch($this->type_code);
$result=$cactioncomm->fetch($key);
if ($result > 0)
{
$this->type_id=$cactioncomm->id;
$this->code=$cactioncomm->code;
$this->type_code=$cactioncomm->code;
}
else if ($result == 0)
{
$this->error='Failed to get record with code '.$this->type_code.' from dictionary "type of events"';
$this->error='Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"';
return -1;
}
else
......@@ -201,7 +204,7 @@ class ActionComm extends CommonObject
$sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").",";
$sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; // deprecated
$sql.= (isset($this->type_id)?$this->type_id:"null").",";
$sql.= (isset($this->code)?" '".$this->code."'":"null").",";
$sql.= (isset($this->type_code)?" '".$this->type_code."'":"null").",";
$sql.= (isset($this->socid) && $this->socid > 0?" '".$this->socid."'":"null").",";
$sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").",";
$sql.= " '".$this->db->escape($this->note)."',";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment