Little debug of module resource

This commit is contained in:
Laurent Destailleur 2015-05-31 02:05:39 +02:00
parent 5e773d4cb6
commit 49f2157f2d
9 changed files with 94 additions and 79 deletions

View File

@ -1267,7 +1267,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print '</form>'."\n";
print '<form name="listactionsfilterweek" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1276,7 +1276,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print '</form>'."\n";
print '<form name="listactionsfilterday" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1285,7 +1285,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewday" value="'.$langs->trans("ViewDay").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewday" value="'.$langs->trans("ViewDay").'">';
print '</form>'."\n";
print '<form name="listactionsfilterperuser" action="'.DOL_URL_ROOT.'/comm/action/peruser.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1294,7 +1294,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print '</form>'."\n";
print '</div>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@ -143,7 +143,7 @@ if ($object->id > 0)
print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$object->label.'</td></tr>';
// Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent).'</td></tr>';
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
// Date start
print '<tr><td width="30%">'.$langs->trans("DateActionStart").'</td><td colspan="3">';
@ -235,7 +235,7 @@ if ($object->id > 0)
// Project
if (! empty($conf->projet->enabled))
{
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Project").'</td><td colspan="3">';
if ($object->fk_project)
{
$project=new Project($db);
@ -274,7 +274,7 @@ if ($object->id > 0)
}
print '<tr><td width="30%" nowrap>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td width="30%" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
@ -294,7 +294,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print '</form>'."\n";
print '<form name="listactionsfilterweek" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -303,7 +303,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print '</form>'."\n";
print '<form name="listactionsfilterday" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -312,7 +312,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewday" value="'.$langs->trans("ViewDay").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewday" value="'.$langs->trans("ViewDay").'">';
print '</form>'."\n";
print '<form name="listactionsfilterperuser" action="'.DOL_URL_ROOT.'/comm/action/peruser.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -321,7 +321,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print '</form>'."\n";
print '</div>';

View File

@ -421,6 +421,15 @@ function actions_prepare_head($object)
$head[$h][2] = 'card';
$h++;
// Tab to link resources
if ($conf->resource->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id;
$head[$h][1] = $langs->trans("Resources");
$head[$h][2] = 'resources';
$h++;
}
// Attached files
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$upload_dir = $conf->agenda->dir_output . "/" . $object->id;

View File

@ -93,6 +93,15 @@ function societe_prepare_head(Societe $object)
$h++;
}
// Tab to link resources
if ($conf->resource->enabled && ! empty($conf->global->RESOURCE_ON_THIRDPARTIES))
{
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id;
$head[$h][1] = $langs->trans("Resources");
$head[$h][2] = 'resources';
$h++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

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
@ -14,6 +13,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Module to manage resources into Dolibarr ERP/CRM
*/
/**
@ -151,8 +152,7 @@ class modResource extends DolibarrModules
// (reresource 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
$this->tabs = array(
'action:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=action&element_id=__ID__',
'thirdparty:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=societe&element_id=__ID__'
// 'thirdparty:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=societe&element_id=__ID__'
);
// Boxes

View File

@ -1,14 +1,13 @@
<?php
// BEGIN TPL RESOURCE_ADD.TPL.PHP
//$langs->load($resource_type);
require_once(DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php');
$form = new Form($db);
if(!class_exists('FormResource'))
require_once(DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php');
$formresources = new FormResource($db);
$out .= '<div class="tagtable centpercent border allwidth">';
$out .= '<div class="tagtable centpercent border allwidth nohover">';
$out .= '<form class="tagtr '.($var==true?'pair':'impair').'" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -27,10 +26,8 @@ $out .= '</div>';
$out .= '<div class="tagtd"><label>'.$langs->trans('Busy').'</label> '.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>';
$out .= '<div class="tagtd"><label>'.$langs->trans('Mandatory').'</label> '.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>';
$out .= '<div class="tagtd">';
$out .='<input type="submit" id="add-resource-place" class="button" value="'.$langs->trans("Add").'"';
$out .=' />';
$out .='<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" />';
$out .= '<div class="tagtd" align="right">';
$out .='<input type="submit" id="add-resource-place" class="button" value="'.$langs->trans("Add").'"/>';
$out .= '</div>';
$out .='</form>';
@ -40,6 +37,4 @@ $out .= '<br />';
print $out;
// FIN DU TPL

View File

@ -6,36 +6,32 @@ $form= new Form($db);
if( (array) $linked_resources && count($linked_resources) > 0)
{
$var=false;
$var=true;
// TODO: DEBUT DU TPL
if($mode == 'edit' )
{
print '<div class="tagtable centpercent noborder allwidth">';
print '<form class="tagtr liste_titre">';
print '<div class="tagtd">'.$langs->trans('Type').'</div>';
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" align="center">'.$langs->trans('Busy').'</div>';
print '<div class="tagtd" align="center">'.$langs->trans('Mandatory').'</div>';
print '<div class="tagtd"></div>';
print '</form>';
//print '</div>';
}
else
{
print '<div class="tagtable centpercent noborder allwidth">';
print '<form class="tagtr liste_titre">';
print '<div class="tagtd">'.$langs->trans('Type').'</div>';
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('Action').'</div>';
print '<div class="tagtd" align="center">'.$langs->trans('Busy').'</div>';
print '<div class="tagtd" align="center">'.$langs->trans('Mandatory').'</div>';
print '<div class="tagtd"></div>';
print '</form>';
//print '</div>';
}
@ -55,7 +51,7 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print '<div class="tagtd">'.$object_resource->type_label.'</div>';
print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>';
print '<div class="tagtd">'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>';
print '<div class="tagtd" align="center">'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>';
print '<div class="tagtd">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>';
print '<div class="tagtd"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>';
print '</form>';
@ -77,20 +73,20 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print $object_resource->getNomUrl(1);
print '</div class="tagtd">';
print '<div class="tagtd">';
print $linked_resource['busy']?1:0;
print '<div class="tagtd" align="center">';
print yn($linked_resource['busy']);
print '</div>';
print '<div class="tagtd">';
print $linked_resource['mandatory']?1:0;
print '<div class="tagtd" align="center">';
print yn($linked_resource['mandatory']);
print '</div>';
print '<div class="tagtd">';
print '<div class="tagtd" align="right">';
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&id='.$linked_resource['resource_id'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&id='.$linked_resource['resource_id'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">';
print img_delete();
print '</a>';
print '</div>';

View File

@ -72,6 +72,11 @@ $mandatory = GETPOST('mandatory','int');
$cancel = GETPOST('cancel','alpha');
$confirm = GETPOST('confirm','alpha');
/*
* Actions
*/
if($action == 'add_element_resource' && ! $cancel)
{
$objstat = fetchObjectByElement($element_id,$element);
@ -147,19 +152,17 @@ $reshook=$hookmanager->executeHooks('getElementResources',$parameters,$object,$a
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/***************************************************
* VIEW
*
* Put here all code to build page
****************************************************/
/*
* View
*/
$form=new Form($db);
$pagetitle=$langs->trans('ResourceElementPage');
llxHeader('',$pagetitle,'');
$form=new Form($db);
// Load available resource, declared by modules
$ret = count($object->available_resources);
if($ret == -1) {
@ -212,16 +215,17 @@ else
print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>';
print '</table>';
print '</div>';
dol_fiche_end();
}
}
/*
* Specific to thirdparty module
*/
if($element_id && $element == 'societe')
if ($element_id && $element == 'societe')
{
$socstatic = fetchObjectByElement($element_id,$element);
if(is_object($socstatic)) {
if (is_object($socstatic)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$head = societe_prepare_head($socstatic);
@ -240,13 +244,13 @@ else
print '</tr>';
print '</table>';
print '</div>';
dol_fiche_end();
}
}
print_fiche_titre($langs->trans('ResourcesLinkedToElement'),'','resource.png@resource');
//print_fiche_titre($langs->trans('ResourcesLinkedToElement'),'','');
@ -257,7 +261,8 @@ else
{
$element_prop = getElementProperties($resource_obj);
print_titre($langs->trans(ucfirst($element_prop['element']).'Singular'));
//print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />';
@ -267,21 +272,21 @@ else
$linked_resources = $object->getElementResources($element,$element_id,$resource_obj);
if ( $mode == 'add' && $resource_obj == $resource_type)
// If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php')))
{
// If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_'.$mode.'.tpl.php')))
{
$res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_'.$mode.'.tpl.php');
}
else
{
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php';
}
$res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php');
}
else
{
//print '/'.$element_prop['module'].'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php';
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php';
}
if ($mode != 'add' || $resource_obj != $resource_type)
{
//print_titre($langs->trans(ucfirst($element_prop['element']).'Singular'));
// If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php')))
@ -294,15 +299,6 @@ else
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php';
}
}
if($resource_obj!=$resource_type )
{
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.'">'.$langs->trans('AddResource').'</a>';
print '</div>';
print '</div>';
}
}
}
}

View File

@ -448,7 +448,17 @@ textarea.centpercent {
#formuserfile_link {
margin-left: 1px;
}
/* Style to move picto into left of button */
/*
.buttonactionview {
padding-left: 15px;
}
.pictoactionview {
padding-left: 10px;
margin-right: -24px;
z-index: 999999;
}
*/
/* ============================================================================== */
/* Styles to hide objects */