Merge branch 'add_clone_on_event_agenda' of
https://github.com/atm-gauthier/dolibarr into atm-gauthier-add_clone_on_event_agenda Conflicts: htdocs/langs/en_US/agenda.lang
This commit is contained in:
commit
d3549cc2a0
@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
@ -57,6 +58,7 @@ $backtopage=GETPOST('backtopage','alpha');
|
||||
$contactid=GETPOST('contactid','int');
|
||||
$origin=GETPOST('origin','alpha');
|
||||
$originid=GETPOST('originid','int');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
$fulldayevent=GETPOST('fullday');
|
||||
$datep=dol_mktime($fulldayevent?'00':GETPOST("aphour"), $fulldayevent?'00':GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear"));
|
||||
@ -78,6 +80,10 @@ $contact = new Contact($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formactions = new FormActions($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
@ -129,6 +135,29 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
|
||||
if ($action == 'update') $action = 'edit';
|
||||
}
|
||||
|
||||
// Action clone object
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||
{
|
||||
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
|
||||
{
|
||||
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
$result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid'));
|
||||
if ($result > 0) {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
|
||||
exit();
|
||||
} else {
|
||||
setEventMessage($object->error, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add event
|
||||
if ($action == 'add')
|
||||
{
|
||||
@ -542,10 +571,6 @@ if ($action == 'mupdate')
|
||||
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
|
||||
llxHeader('',$langs->trans("Agenda"),$help_url);
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formactions = new FormActions($db);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
@ -1035,6 +1060,15 @@ if ($id > 0)
|
||||
{
|
||||
dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');
|
||||
|
||||
|
||||
// Clone event
|
||||
if($action == 'clone')
|
||||
{
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneAction', $object->label), 'confirm_clone', $formquestion, 'yes', 1);
|
||||
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
// Affichage fiche action en mode visu
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -1241,7 +1275,17 @@ if ($id > 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Modify").'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
if ($user->rights->agenda->allactions->create ||
|
||||
(($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=clone&object='.$object->element.'&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("ToClone").'</a></div>';
|
||||
}
|
||||
|
||||
if ($user->rights->agenda->allactions->delete ||
|
||||
(($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete))
|
||||
{
|
||||
|
||||
@ -391,6 +391,67 @@ class ActionComm extends CommonObject
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an object from its id and create a new one in database
|
||||
*
|
||||
* @param int $socid Id of thirdparty
|
||||
* @return int New id of clone
|
||||
*/
|
||||
function createFromClone()
|
||||
{
|
||||
global $db, $user,$langs,$conf,$hookmanager;
|
||||
|
||||
$this->context['createfromclone']='createfromclone';
|
||||
|
||||
$error=0;
|
||||
$now=dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$objFrom = dol_clone($this);
|
||||
|
||||
$this->fetch_optionals();
|
||||
$this->fetch_userassigned();
|
||||
|
||||
$this->id=0;
|
||||
|
||||
// Create clone
|
||||
$result=$this->add($user);
|
||||
if ($result < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Hook of thirdparty module
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('objFrom'=>$objFrom);
|
||||
$action='';
|
||||
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) $error++;
|
||||
}
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ACTION_CLONE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
unset($this->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object from database
|
||||
*
|
||||
|
||||
@ -95,3 +95,5 @@ AddEvent=Create event
|
||||
MyAvailability=My availability
|
||||
ActionType=Event type
|
||||
DateActionBegin=Start event date
|
||||
CloneAction=Clone event
|
||||
ConfirmCloneEvent=Are you sure you want to clone the event <b>%s</b> ?
|
||||
|
||||
@ -96,3 +96,5 @@ AddEvent=Créer un événement
|
||||
MyAvailability=Ma disponibilité
|
||||
ActionType=Type événement
|
||||
DateActionBegin=Date début événément
|
||||
CloneAction=Cloner événement
|
||||
ConfirmCloneAction=Êtes-vous sûr de vouloir cloner l'événement <b>%s</b> ?
|
||||
Loading…
Reference in New Issue
Block a user