/** * Get ActionComm * * @param array $authentication Array of authentication information * @param int $id Id of object * @return mixed */ function getActionComm($authentication, $id) { global $db, $conf, $langs; dol_syslog("Function: getActionComm login="******" id=" . $id); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } // Init and check authentication $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters if ($error || !$id) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } if (!$error) { $fuser->getrights(); if ($fuser->rights->agenda->allactions->read) { $actioncomm = new ActionComm($db); $result = $actioncomm->fetch($id); if ($result > 0) { $actioncomm_result_fields = array('id' => $actioncomm->id, 'ref' => $actioncomm->ref, 'ref_ext' => $actioncomm->ref_ext, 'type_id' => $actioncomm->type_id, 'type_code' => $actioncomm->type_code, 'type' => $actioncomm->type, 'label' => $actioncomm->label, 'datep' => dol_print_date($actioncomm->datep, 'dayhourrfc'), 'datef' => dol_print_date($actioncomm->datef, 'dayhourrfc'), 'datec' => dol_print_date($actioncomm->datec, 'dayhourrfc'), 'datem' => dol_print_date($actioncomm->datem, 'dayhourrfc'), 'note' => $actioncomm->note, 'percentage' => $actioncomm->percentage, 'author' => $actioncomm->author->id, 'usermod' => $actioncomm->usermod->id, 'usertodo' => $actioncomm->usertodo->id, 'userdone' => $actioncomm->userdone->id, 'priority' => $actioncomm->priority, 'fulldayevent' => $actioncomm->fulldayevent, 'location' => $actioncomm->location, 'socid' => $actioncomm->societe->id, 'contactid' => $actioncomm->contact->id, 'projectid' => $actioncomm->fk_project, 'fk_element' => $actioncomm->fk_element, 'elementtype' => $actioncomm->elementtype); //Retreive all extrafield for actioncomm // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true); //Get extrafield values $actioncomm->fetch_optionals($actioncomm->id, $extralabels); foreach ($extrafields->attribute_label as $key => $label) { $actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_' . $key => $actioncomm->array_options['options_' . $key])); } // Create $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'actioncomm' => $actioncomm_result_fields); } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id=' . $id . ' nor ref=' . $ref . ' nor ref_ext=' . $ref_ext; } } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
/* * Actions */ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; /* * View */ $form = new Form($db); $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); if ($object->id > 0) { $result1 = $object->fetch($id); $result2 = $object->fetch_thirdparty(); $result3 = $object->fetch_contact(); $result4 = $object->fetch_userassigned(); $result5 = $object->fetch_optionals($id, $extralabels); if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { dol_print_error($db, $object->error); exit; } if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; } if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; } $author = new User($db);