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('Resource').'</div>';
print '<div class="tagtd">'.$langs->trans('Busy').'</div>'; print '<div class="tagtd">'.$langs->trans('Busy').'</div>';
print '<div class="tagtd">'.$langs->trans('Mandatory').'</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 '</form>';
//print '</div>'; //print '</div>';
@ -86,8 +86,13 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print '</div>'; print '</div>';
print '<div class="tagtd">'; 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'].'">';
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 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>';
print '</div>'; print '</div>';

View File

@ -32,7 +32,7 @@ if (! $res) die("Include of main fails");
require_once 'class/resource.class.php'; require_once 'class/resource.class.php';
require_once 'class/html.formresource.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("resource");
$langs->load("companies"); $langs->load("companies");
$langs->load("other"); $langs->load("other");
@ -41,6 +41,7 @@ $langs->load("resource@resource");
// Get parameters // Get parameters
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha');
if (empty($sortorder)) $sortorder="DESC"; if (empty($sortorder)) $sortorder="DESC";
if (empty($sortfield)) $sortfield="t.rowid"; if (empty($sortfield)) $sortfield="t.rowid";
if (empty($arch)) $arch = 0; if (empty($arch)) $arch = 0;
@ -64,6 +65,8 @@ if ($user->societe_id > 0)
$object = new Resource($db); $object = new Resource($db);
if ($action == 'confirm_add_resource') if ($action == 'confirm_add_resource')
{
if (! $cancel)
{ {
$error=''; $error='';
@ -106,11 +109,16 @@ if ($action == 'confirm_add_resource')
$action = ''; $action = '';
} }
} }
else
{
Header("Location: list.php");
}
}
/*************************************************** /*
* VIEW * View
* *
****************************************************/ */
$form=new Form($db); $form=new Form($db);
$formresource = new FormResource($db); $formresource = new FormResource($db);
@ -161,8 +169,10 @@ if ( !$action )
print '</table>'; print '</table>';
echo '<div style="text-align: center">', echo '<br><div align="center">',
' <input type="submit" class="button" name="" value="'.$langs->trans('Save').'" />', '<input type="submit" class="button" name="add" value="'.$langs->trans('Save').'" />',
'&nbsp;',
'<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" />',
'</div>'; '</div>';
print '</form>'; print '</form>';

View File

@ -171,7 +171,7 @@ if ( $object->fetch($id) > 0 )
} }
else else
{ {
// Confirmation suppression resource line // Confirm deleting resource line
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm("card.php?&id=".$id,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResource"),"confirm_delete_resource",'','',1); 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>'; print '</div>';
} }
} }
if ($action != "delete" ) if ($action != "delete" && $action != "edit")
{ {
// Edit resource // Delete resource
if($user->rights->resource->delete) if($user->rights->resource->delete)
{ {
print '<div class="inline-block divButAction">'; print '<div class="inline-block divButAction">';

View File

@ -1,6 +1,5 @@
<?php <?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 * 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 * 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'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load traductions files requiredby by page // Load traductions files requiredby by page
$langs->load("resource@resource"); $langs->load("resource");
$langs->load("other"); $langs->load("other");
// Get parameters // Get parameters
@ -70,8 +69,9 @@ $resource_id = GETPOST('fk_resource','int');
$resource_type = GETPOST('resource_type','alpha'); $resource_type = GETPOST('resource_type','alpha');
$busy = GETPOST('busy','int'); $busy = GETPOST('busy','int');
$mandatory = GETPOST('mandatory','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); $objstat = fetchObjectByElement($element_id,$element);
$res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory); $res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory);
@ -251,9 +251,6 @@ else
foreach ($object->available_resources as $modresources => $resources) foreach ($object->available_resources as $modresources => $resources)
{ {
$langs->load($resources);
//print '<h2>'.$modresources.'</h2>';
$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)
{ {
@ -301,7 +298,7 @@ else
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<div class="inline-block divButAction">'; 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>';
print '</div>'; print '</div>';
} }

View File

@ -1,6 +1,5 @@
<?php <?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 * 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 * 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('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('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('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>'; print '</tr>';
foreach ($object->lines as $resource) foreach ($object->lines as $resource)
@ -128,7 +127,7 @@ else
$style='style="background: orange;"'; $style='style="background: orange;"';
print '<tr '.$bc[$var].' '.$style.'><td>'; print '<tr '.$bc[$var].' '.$style.'><td>';
print $resource->id; print '<a href="./card.php?id='.$resource->id.'">'.$resource->id.'</a>';
print '</td>'; print '</td>';
print '<td>'; print '<td>';
@ -139,9 +138,14 @@ else
print $resource->type_label; print $resource->type_label;
print '</td>'; print '</td>';
print '<td>'; print '<td align="center">';
print '<a href="card.php?id='.$resource->id.'">'.$langs->trans('View').'</a> '; print '<a href="./card.php?action=update&id='.$resource->id.'">';
print '<a href="card.php?action=edit&id='.$resource->id.'">'.$langs->trans('Edit').'</a>'; 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 '</td>';
print '</tr>'; print '</tr>';