Resource fixes
This commit is contained in:
parent
6964f80d8f
commit
f3cd9da73d
@ -44,6 +44,7 @@ $id = GETPOST('id','int');
|
|||||||
$action = GETPOST('action','alpha');
|
$action = GETPOST('action','alpha');
|
||||||
$ref = GETPOST('ref');
|
$ref = GETPOST('ref');
|
||||||
$description = GETPOST('description');
|
$description = GETPOST('description');
|
||||||
|
$confirm = GETPOST('confirm');
|
||||||
$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
|
$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
@ -111,6 +112,29 @@ if (empty($reshook))
|
|||||||
$action='edit';
|
$action='edit';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && $confirm === 'yes')
|
||||||
|
{
|
||||||
|
$res = $object->fetch($id);
|
||||||
|
if($res > 0)
|
||||||
|
{
|
||||||
|
$result = $object->delete($id);
|
||||||
|
|
||||||
|
if ($result >= 0)
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans('RessourceSuccessfullyDeleted'));
|
||||||
|
Header('Location: '.DOL_URL_ROOT.'/resource/list.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setEventMessage($object->error,'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessage($object->error,'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ class Resource extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."resource(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
|
||||||
|
|
||||||
$sql.= " entity,";
|
$sql.= " entity,";
|
||||||
$sql.= "ref,";
|
$sql.= "ref,";
|
||||||
@ -114,7 +114,7 @@ class Resource extends CommonObject
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."place");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
||||||
|
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
@ -164,7 +164,7 @@ class Resource extends CommonObject
|
|||||||
$sql.= " t.note_private,";
|
$sql.= " t.note_private,";
|
||||||
$sql.= " t.tms,";
|
$sql.= " t.tms,";
|
||||||
$sql.= " ty.label as type_label";
|
$sql.= " ty.label as type_label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."resource as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
|
||||||
$sql.= " WHERE t.rowid = ".$this->db->escape($id);
|
$sql.= " WHERE t.rowid = ".$this->db->escape($id);
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class Resource extends CommonObject
|
|||||||
if (isset($this->description)) $this->description=trim($this->description);
|
if (isset($this->description)) $this->description=trim($this->description);
|
||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."resource SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
|
||||||
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
||||||
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
||||||
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
|
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
|
||||||
@ -340,7 +340,7 @@ class Resource extends CommonObject
|
|||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."resource";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||||
$sql.= " WHERE rowid =".$rowid;
|
$sql.= " WHERE rowid =".$rowid;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
@ -386,7 +386,7 @@ class Resource extends CommonObject
|
|||||||
$sql.= " t.fk_code_type_resource,";
|
$sql.= " t.fk_code_type_resource,";
|
||||||
$sql.= " t.tms,";
|
$sql.= " t.tms,";
|
||||||
$sql.= " ty.label as type_label";
|
$sql.= " ty.label as type_label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."resource as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
|
||||||
$sql.= " WHERE t.entity IN (".getEntity('resource',1).")";
|
$sql.= " WHERE t.entity IN (".getEntity('resource',1).")";
|
||||||
|
|
||||||
|
|||||||
@ -34,16 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
|||||||
$langs->load("resource");
|
$langs->load("resource");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
// Get parameters
|
|
||||||
$id = GETPOST('id','int');
|
|
||||||
$action = GETPOST('action','alpha');
|
|
||||||
$mode = GETPOST('mode','alpha');
|
|
||||||
$lineid = GETPOST('lineid','int');
|
|
||||||
$element = GETPOST('element','alpha');
|
|
||||||
$element_id = GETPOST('element_id','int');
|
|
||||||
$resource_id = GETPOST('resource_id','int');
|
|
||||||
$resource_type = GETPOST('resource_type','alpha');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$sortorder = GETPOST('sortorder','alpha');
|
$sortorder = GETPOST('sortorder','alpha');
|
||||||
$sortfield = GETPOST('sortfield','alpha');
|
$sortfield = GETPOST('sortfield','alpha');
|
||||||
@ -80,7 +70,11 @@ $confirm = GETPOST('confirm','alpha');
|
|||||||
if($action == 'add_element_resource' && ! $cancel)
|
if($action == 'add_element_resource' && ! $cancel)
|
||||||
{
|
{
|
||||||
$objstat = fetchObjectByElement($element_id,$element);
|
$objstat = fetchObjectByElement($element_id,$element);
|
||||||
$res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory);
|
$res = 0;
|
||||||
|
if ($resource_id >= 0)
|
||||||
|
{
|
||||||
|
$res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory);
|
||||||
|
}
|
||||||
if($res > 0)
|
if($res > 0)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
|
setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
|
||||||
@ -89,7 +83,7 @@ if($action == 'add_element_resource' && ! $cancel)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans('ErrorWhenLinkingResource'),'errors');
|
setEventMessage($langs->trans('ErrorWhenLinkingResource') . " " . $objstat->error, 'errors');
|
||||||
header("Location: ".$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_type.'&element='.$element.'&element_id='.$element_id);
|
header("Location: ".$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_type.'&element='.$element.'&element_id='.$element_id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -142,7 +136,7 @@ if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->dele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters=array('resource_id'=>resource_id);
|
$parameters=array('resource_id'=>$resource_id);
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
@ -254,7 +248,7 @@ else
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($object->available_resources as $modresources => $resources)
|
foreach ($object->available_resources as $modresources => $resources)
|
||||||
{
|
{
|
||||||
$resources=(array) $resources; // To be sure $resources is an array
|
$resources=(array) $resources; // To be sure $resources is an array
|
||||||
foreach($resources as $resource_obj)
|
foreach($resources as $resource_obj)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user