Presentation

This commit is contained in:
aspangaro 2014-11-23 21:03:34 +01:00
parent aa4f16ce99
commit aa8c165f06
5 changed files with 75 additions and 59 deletions

View File

@ -32,7 +32,7 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print '<div class="tagtd">'.$langs->trans('Resource').'</div>';
print '<div class="tagtd">'.$langs->trans('Busy').'</div>';
print '<div class="tagtd">'.$langs->trans('Mandatory').'</div>';
print '<div class="tagtd">'.$langs->trans('Edit').'</div>';
print '<div class="tagtd">'.$langs->trans('Action').'</div>';
print '</form>';
//print '</div>';
@ -86,8 +86,13 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print '</div>';
print '<div class="tagtd">';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'.$langs->trans('Delete').'</a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?mode=edit&resource_type='.$linked_resource['resource_type'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'.$langs->trans('Edit').'</a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?mode=edit&resource_type='.$linked_resource['resource_type'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">';
print img_delete();
print '</a>';
print '</div>';
print '</div>';
@ -105,4 +110,4 @@ else {
print '<div class="warning">'.$langs->trans('NoResourceLinked').'</div>';
}
// FIN DU TPL
// FIN DU TPL

View File

@ -32,7 +32,7 @@ if (! $res) die("Include of main fails");
require_once 'class/resource.class.php';
require_once 'class/html.formresource.class.php';
// Load traductions files requiredby by page
// Load traductions files required by page
$langs->load("resource");
$langs->load("companies");
$langs->load("other");
@ -41,6 +41,7 @@ $langs->load("resource@resource");
// Get parameters
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha');
if (empty($sortorder)) $sortorder="DESC";
if (empty($sortfield)) $sortfield="t.rowid";
if (empty($arch)) $arch = 0;
@ -65,57 +66,64 @@ $object = new Resource($db);
if ($action == 'confirm_add_resource')
{
$error='';
$ref=GETPOST('ref','alpha');
$description=GETPOST('description','alpha');
$fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
if (empty($ref))
if (! $cancel)
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
setEventMessage($mesg, 'errors');
$error++;
}
if (! $error)
{
$object=new Resource($db);
$object->ref=$ref;
$object->description=$description;
$object->fk_code_type_resource=$fk_code_type_resource;
$error='';
$result=$object->create($user);
if ($result > 0)
$ref=GETPOST('ref','alpha');
$description=GETPOST('description','alpha');
$fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
if (empty($ref))
{
// Creation OK
$db->commit();
setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
Header("Location: card.php?id=" . $object->id);
return;
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
setEventMessage($mesg, 'errors');
$error++;
}
if (! $error)
{
$object=new Resource($db);
$object->ref=$ref;
$object->description=$description;
$object->fk_code_type_resource=$fk_code_type_resource;
$result=$object->create($user);
if ($result > 0)
{
// Creation OK
$db->commit();
setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
Header("Location: card.php?id=" . $object->id);
return;
}
else
{
// Creation KO
setEventMessage($object->error, 'errors');
$action = '';
}
}
else
{
// Creation KO
setEventMessage($object->error, 'errors');
$action = '';
}
}
else
{
$action = '';
Header("Location: list.php");
}
}
/***************************************************
* VIEW
*
****************************************************/
/*
* View
*
*/
$form=new Form($db);
$formresource = new FormResource($db);
if ( !$action )
if (! $action)
{
$pagetitle=$langs->trans('AddResource');
llxHeader('',$pagetitle,'');
@ -161,8 +169,10 @@ if ( !$action )
print '</table>';
echo '<div style="text-align: center">',
' <input type="submit" class="button" name="" value="'.$langs->trans('Save').'" />',
echo '<br><div align="center">',
'<input type="submit" class="button" name="add" value="'.$langs->trans('Save').'" />',
'&nbsp;',
'<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" />',
'</div>';
print '</form>';

View File

@ -139,7 +139,7 @@ if ( $object->fetch($id) > 0 )
/*---------------------------------------
* Edit object
*/
*/
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
@ -171,7 +171,7 @@ if ( $object->fetch($id) > 0 )
}
else
{
// Confirmation suppression resource line
// Confirm deleting resource line
if ($action == 'delete')
{
print $form->formconfirm("card.php?&id=".$id,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResource"),"confirm_delete_resource",'','',1);
@ -228,9 +228,9 @@ if ( $object->fetch($id) > 0 )
print '</div>';
}
}
if ($action != "delete" )
if ($action != "delete" && $action != "edit")
{
// Edit resource
// Delete resource
if($user->rights->resource->delete)
{
print '<div class="inline-block divButAction">';

View File

@ -1,6 +1,5 @@
<?php
/* Module to manage locations, buildings, floors and rooms into Dolibarr ERP/CRM
* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
/* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,7 +31,7 @@ require 'class/resource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load traductions files requiredby by page
$langs->load("resource@resource");
$langs->load("resource");
$langs->load("other");
// Get parameters
@ -70,8 +69,9 @@ $resource_id = GETPOST('fk_resource','int');
$resource_type = GETPOST('resource_type','alpha');
$busy = GETPOST('busy','int');
$mandatory = GETPOST('mandatory','int');
$cancel = GETPOST('cancel','alpha');
if($action == 'add_element_resource' && !GETPOST('cancel'))
if($action == 'add_element_resource' && ! $cancel)
{
$objstat = fetchObjectByElement($element_id,$element);
$res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory);
@ -251,9 +251,6 @@ else
foreach ($object->available_resources as $modresources => $resources)
{
$langs->load($resources);
//print '<h2>'.$modresources.'</h2>';
$resources=(array) $resources; // To be sure $resources is an array
foreach($resources as $resource_obj)
{
@ -301,7 +298,7 @@ else
{
print '<div class="tabsAction">';
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_obj.'&element='.$element.'&element_id='.$element_id.'">Add resource</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_obj.'&element='.$element.'&element_id='.$element_id.'">'.$langs->trans('AddResource').'</a>';
print '</div>';
print '</div>';
}

View File

@ -1,6 +1,5 @@
<?php
/* Module to manage resources into Dolibarr ERP/CRM
* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -116,7 +115,7 @@ else
print_liste_field_titre($langs->trans('Id'),$_SERVER['PHP_SELF'],'t.rowid','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'t.ref','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('ResourceType'),$_SERVER['PHP_SELF'],'ty.code','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Edit'));
print_liste_field_titre($langs->trans('Action'),"","","","",'width="60" align="center"',"","");
print '</tr>';
foreach ($object->lines as $resource)
@ -128,7 +127,7 @@ else
$style='style="background: orange;"';
print '<tr '.$bc[$var].' '.$style.'><td>';
print $resource->id;
print '<a href="./card.php?id='.$resource->id.'">'.$resource->id.'</a>';
print '</td>';
print '<td>';
@ -139,9 +138,14 @@ else
print $resource->type_label;
print '</td>';
print '<td>';
print '<a href="card.php?id='.$resource->id.'">'.$langs->trans('View').'</a> ';
print '<a href="card.php?action=edit&id='.$resource->id.'">'.$langs->trans('Edit').'</a>';
print '<td align="center">';
print '<a href="./card.php?action=update&id='.$resource->id.'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="./card.php?action=delete&id='.$resource->id.'">';
print img_delete();
print '</a>';
print '</td>';
print '</tr>';