Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2017-07-31 02:09:15 +02:00
30 changed files with 1163 additions and 364 deletions

View File

@@ -296,7 +296,7 @@ if ($conf->use_javascript_ajax)
//puis tous les elements enfants //puis tous les elements enfants
$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.module"; $sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'"; $sql.= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -323,6 +323,7 @@ if ($conf->use_javascript_ajax)
'leftmenu'=>$menu['leftmenu'], 'leftmenu'=>$menu['leftmenu'],
'fk_mainmenu'=>$menu['fk_mainmenu'], 'fk_mainmenu'=>$menu['fk_mainmenu'],
'fk_leftmenu'=>$menu['fk_leftmenu'], 'fk_leftmenu'=>$menu['fk_leftmenu'],
'position'=>$menu['position'],
'entry'=>'<table class="nobordernopadding centpercent"><tr><td>'. 'entry'=>'<table class="nobordernopadding centpercent"><tr><td>'.
'<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'.$titre.'</a></strong>'. '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'.$titre.'</a></strong>'.
'</td><td align="right">'. '</td><td align="right">'.
@@ -344,10 +345,11 @@ if ($conf->use_javascript_ajax)
global $tree_recur_alreadyadded; // This var was def into tree_recur global $tree_recur_alreadyadded; // This var was def into tree_recur
// Appelle de la fonction recursive (ammorce)
// avec recherche depuis la racine.
//var_dump($data); //var_dump($data);
tree_recur($data, $data[0], 0, 'iddivjstree'); // $data[0] is virtual record 'racine'
// Appelle de la fonction recursive (ammorce) avec recherche depuis la racine.
//tree_recur($data, $data[0], 0, 'iddivjstree', 0, 1); // use this to get info on name and foreign keys of menu entry
tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine'
print '</td>'; print '</td>';
@@ -376,7 +378,6 @@ if ($conf->use_javascript_ajax)
print '<tr>'; print '<tr>';
print '<td colspan="2">'; print '<td colspan="2">';
foreach($remainingdata as $datar) foreach($remainingdata as $datar)
{ {
$father = array('rowid'=>$datar['rowid'],'title'=>"???",'mainmenu'=>$datar['fk_mainmenu'],'leftmenu'=>$datar['fk_leftmenu'],'fk_mainmenu'=>'','fk_leftmenu'=>''); $father = array('rowid'=>$datar['rowid'],'title'=>"???",'mainmenu'=>$datar['fk_mainmenu'],'leftmenu'=>$datar['fk_leftmenu'],'fk_mainmenu'=>'','fk_leftmenu'=>'');

View File

@@ -238,6 +238,7 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json'
{ {
$classfile = str_replace('_', '', $module); $classfile = str_replace('_', '', $module);
if ($module == 'supplierinvoices') $classfile = 'supplier_invoices'; if ($module == 'supplierinvoices') $classfile = 'supplier_invoices';
if ($module == 'supplierorders') $classfile = 'supplier_orders';
$dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php'); $dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php');
$classname=ucwords($module); $classname=ucwords($module);

View File

@@ -38,11 +38,8 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
{ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("companies"); $langs->load("companies");
@@ -585,6 +582,8 @@ if ($action == 'mupdate')
* View * View
*/ */
$formproject=new FormProjets($db);
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url); llxHeader('',$langs->trans("Agenda"),$help_url);
@@ -786,8 +785,6 @@ if ($action == 'create')
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$formproject=new FormProjets($db);
// Projet associe // Projet associe
$langs->load("projects"); $langs->load("projects");
@@ -1133,8 +1130,6 @@ if ($id > 0)
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$formproject=new FormProjets($db);
$langs->load("projects"); $langs->load("projects");
print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td>';

View File

@@ -30,15 +30,17 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
$filter = GETPOST("filter",'',3); $filter = GETPOST("filter",'alpha',3);
$filtert = GETPOST("filtert","int",3); $filtert = GETPOST("filtert","int",3);
$usergroup = GETPOST("usergroup","int",3); $usergroup = GETPOST("usergroup","int",3);
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
@@ -55,7 +57,7 @@ $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page","int"); $page = GETPOST("page","int");
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$offset = $limit * $page; $offset = $limit * $page;
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="a.datec"; if (! $sortfield) $sortfield="a.datec";
@@ -82,9 +84,9 @@ $month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$day=GETPOST("day","int")?GETPOST("day","int"):date("d"); $day=GETPOST("day","int")?GETPOST("day","int"):date("d");
$pid=GETPOST("projectid","int",3); $pid=GETPOST("projectid","int",3);
$status=GETPOST("status"); $status=GETPOST("status",'alpha');
$type=GETPOST("type"); $type=GETPOST("type",'alpha');
$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('actioncode','array')) if (GETPOST('actioncode','array'))
{ {
@@ -93,22 +95,22 @@ if (GETPOST('actioncode','array'))
} }
else else
{ {
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
} }
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear')); $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int'));
if ($dateselect > 0) if ($dateselect > 0)
{ {
$day=GETPOST('dateselectday'); $day=GETPOST('dateselectday','int');
$month=GETPOST('dateselectmonth'); $month=GETPOST('dateselectmonth','int');
$year=GETPOST('dateselectyear'); $year=GETPOST('dateselectyear','int');
} }
$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS;
$tmparray=explode('-',$tmp); $tmparray=explode('-',$tmp);
$begin_h = GETPOST('begin_h')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); $begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9);
$end_h = GETPOST('end_h')?GETPOST('end_h'):($tmparray[1] != '' ? $tmparray[1] : 18); $end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18);
if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; if ($begin_h < 0 || $begin_h > 23) $begin_h = 9;
if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h < 1 || $end_h > 24) $end_h = 18;
if ($end_h <= $begin_h) $end_h = $begin_h + 1; if ($end_h <= $begin_h) $end_h = $begin_h + 1;
@@ -124,13 +126,13 @@ if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $ac
if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
$action='show_month'; $day=''; $action='show_month'; $day='';
} // View by month } // View by month
if (GETPOST('viewweek') || $action == 'show_week') { if (GETPOST('viewweek','alpha') || $action == 'show_week') {
$action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d"));
} // View by week } // View by week
if (GETPOST('viewday') || $action == 'show_day') { if (GETPOST('viewday','alpha') || $action == 'show_day') {
$action='show_day'; $day=($day?$day:date("d")); $action='show_day'; $day=($day?$day:date("d"));
} // View by day } // View by day
if (GETPOST('viewyear') || $action == 'show_year') { if (GETPOST('viewyear','alpha') || $action == 'show_year') {
$action='show_year'; $action='show_year';
} // View by year } // View by year
@@ -161,12 +163,12 @@ if ($action =='delete_action')
* View * View
*/ */
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);
$form=new Form($db); $form=new Form($db);
$companystatic=new Societe($db); $companystatic=new Societe($db);
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);
$now=dol_now(); $now=dol_now();
$nowarray=dol_getdate($now); $nowarray=dol_getdate($now);
$nowyear=$nowarray['year']; $nowyear=$nowarray['year'];
@@ -354,7 +356,7 @@ $sql.= ' a.datep2,';
$sql.= ' a.percent,'; $sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,'; $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
$sql.= ' ca.code, ca.color'; $sql.= ' ca.code, ca.color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
@@ -456,11 +458,14 @@ if ($resql)
continue; continue;
} }
$datep=$db->jdate($obj->datep);
$datep2=$db->jdate($obj->datep2);
// Create a new object action // Create a new object action
$event=new ActionComm($db); $event=new ActionComm($db);
$event->id=$obj->id; $event->id=$obj->id;
$event->datep=$db->jdate($obj->datep); // datep and datef are GMT date $event->datep=$datep; // datep and datef are GMT date
$event->datef=$db->jdate($obj->datep2); $event->datef=$datep2;
$event->type_code=$obj->code; $event->type_code=$obj->code;
$event->type_color=$obj->color; $event->type_color=$obj->color;
//$event->libelle=$obj->label; // deprecated //$event->libelle=$obj->label; // deprecated
@@ -469,12 +474,13 @@ if ($resql)
//$event->author->id=$obj->fk_user_author; // user id of creator //$event->author->id=$obj->fk_user_author; // user id of creator
$event->authorid=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator
$event->userownerid=$obj->fk_user_action; // user id of owner $event->userownerid=$obj->fk_user_action; // user id of owner
$event->fetch_userassigned(); // This load $event->userassigned
$event->priority=$obj->priority; $event->priority=$obj->priority;
$event->fulldayevent=$obj->fulldayevent; $event->fulldayevent=$obj->fulldayevent;
$event->location=$obj->location; $event->location=$obj->location;
$event->transparency=$obj->transparency; $event->transparency=$obj->transparency;
$event->fk_project=$obj->fk_project;
$event->socid=$obj->fk_soc; $event->socid=$obj->fk_soc;
$event->contactid=$obj->fk_contact; $event->contactid=$obj->fk_contact;
//$event->societe->id=$obj->fk_soc; // deprecated //$event->societe->id=$obj->fk_soc; // deprecated
@@ -487,15 +493,15 @@ if ($resql)
// They are date start and end of action but modified to not be outside calendar view. // They are date start and end of action but modified to not be outside calendar view.
if ($event->percentage <= 0) if ($event->percentage <= 0)
{ {
$event->date_start_in_calendar=$event->datep; $event->date_start_in_calendar=$datep;
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
else $event->date_end_in_calendar=$event->datep; else $event->date_end_in_calendar=$datep;
} }
else else
{ {
$event->date_start_in_calendar=$event->datep; $event->date_start_in_calendar=$datep;
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
else $event->date_end_in_calendar=$event->datep; else $event->date_end_in_calendar=$datep;
} }
// Define ponctual property // Define ponctual property
if ($event->date_start_in_calendar == $event->date_end_in_calendar) if ($event->date_start_in_calendar == $event->date_end_in_calendar)
@@ -508,10 +514,14 @@ if ($resql)
$event->date_start_in_calendar >= $lastdaytoshow) $event->date_start_in_calendar >= $lastdaytoshow)
{ {
// This record is out of visible range // This record is out of visible range
unset($event);
} }
else else
{ {
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
$event->fetch_userassigned(); // This load $event->userassigned
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow;
if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1);
// Add an entry in actionarray for each day // Add an entry in actionarray for each day
@@ -881,11 +891,37 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
} }
$cases1[$h][$event->id]['string'].=' - '.$event->label; $cases1[$h][$event->id]['string'].=' - '.$event->label;
$cases1[$h][$event->id]['typecode']=$event->type_code; $cases1[$h][$event->id]['typecode']=$event->type_code;
if ($event->socid)
{
//$cases1[$h][$event->id]['string'].='xxx';
}
$cases1[$h][$event->id]['color']=$color; $cases1[$h][$event->id]['color']=$color;
if ($event->fk_project > 0)
{
if (empty($cache_project[$event->fk_project]))
{
$tmpproj=new Project($db);
$tmpproj->fetch($event->fk_project);
$cache_project[$event->fk_project]=$tmpproj;
}
$cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cache_thirdparty[$event->socid]))
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cache_thirdparty[$event->socid]=$tmpthirdparty;
}
$cases1[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name;
}
if ($event->contactid > 0)
{
if (empty($cache_contact[$event->contactid]))
{
$tmpcontact=new Contact($db);
$tmpcontact->fetch($event->contactid);
$cache_contact[$event->contactid]=$tmpcontact;
}
$cases1[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs);
}
} }
if ($event->date_start_in_calendar < $c && $dateendtouse > $b) if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
{ {
@@ -901,11 +937,37 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
} }
$cases2[$h][$event->id]['string'].=' - '.$event->label; $cases2[$h][$event->id]['string'].=' - '.$event->label;
$cases2[$h][$event->id]['typecode']=$event->type_code; $cases2[$h][$event->id]['typecode']=$event->type_code;
if ($event->socid)
{
//$cases2[$h][$event->id]['string'].='xxx';
}
$cases2[$h][$event->id]['color']=$color; $cases2[$h][$event->id]['color']=$color;
if ($event->fk_project > 0)
{
if (empty($cache_project[$event->fk_project]))
{
$tmpproj=new Project($db);
$tmpproj->fetch($event->fk_project);
$cache_project[$event->fk_project]=$tmpproj;
}
$cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cache_thirdparty[$event->socid]))
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cache_thirdparty[$event->socid]=$tmpthirdparty;
}
$cases2[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name;
}
if ($event->contactid > 0)
{
if (empty($cache_contact[$event->contactid]))
{
$tmpcontact=new Contact($db);
$tmpcontact->fetch($event->contactid);
$cache_contact[$event->contactid]=$tmpcontact;
}
$cases2[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs);
}
} }
} }
else else
@@ -928,6 +990,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
} }
} }
// Now output $casesX
for ($h = $begin_h; $h < $end_h; $h++) for ($h = $begin_h; $h < $end_h; $h++)
{ {
$color1='';$color2=''; $color1='';$color2='';

View File

@@ -30,15 +30,17 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
$filter = GETPOST("filter",'',3); $filter = GETPOST("filter",'alpha',3);
$filtert = GETPOST("filtert","int",3); $filtert = GETPOST("filtert","int",3);
$usergroup = GETPOST("usergroup","int",3); $usergroup = GETPOST("usergroup","int",3);
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
@@ -55,7 +57,7 @@ $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page","int"); $page = GETPOST("page","int");
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$offset = $limit * $page; $offset = $limit * $page;
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="a.datec"; if (! $sortfield) $sortfield="a.datec";
@@ -82,9 +84,9 @@ $month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$day=GETPOST("day","int")?GETPOST("day","int"):date("d"); $day=GETPOST("day","int")?GETPOST("day","int"):date("d");
$pid=GETPOST("projectid","int",3); $pid=GETPOST("projectid","int",3);
$status=GETPOST("status"); $status=GETPOST("status",'alpha');
$type=GETPOST("type"); $type=GETPOST("type",'alpha');
$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('actioncode','array')) if (GETPOST('actioncode','array'))
{ {
@@ -93,29 +95,30 @@ if (GETPOST('actioncode','array'))
} }
else else
{ {
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
} }
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear'));
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int'));
if ($dateselect > 0) if ($dateselect > 0)
{ {
$day=GETPOST('dateselectday'); $day=GETPOST('dateselectday','int');
$month=GETPOST('dateselectmonth'); $month=GETPOST('dateselectmonth','int');
$year=GETPOST('dateselectyear'); $year=GETPOST('dateselectyear','int');
} }
$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS;
$tmparray=explode('-',$tmp); $tmparray=explode('-',$tmp);
$begin_h = GETPOST('begin_h')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); $begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9);
$end_h = GETPOST('end_h')?GETPOST('end_h'):($tmparray[1] != '' ? $tmparray[1] : 18); $end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18);
if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; if ($begin_h < 0 || $begin_h > 23) $begin_h = 9;
if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h < 1 || $end_h > 24) $end_h = 18;
if ($end_h <= $begin_h) $end_h = $begin_h + 1; if ($end_h <= $begin_h) $end_h = $begin_h + 1;
$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS;
$tmparray=explode('-',$tmp); $tmparray=explode('-',$tmp);
$begin_d = GETPOST('begin_d')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tmparray[0] : 1); $begin_d = GETPOST('begin_d','int')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tmparray[0] : 1);
$end_d = GETPOST('end_d')?GETPOST('end_d'):($tmparray[1] != '' ? $tmparray[1] : 5); $end_d = GETPOST('end_d','int')?GETPOST('end_d','int'):($tmparray[1] != '' ? $tmparray[1] : 5);
if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; if ($begin_d < 1 || $begin_d > 7) $begin_d = 1;
if ($end_d < 1 || $end_d > 7) $end_d = 7; if ($end_d < 1 || $end_d > 7) $end_d = 7;
if ($end_d < $begin_d) $end_d = $begin_d + 1; if ($end_d < $begin_d) $end_d = $begin_d + 1;
@@ -123,13 +126,13 @@ if ($end_d < $begin_d) $end_d = $begin_d + 1;
if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { if (GETPOST('viewcal','alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
$action='show_month'; $day=''; $action='show_month'; $day='';
} // View by month } // View by month
if (GETPOST('viewweek') || $action == 'show_week') { if (GETPOST('viewweek','alpha') || $action == 'show_week') {
$action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d"));
} // View by week } // View by week
if (GETPOST('viewday') || $action == 'show_day') { if (GETPOST('viewday','alpha') || $action == 'show_day') {
$action='show_day'; $day=($day?$day:date("d")); $action='show_day'; $day=($day?$day:date("d"));
} // View by day } // View by day
@@ -160,12 +163,12 @@ if ($action =='delete_action')
* View * View
*/ */
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);
$form=new Form($db); $form=new Form($db);
$companystatic=new Societe($db); $companystatic=new Societe($db);
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);
$now=dol_now(); $now=dol_now();
$nowarray=dol_getdate($now); $nowarray=dol_getdate($now);
$nowyear=$nowarray['year']; $nowyear=$nowarray['year'];
@@ -361,7 +364,7 @@ $sql.= ' a.datep2,';
$sql.= ' a.percent,'; $sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,'; $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
$sql.= ' ca.code, ca.color'; $sql.= ' ca.code, ca.color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
@@ -418,14 +421,14 @@ else
{ {
// To limit array // To limit array
$sql.= " AND ("; $sql.= " AND (";
$sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; // Start 7 days before $sql.= " (a.datep BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; // Start 2 day before $firstdaytoshow
$sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 $sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; // End 2 day after $lastdaytoshow
$sql.= " OR "; $sql.= " OR ";
$sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; $sql.= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'";
$sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; $sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')";
$sql.= " OR "; $sql.= " OR ";
$sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; $sql.= " (a.datep < '".$db->idate($firstdaytoshow-(60*60*24*2))."'";
$sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; $sql.= " AND a.datep2 > '".$db->idate($lastdaytoshow+(60*60*24*2))."')";
$sql.= ')'; $sql.= ')';
} }
if ($type) $sql.= " AND ca.id = ".$type; if ($type) $sql.= " AND ca.id = ".$type;
@@ -444,13 +447,14 @@ if ($filtert > 0 || $usergroup > 0)
} }
// Sort on date // Sort on date
$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action $sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action
//print $sql; //print $sql;exit;
dol_syslog("comm/action/peruser.php", LOG_DEBUG); dol_syslog("comm/action/peruser.php", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i=0; $i=0;
while ($i < $num) while ($i < $num)
{ {
@@ -463,11 +467,14 @@ if ($resql)
continue; continue;
} }
$datep=$db->jdate($obj->datep);
$datep2=$db->jdate($obj->datep2);
// Create a new object action // Create a new object action
$event=new ActionComm($db); $event=new ActionComm($db);
$event->id=$obj->id; $event->id=$obj->id;
$event->datep=$db->jdate($obj->datep); // datep and datef are GMT date $event->datep=$datep; // datep and datef are GMT date
$event->datef=$db->jdate($obj->datep2); $event->datef=$datep2;
$event->type_code=$obj->code; $event->type_code=$obj->code;
$event->type_color=$obj->color; $event->type_color=$obj->color;
//$event->libelle=$obj->label; // deprecated //$event->libelle=$obj->label; // deprecated
@@ -476,12 +483,13 @@ if ($resql)
//$event->author->id=$obj->fk_user_author; // user id of creator //$event->author->id=$obj->fk_user_author; // user id of creator
$event->authorid=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator
$event->userownerid=$obj->fk_user_action; // user id of owner $event->userownerid=$obj->fk_user_action; // user id of owner
$event->fetch_userassigned(); // This load $event->userassigned
$event->priority=$obj->priority; $event->priority=$obj->priority;
$event->fulldayevent=$obj->fulldayevent; $event->fulldayevent=$obj->fulldayevent;
$event->location=$obj->location; $event->location=$obj->location;
$event->transparency=$obj->transparency; $event->transparency=$obj->transparency;
$event->fk_project=$obj->fk_project;
$event->socid=$obj->fk_soc; $event->socid=$obj->fk_soc;
$event->contactid=$obj->fk_contact; $event->contactid=$obj->fk_contact;
//$event->societe->id=$obj->fk_soc; // deprecated //$event->societe->id=$obj->fk_soc; // deprecated
@@ -494,15 +502,15 @@ if ($resql)
// They are date start and end of action but modified to not be outside calendar view. // They are date start and end of action but modified to not be outside calendar view.
if ($event->percentage <= 0) if ($event->percentage <= 0)
{ {
$event->date_start_in_calendar=$event->datep; $event->date_start_in_calendar=$datep;
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
else $event->date_end_in_calendar=$event->datep; else $event->date_end_in_calendar=$datep;
} }
else else
{ {
$event->date_start_in_calendar=$event->datep; $event->date_start_in_calendar=$datep;
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
else $event->date_end_in_calendar=$event->datep; else $event->date_end_in_calendar=$datep;
} }
// Define ponctual property // Define ponctual property
if ($event->date_start_in_calendar == $event->date_end_in_calendar) if ($event->date_start_in_calendar == $event->date_end_in_calendar)
@@ -515,10 +523,14 @@ if ($resql)
$event->date_start_in_calendar >= $lastdaytoshow) $event->date_start_in_calendar >= $lastdaytoshow)
{ {
// This record is out of visible range // This record is out of visible range
unset($event);
} }
else else
{ {
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
$event->fetch_userassigned(); // This load $event->userassigned
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow;
if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1);
// Add an entry in actionarray for each day // Add an entry in actionarray for each day
@@ -548,6 +560,7 @@ if ($resql)
$i++; $i++;
} }
$db->free($resql);
} }
else else
{ {
@@ -865,11 +878,12 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
global $theme_datacolor; // Array with a list of different we can use (come from theme) global $theme_datacolor; // Array with a list of different we can use (come from theme)
global $cachethirdparties, $cachecontacts, $colorindexused; global $cachethirdparties, $cachecontacts, $colorindexused;
global $begin_h, $end_h; global $begin_h, $end_h;
global $cache_project, $cache_thirdparty, $cache_contact;
$cases1 = array(); // Color first half hour $cases1 = array(); // Color first half hour
$cases2 = array(); // Color second half hour $cases2 = array(); // Color second half hour
$curtime = dol_mktime(0, 0, 0, $month, $day, $year); $curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0);
$i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
$ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
@@ -980,13 +994,39 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour');
else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour');
} }
$cases1[$h][$event->id]['string'].=' - '.$event->label; if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label;
$cases1[$h][$event->id]['typecode']=$event->type_code; $cases1[$h][$event->id]['typecode']=$event->type_code;
if ($event->socid)
{
//$cases1[$h][$event->id]['string'].='xxx';
}
$cases1[$h][$event->id]['color']=$color; $cases1[$h][$event->id]['color']=$color;
if ($event->fk_project > 0)
{
if (empty($cache_project[$event->fk_project]))
{
$tmpproj=new Project($db);
$tmpproj->fetch($event->fk_project);
$cache_project[$event->fk_project]=$tmpproj;
}
$cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cache_thirdparty[$event->socid]))
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cache_thirdparty[$event->socid]=$tmpthirdparty;
}
$cases1[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name;
}
if ($event->contactid > 0)
{
if (empty($cache_contact[$event->contactid]))
{
$tmpcontact=new Contact($db);
$tmpcontact->fetch($event->contactid);
$cache_contact[$event->contactid]=$tmpcontact;
}
$cases1[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs);
}
} }
if ($event->date_start_in_calendar < $c && $dateendtouse > $b) if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
{ {
@@ -1000,13 +1040,39 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour');
else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour');
} }
$cases2[$h][$event->id]['string'].=' - '.$event->label; if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label;
$cases2[$h][$event->id]['typecode']=$event->type_code; $cases2[$h][$event->id]['typecode']=$event->type_code;
if ($event->socid)
{
//$cases2[$h][$event->id]['string'].='xxx';
}
$cases2[$h][$event->id]['color']=$color; $cases2[$h][$event->id]['color']=$color;
if ($event->fk_project > 0)
{
if (empty($cache_project[$event->fk_project]))
{
$tmpproj=new Project($db);
$tmpproj->fetch($event->fk_project);
$cache_project[$event->fk_project]=$tmpproj;
}
$cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cache_thirdparty[$event->socid]))
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cache_thirdparty[$event->socid]=$tmpthirdparty;
}
$cases2[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name;
}
if ($event->contactid > 0)
{
if (empty($cache_contact[$event->contactid]))
{
$tmpcontact=new Contact($db);
$tmpcontact->fetch($event->contactid);
$cache_contact[$event->contactid]=$tmpcontact;
}
$cases2[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs);
}
} }
} }
else else
@@ -1029,6 +1095,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
} }
} }
// Now output $casesX
for ($h = $begin_h; $h < $end_h; $h++) for ($h = $begin_h; $h < $end_h; $h++)
{ {
$color1='';$color2=''; $color1='';$color2='';

View File

@@ -24,14 +24,14 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
/** /**
* API class for orders * API class for orders
* *
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
*/ */
class Proposals extends DolibarrApi class Proposals extends DolibarrApi
{ {
/** /**
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'socid' 'socid'
@@ -56,36 +56,36 @@ class Proposals extends DolibarrApi
* Get properties of a commercial proposal object * Get properties of a commercial proposal object
* *
* Return an array with commercial proposal informations * Return an array with commercial proposal informations
* *
* @param int $id ID of commercial proposal * @param int $id ID of commercial proposal
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
{ {
if(! DolibarrApiAccess::$user->rights->propal->lire) { if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->propal->fetchObjectLinked(); $this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }
/** /**
* List commercial proposals * List commercial proposals
* *
* Get a list of commercial proposals * Get a list of commercial proposals
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
@@ -96,12 +96,12 @@ class Proposals extends DolibarrApi
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
@@ -109,7 +109,7 @@ class Proposals extends DolibarrApi
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; $sql.= ' WHERE t.entity IN ('.getEntity('propal').')';
@@ -122,7 +122,7 @@ class Proposals extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (! DolibarrApi::_checkFilters($sqlfilters)) if (! DolibarrApi::_checkFilters($sqlfilters))
{ {
@@ -131,7 +131,7 @@ class Proposals extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0)
@@ -144,7 +144,7 @@ class Proposals extends DolibarrApi
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@@ -195,7 +195,7 @@ class Proposals extends DolibarrApi
if ($this->propal->create(DolibarrApiAccess::$user) < 0) { if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors)); throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors));
} }
return $this->propal->id; return $this->propal->id;
} }
@@ -203,21 +203,21 @@ class Proposals extends DolibarrApi
* Get lines of a commercial proposal * Get lines of a commercial proposal
* *
* @param int $id Id of commercial proposal * @param int $id Id of commercial proposal
* *
* @url GET {id}/lines * @url GET {id}/lines
* *
* @return int * @return int
*/ */
function getLines($id) { function getLines($id) {
if(! DolibarrApiAccess::$user->rights->propal->lire) { if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -233,22 +233,22 @@ class Proposals extends DolibarrApi
* Add a line to given commercial proposal * Add a line to given commercial proposal
* *
* @param int $id Id of commercial proposal to update * @param int $id Id of commercial proposal to update
* @param array $request_data Commercial proposal line data * @param array $request_data Commercial proposal line data
* *
* @url POST {id}/lines * @url POST {id}/lines
* *
* @return int * @return int
*/ */
function postLine($id, $request_data = NULL) { function postLine($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->propal->creer) { if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -294,22 +294,22 @@ class Proposals extends DolibarrApi
* *
* @param int $id Id of commercial proposal to update * @param int $id Id of commercial proposal to update
* @param int $lineid Id of line to update * @param int $lineid Id of line to update
* @param array $request_data Commercial proposal line data * @param array $request_data Commercial proposal line data
* *
* @url PUT {id}/lines/{lineid} * @url PUT {id}/lines/{lineid}
* *
* @return object * @return object
*/ */
function putLine($id, $lineid, $request_data = NULL) { function putLine($id, $lineid, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->propal->creer) { if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -352,21 +352,21 @@ class Proposals extends DolibarrApi
* *
* @param int $id Id of commercial proposal to update * @param int $id Id of commercial proposal to update
* @param int $lineid Id of line to delete * @param int $lineid Id of line to delete
* *
* @url DELETE {id}/lines/{lineid} * @url DELETE {id}/lines/{lineid}
* *
* @return int * @return int
*/ */
function delLine($id, $lineid) { function delLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->propal->creer) { if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -382,20 +382,20 @@ class Proposals extends DolibarrApi
* Update commercial proposal general fields (won't touch lines of commercial proposal) * Update commercial proposal general fields (won't touch lines of commercial proposal)
* *
* @param int $id Id of commercial proposal to update * @param int $id Id of commercial proposal to update
* @param array $request_data Datas * @param array $request_data Datas
* *
* @return int * @return int
*/ */
function put($id, $request_data = NULL) { function put($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->propal->creer) { if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -403,18 +403,18 @@ class Proposals extends DolibarrApi
if ($field == 'id') continue; if ($field == 'id') continue;
$this->propal->$field = $value; $this->propal->$field = $value;
} }
if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update')) if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update'))
return $this->get($id); return $this->get($id);
return false; return false;
} }
/** /**
* Delete commercial proposal * Delete commercial proposal
* *
* @param int $id Commercial proposal ID * @param int $id Commercial proposal ID
* *
* @return array * @return array
*/ */
function delete($id) function delete($id)
@@ -426,32 +426,32 @@ class Proposals extends DolibarrApi
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if( ! $this->propal->delete(DolibarrApiAccess::$user)) { if( ! $this->propal->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error);
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'Commercial Proposal deleted' 'message' => 'Commercial Proposal deleted'
) )
); );
} }
/** /**
* Validate a commercial proposal * Validate a commercial proposal
* *
* @param int $id Commercial proposal ID * @param int $id Commercial proposal ID
* @param int $notrigger Use {} * @param int $notrigger Use {}
* *
* @url POST {id}/validate * @url POST {id}/validate
* *
* @return array * @return array
* FIXME An error 403 is returned if the request has an empty body. * FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported." * Error message: "Forbidden: Content type `text/plain` is not supported."
@@ -469,11 +469,11 @@ class Proposals extends DolibarrApi
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger); $result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger);
if ($result == 0) { if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated'); throw new RestException(500, 'Error nothing done. May be object is already validated');
@@ -481,30 +481,30 @@ class Proposals extends DolibarrApi
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error); throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'Commercial Proposal validated' 'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')'
) )
); );
} }
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
* @param array $data Array with data to verify * @param array $data Array with data to verify
* @return array * @return array
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)
{ {
$propal = array(); $propal = array();
foreach (Orders::$FIELDS as $field) { foreach (Proposals::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field]))
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
$propal[$field] = $data[$field]; $propal[$field] = $data[$field];
} }
return $propal; return $propal;
} }

View File

@@ -80,8 +80,8 @@ class Orders extends DolibarrApi
return $this->_cleanObjectDatas($this->commande); return $this->_cleanObjectDatas($this->commande);
} }
/** /**
* List orders * List orders
* *
@@ -101,7 +101,7 @@ class Orders extends DolibarrApi
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
@@ -125,7 +125,7 @@ class Orders extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (! DolibarrApi::_checkFilters($sqlfilters)) if (! DolibarrApi::_checkFilters($sqlfilters))
{ {
@@ -134,7 +134,7 @@ class Orders extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0)
@@ -490,7 +490,7 @@ class Orders extends DolibarrApi
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'Order validated' 'message' => 'Order validated (Ref='.$this->commande->ref.')'
) )
); );
} }
@@ -502,14 +502,14 @@ class Orders extends DolibarrApi
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*/ */
function _cleanObjectDatas($object) { function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->address); unset($object->address);
return $object; return $object;
} }
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *

View File

@@ -22,14 +22,14 @@
/** /**
* API class for invoices * API class for invoices
* *
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
*/ */
class Invoices extends DolibarrApi class Invoices extends DolibarrApi
{ {
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'socid' 'socid'
@@ -54,23 +54,23 @@ class Invoices extends DolibarrApi
* Get properties of a invoice object * Get properties of a invoice object
* *
* Return an array with invoice informations * Return an array with invoice informations
* *
* @param int $id ID of invoice * @param int $id ID of invoice
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
{ {
if(! DolibarrApiAccess::$user->rights->facture->lire) { if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -80,9 +80,9 @@ class Invoices extends DolibarrApi
/** /**
* List invoices * List invoices
* *
* Get a list of invoices * Get a list of invoices
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
@@ -96,12 +96,12 @@ class Invoices extends DolibarrApi
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
@@ -109,7 +109,7 @@ class Invoices extends DolibarrApi
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."facture as t"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('facture').')'; $sql.= ' WHERE t.entity IN ('.getEntity('facture').')';
@@ -117,7 +117,7 @@ class Invoices extends DolibarrApi
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status // Filter by status
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)";
@@ -129,7 +129,7 @@ class Invoices extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (! DolibarrApi::_checkFilters($sqlfilters)) if (! DolibarrApi::_checkFilters($sqlfilters))
{ {
@@ -138,7 +138,7 @@ class Invoices extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0)
@@ -174,10 +174,10 @@ class Invoices extends DolibarrApi
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create invoice object * Create invoice object
* *
* @param array $request_data Request datas * @param array $request_data Request datas
* @return int ID of invoice * @return int ID of invoice
*/ */
@@ -188,7 +188,7 @@ class Invoices extends DolibarrApi
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach($request_data as $field => $value) { foreach($request_data as $field => $value) {
$this->invoice->$field = $value; $this->invoice->$field = $value;
} }
@@ -203,7 +203,7 @@ class Invoices extends DolibarrApi
} }
$this->invoice->lines = $lines; $this->invoice->lines = $lines;
}*/ }*/
if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { if ($this->invoice->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors));
} }
@@ -214,20 +214,20 @@ class Invoices extends DolibarrApi
* Update invoice * Update invoice
* *
* @param int $id Id of invoice to update * @param int $id Id of invoice to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
if(! DolibarrApiAccess::$user->rights->facture->creer) { if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -236,13 +236,13 @@ class Invoices extends DolibarrApi
if ($field == 'id') continue; if ($field == 'id') continue;
$this->invoice->$field = $value; $this->invoice->$field = $value;
} }
if($this->invoice->update($id, DolibarrApiAccess::$user)) if($this->invoice->update($id, DolibarrApiAccess::$user))
return $this->get ($id); return $this->get ($id);
return false; return false;
} }
/** /**
* Delete invoice * Delete invoice
* *
@@ -258,16 +258,16 @@ class Invoices extends DolibarrApi
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if( $this->invoice->delete($id) < 0) if( $this->invoice->delete($id) < 0)
{ {
throw new RestException(500); throw new RestException(500);
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
@@ -275,13 +275,76 @@ class Invoices extends DolibarrApi
) )
); );
} }
/**
* Validate an order
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "idwarehouse": 0,
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse=0, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
)
);
}
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
unset($object->address);
return $object;
}
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
* @param array|null $data Datas to validate * @param array|null $data Datas to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)
@@ -294,5 +357,5 @@ class Invoices extends DolibarrApi
} }
return $invoice; return $invoice;
} }
} }

View File

@@ -83,17 +83,17 @@ class box_activity extends ModeleBoxes
$cachetime = 3600; $cachetime = 3600;
$fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache';
$now = dol_now(); $now = dol_now();
$nbofyears=2; $nbofperiod=3;
if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION; if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION;
$textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofyears*12); $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $textHead, 'text' => $textHead,
'limit'=> dol_strlen($textHead), 'limit'=> dol_strlen($textHead),
); );
// compute the year limit to show // compute the year limit to show
$tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y"); $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m");
$cumuldata = array(); $cumuldata = array();
@@ -103,6 +103,7 @@ class box_activity extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
// part 1
$cachedir = DOL_DATA_ROOT.'/facture/temp'; $cachedir = DOL_DATA_ROOT.'/facture/temp';
$filename = '/boxactivity-invoice'.$fileid; $filename = '/boxactivity-invoice'.$fileid;
@@ -189,6 +190,7 @@ class box_activity extends ModeleBoxes
); );
} }
// part 2
$cachedir = DOL_DATA_ROOT.'/facture/temp'; $cachedir = DOL_DATA_ROOT.'/facture/temp';
$filename = '/boxactivity-invoice2'.$fileid; $filename = '/boxactivity-invoice2'.$fileid;

View File

@@ -46,6 +46,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
{ {
if (empty($minLength)) $minLength=1; if (empty($minLength)) $minLength=1;
$dataforrenderITem='ui-autocomplete';
$dataforitem='ui-autocomplete-item';
// Allow two constant to use other values for backward compatibility
if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
// Input search_htmlname is original field // Input search_htmlname is original field
// Input htmlname is a second input field used when using ajax autocomplete. // Input htmlname is a second input field used when using ajax autocomplete.
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />'; $script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
@@ -185,10 +191,10 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
$("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code. $("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code.
} }
,delay: 500 ,delay: 500
}).data("ui-autocomplete")._renderItem = function( ul, item ) { }).data("'.$dataforrenderITem.'")._renderItem = function( ul, item ) {
return $("<li>") return $("<li>")
.data( "ui-autocomplete-item", item ) // jQuery UI > 1.10.0 .data( "'.$dataforitem.'", item ) // jQuery UI > 1.10.0
.append( \'<a><span class="tag">\' + item.label + "</span></a>" ) .append( \'<a><span class="tag">\' + item.label + "</span></a>" )
.appendTo(ul); .appendTo(ul);
}; };

View File

@@ -2200,7 +2200,7 @@ function getModuleDirForApiClass($module)
elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
$moduledirforclass = 'product/stock'; $moduledirforclass = 'product/stock';
} }
elseif ($module == 'fournisseur' || $module == 'supplierinvoices') { elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') {
$moduledirforclass = 'fourn'; $moduledirforclass = 'fourn';
} }
elseif ($module == 'expensereports') { elseif ($module == 'expensereports') {

View File

@@ -629,9 +629,11 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
// User // User
/*
print '<td class="nowrap">'; print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time'); print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>'; print '</td>';
*/
// Ref // Ref
print '<td>'; print '<td>';
@@ -835,9 +837,11 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
// User // User
/*
print '<td class="nowrap">'; print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time'); print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>'; print '</td>';
*/
// Ref // Ref
print '<td class="nowrap">'; print '<td class="nowrap">';

View File

@@ -182,7 +182,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
//print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
// And now we search all its sons of lower level // And now we search all its sons of lower level
tree_recur($tab,$tab[$x],$rang+1); tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
print '</li>'; print '</li>';
} }
elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
@@ -206,7 +206,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'; print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
print $tab[$x]['title']; print $tab[$x]['title'];
print '</a></strong>'; print '</a></strong>';
print '&nbsp; (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
print '</td><td align="right">'; print '</td><td align="right">';
print $tab[$x]['buttons']; print $tab[$x]['buttons'];
print '</td></tr></table>'; print '</td></tr></table>';
@@ -219,7 +219,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
// And now we search all its sons of lower level // And now we search all its sons of lower level
//print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n";
tree_recur($tab,$tab[$x],$rang+1); tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
print '</li>'; print '</li>';
} }
} }

View File

@@ -50,7 +50,7 @@ class modWebsites extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this)); $this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Enable to build and serve public websites with CMS features"; $this->description = "Enable to build and serve public websites with CMS features";
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version $this->version = 'development'; // 'experimental' or 'dolibarr' or version
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)

View File

@@ -23,14 +23,14 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
/** /**
* API class for supplier invoices * API class for supplier invoices
* *
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
*/ */
class SupplierInvoices extends DolibarrApi class SupplierInvoices extends DolibarrApi
{ {
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'socid' 'socid'
@@ -55,24 +55,24 @@ class SupplierInvoices extends DolibarrApi
* Get properties of a supplier invoice object * Get properties of a supplier invoice object
* *
* Return an array with supplier invoice information * Return an array with supplier invoice information
* *
* @param int $id ID of supplier invoice * @param int $id ID of supplier invoice
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id)
{ {
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found'); throw new RestException(404, 'Supplier invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -81,9 +81,9 @@ class SupplierInvoices extends DolibarrApi
/** /**
* List invoices * List invoices
* *
* Get a list of supplier invoices * Get a list of supplier invoices
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
@@ -97,12 +97,12 @@ class SupplierInvoices extends DolibarrApi
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
@@ -110,14 +110,14 @@ class SupplierInvoices extends DolibarrApi
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status // Filter by status
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)";
@@ -129,7 +129,7 @@ class SupplierInvoices extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (! DolibarrApi::_checkFilters($sqlfilters)) if (! DolibarrApi::_checkFilters($sqlfilters))
{ {
@@ -138,7 +138,7 @@ class SupplierInvoices extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0)
@@ -174,10 +174,10 @@ class SupplierInvoices extends DolibarrApi
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create supplier invoice object * Create supplier invoice object
* *
* @param array $request_data Request datas * @param array $request_data Request datas
* @return int ID of supplier invoice * @return int ID of supplier invoice
*/ */
@@ -188,7 +188,7 @@ class SupplierInvoices extends DolibarrApi
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach($request_data as $field => $value) { foreach($request_data as $field => $value) {
$this->invoice->$field = $value; $this->invoice->$field = $value;
} }
@@ -203,7 +203,7 @@ class SupplierInvoices extends DolibarrApi
} }
$this->invoice->lines = $lines; $this->invoice->lines = $lines;
}*/ }*/
if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { if ($this->invoice->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors)); throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors));
} }
@@ -214,21 +214,21 @@ class SupplierInvoices extends DolibarrApi
* Update supplier invoice * Update supplier invoice
* *
* @param int $id Id of supplier invoice to update * @param int $id Id of supplier invoice to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found'); throw new RestException(404, 'Supplier invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@@ -236,13 +236,13 @@ class SupplierInvoices extends DolibarrApi
if ($field == 'id') continue; if ($field == 'id') continue;
$this->invoice->$field = $value; $this->invoice->$field = $value;
} }
if($this->invoice->update($id, DolibarrApiAccess::$user)) if($this->invoice->update($id, DolibarrApiAccess::$user))
return $this->get ($id); return $this->get ($id);
return false; return false;
} }
/** /**
* Delete supplier invoice * Delete supplier invoice
* *
@@ -258,16 +258,16 @@ class SupplierInvoices extends DolibarrApi
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found'); throw new RestException(404, 'Supplier invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) if( $this->invoice->delete(DolibarrApiAccess::$user) < 0)
{ {
throw new RestException(500); throw new RestException(500);
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
@@ -275,8 +275,56 @@ class SupplierInvoices extends DolibarrApi
) )
); );
} }
/**
* Validate an order
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "idwarehouse": 0,
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse=0, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice validated (Ref='.$this->invoice->ref.')'
)
);
}
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
@@ -284,20 +332,20 @@ class SupplierInvoices extends DolibarrApi
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*/ */
function _cleanObjectDatas($object) { function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->rowid); unset($object->rowid);
return $object; return $object;
} }
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
* @param array $data Datas to validate * @param array $data Datas to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
*/ */
function _validate($data) function _validate($data)

View File

@@ -0,0 +1,365 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
/**
* API class for supplier orders
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class SupplierOrders extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid'
);
/**
* @var CommandeFournisseur $order {@type CommandeFournisseur}
*/
public $order;
/**
* Constructor
*/
function __construct()
{
global $db, $conf;
$this->db = $db;
$this->order = new CommandeFournisseur($this->db);
}
/**
* Get properties of a supplier order object
*
* Return an array with supplier order information
*
* @param int $id ID of supplier order
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) {
throw new RestException(401);
}
$result = $this->order->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier order not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
return $this->_cleanObjectDatas($this->order);
}
/**
* List orders
*
* Get a list of supplier orders
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
* @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of order objects
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
global $db, $conf;
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)";
if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)";
if ($status == 'running') $sql.= " AND t.fk_statut IN (3)";
if ($status == 'received_start') $sql.= " AND t.fk_statut IN (4)";
if ($status == 'received_end') $sql.= " AND t.fk_statut IN (5)";
if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (6,7)";
if ($status == 'refused') $sql.= " AND t.fk_statut IN (9)";
// Insert sale filter
if ($search_sale > 0)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result)
{
$i = 0;
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$order_static = new CommandeFournisseur($db);
if($order_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($order_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve supplier order list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No supplier order found');
}
return $obj_ret;
}
/**
* Create supplier order object
*
* @param array $request_data Request datas
* @return int ID of supplier order
*/
function post($request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
$this->order->$field = $value;
}
if(! array_keys($request_data,'date')) {
$this->order->date = dol_now();
}
/* We keep lines as an array
if (isset($request_data["lines"])) {
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->order->lines = $lines;
}*/
if ($this->order->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors));
}
return $this->order->id;
}
/**
* Update supplier order
*
* @param int $id Id of supplier order to update
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
throw new RestException(401);
}
$result = $this->order->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier order not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
$this->order->$field = $value;
}
if($this->order->update($id, DolibarrApiAccess::$user))
return $this->get ($id);
return false;
}
/**
* Delete supplier order
*
* @param int $id Supplier order ID
* @return type
*/
function delete($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) {
throw new RestException(401);
}
$result = $this->order->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier order not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( $this->order->delete(DolibarrApiAccess::$user) < 0)
{
throw new RestException(500);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Supplier order deleted'
)
);
}
/**
* Validate an order
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "idwarehouse": 0,
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse=0, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
throw new RestException(401);
}
$result = $this->order->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Order: '.$this->order->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Order validated (Ref='.$this->order->ref.')'
)
);
}
/**
* Clean sensible object datas
*
* @param Object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
unset($object->rowid);
return $object;
}
/**
* Validate fields before create or update object
*
* @param array $data Datas to validate
* @return array
*
* @throws RestException
*/
function _validate($data)
{
$order = array();
foreach (SupplierOrders::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$order[$field] = $data[$field];
}
return $order;
}
}

View File

@@ -41,6 +41,8 @@ $action=GETPOST('action','aZ09');
$confirm=GETPOST('confirm'); $confirm=GETPOST('confirm');
$cancel=GETPOST('cancel','alpha'); $cancel=GETPOST('cancel','alpha');
$projectid = GETPOST('projectid','int');
// Security check // Security check
$socid = GETPOST('socid','int'); $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@@ -133,7 +135,7 @@ if (empty($reshook))
$object->rate = $rate; $object->rate = $rate;
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public');
$object->fk_project = GETPOST('fk_project'); $object->fk_project = GETPOST('projectid','int');
$accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_capital = GETPOST('accountancy_account_capital');
$accountancy_account_insurance = GETPOST('accountancy_account_insurance'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance');
@@ -215,7 +217,7 @@ if (empty($reshook))
if ($action == 'classin' && $user->rights->loan->write) if ($action == 'classin' && $user->rights->loan->write)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->setProject(GETPOST('projectid')); $result = $object->setProject($projectid);
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@@ -309,7 +311,7 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
$numproject=$formproject->select_projects(-1,GETPOST("fk_project"),'fk_project',16,0,1,1); $numproject=$formproject->select_projects(-1, $projectid, 'projectid', 16, 0, 1, 1);
print '</td></tr>'; print '</td></tr>';
} }
@@ -443,21 +445,21 @@ if ($id > 0)
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer) if ($user->rights->loan->write)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);

View File

@@ -89,8 +89,38 @@ if ($object->id)
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref loan // Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
// Project
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ';
if ($user->rights->loan->write) {
//if ($action != 'classify')
// $morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>'; $morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';

View File

@@ -57,8 +57,38 @@ dol_fiche_head($head, 'info', $langs->trans("Loan"), -1, 'bill');
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref loan // Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
// Project
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ';
if ($user->rights->loan->write) {
//if ($action != 'classify')
// $morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>'; $morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';

View File

@@ -74,8 +74,38 @@ if ($id > 0)
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref loan // Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
// Project
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ';
if ($user->rights->loan->write) {
//if ($action != 'classify')
// $morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>'; $morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';

View File

@@ -1199,7 +1199,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<!-- Includes JS for JQuery -->'."\n"; print '<!-- Includes JS for JQuery -->'."\n";
if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n"; if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n"; else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
if (! empty($conf->global->MAIN_FEATURES_LEVEL)) if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED'))
{ {
if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print '<script type="text/javascript" src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n"; if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print '<script type="text/javascript" src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n"; else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
@@ -2002,7 +2002,7 @@ if (! function_exists("llxFooter"))
} }
// Wrapper to manage dropdown // Wrapper to manage dropdown
if ($conf->use_javascript_ajax) if (! empty($conf->use_javascript_ajax) && ! defined('JS_JQUERY_DISABLE_DROPDOWN'))
{ {
print "\n<!-- JS CODE TO ENABLE dropdown -->\n"; print "\n<!-- JS CODE TO ENABLE dropdown -->\n";
print '<script type="text/javascript"> print '<script type="text/javascript">

View File

@@ -236,7 +236,7 @@ class modMyModule extends DolibarrModules
'leftmenu'=>'', 'leftmenu'=>'',
'url'=>'/mymodule/mymoduleindex.php', 'url'=>'/mymodule/mymoduleindex.php',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000, 'position'=>1000+$r,
'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
@@ -253,7 +253,7 @@ class modMyModule extends DolibarrModules
'leftmenu'=>'mymodule', 'leftmenu'=>'mymodule',
'url'=>'/mymodule/myobject_list.php', 'url'=>'/mymodule/myobject_list.php',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1100, 'position'=>1000+$r,
'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
@@ -265,7 +265,7 @@ class modMyModule extends DolibarrModules
'leftmenu'=>'mymodule', 'leftmenu'=>'mymodule',
'url'=>'/mymodule/myobject_page.php?action=create', 'url'=>'/mymodule/myobject_page.php?action=create',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1101, 'position'=>1000+$r,
'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',

View File

@@ -64,6 +64,7 @@ $day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"
$day = (int) $day; $day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$search_categ=GETPOST("search_categ",'alpha');
$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_usertoprocessid=GETPOST('search_usertoprocessid', 'int');
$search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_ref=GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha');
@@ -100,13 +101,14 @@ $object=new Task($db);
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{ {
$action = ''; $action = '';
$search_categ='';
$search_usertoprocessid = ''; $search_usertoprocessid = '';
$search_task_ref = ''; $search_task_ref = '';
$search_task_label = ''; $search_task_label = '';
$search_project_ref = ''; $search_project_ref = '';
$search_thirdparty = ''; $search_thirdparty = '';
} }
if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search")) if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha'))
{ {
$action = ''; $action = '';
} }
@@ -394,15 +396,41 @@ print '</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>'; print '<div class="clearboth" style="padding-bottom: 8px;"></div>';
$moreforfilter='';
// Filter on categories
/*if (! empty($conf->categorie->enabled))
{
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectCategories'). ': ';
$moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
$moreforfilter.='</div>';
}*/
// If the user can view user other than himself
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
$includeonly='hierachyme';
if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.='</div>';
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
$usersettoshow='hierarchyme';
if ($user->rights->projet->all->lire) $usersettoshow='';
print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150');
print '</td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
@@ -422,7 +450,6 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("User").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>'; print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>'; print '<td>'.$langs->trans("ProjectRef").'</td>';
@@ -454,7 +481,7 @@ if (count($tasksarray) > 0)
} }
else else
{ {
print '<tr><td colspan="14">'.$langs->trans("NoTasks").'</td></tr>'; print '<tr><td colspan="13">'.$langs->trans("NoTasks").'</td></tr>';
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@@ -65,6 +65,7 @@ $day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"
$day = (int) $day; $day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$search_categ=GETPOST("search_categ",'alpha');
$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_usertoprocessid=GETPOST('search_usertoprocessid', 'int');
$search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_ref=GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha');
@@ -113,13 +114,14 @@ $object=new Task($db);
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{ {
$action = ''; $action = '';
$search_categ='';
$search_usertoprocessid = ''; $search_usertoprocessid = '';
$search_task_ref = ''; $search_task_ref = '';
$search_task_label = ''; $search_task_label = '';
$search_project_ref = ''; $search_project_ref = '';
$search_thirdparty = ''; $search_thirdparty = '';
} }
if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search")) if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha'))
{ {
$action = ''; $action = '';
} }
@@ -313,6 +315,7 @@ $morewherefilter='';
if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref);
if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label); if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label);
if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty);
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
@@ -387,15 +390,42 @@ print '</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>'; print '<div class="clearboth" style="padding-bottom: 8px;"></div>';
$moreforfilter='';
// Filter on categories
/*
if (! empty($conf->categorie->enabled))
{
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectCategories'). ': ';
$moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
$moreforfilter.='</div>';
}*/
// If the user can view user other than himself
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
$includeonly='hierachyme';
if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.='</div>';
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
$usersettoshow='hierarchyme';
if ($user->rights->projet->all->lire) $usersettoshow='';
print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150');
print '</td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
@@ -416,7 +446,6 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("User").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>'; print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>'; print '<td>'.$langs->trans("ProjectRef").'</td>';
@@ -453,7 +482,7 @@ if (count($tasksarray) > 0)
$level=0; $level=0;
projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask); projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask);
$colspan=8; $colspan=7;
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++;
print '<tr class="liste_total"> print '<tr class="liste_total">
@@ -470,7 +499,7 @@ if (count($tasksarray) > 0)
} }
else else
{ {
print '<tr><td colspan="16">'.$langs->trans("NoTasks").'</td></tr>'; print '<tr><td colspan="15">'.$langs->trans("NoTasks").'</td></tr>';
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@@ -336,7 +336,7 @@ $listofreferent=array(
'table'=>'fichinter', 'table'=>'fichinter',
'datefieldname'=>'date_valid', 'datefieldname'=>'date_valid',
'disableamount'=>0, 'disableamount'=>0,
'margin'=>'minus', 'margin'=>'minus',
'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid,
'lang'=>'interventions', 'lang'=>'interventions',
'buttonnew'=>'AddIntervention', 'buttonnew'=>'AddIntervention',
@@ -417,9 +417,9 @@ $listofreferent=array(
'lang'=>'compta', 'lang'=>'compta',
'buttonnew'=>'AddSocialContribution', 'buttonnew'=>'AddSocialContribution',
'testnew'=>$user->rights->tax->charges->lire, 'testnew'=>$user->rights->tax->charges->lire,
'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire),
'project_task'=>array( 'project_task'=>array(
'name'=>"TaskTimeValorised", 'name'=>"TaskTimeSpent",
'title'=>"ListTaskTimeUserProject", 'title'=>"ListTaskTimeUserProject",
'class'=>'Task', 'class'=>'Task',
'margin'=>'minus', 'margin'=>'minus',
@@ -573,7 +573,7 @@ foreach ($listofreferent as $key => $value)
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount;
elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty);
else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount();
elseif ($tablename == 'projet_task') elseif ($tablename == 'projet_task')
{ {
if ($idofelementuser) if ($idofelementuser)
@@ -598,7 +598,7 @@ foreach ($listofreferent as $key => $value)
if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line; if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line;
if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount;
else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount();
elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty);
elseif ($tablename == 'projet_task') elseif ($tablename == 'projet_task')
{ {
@@ -629,7 +629,7 @@ foreach ($listofreferent as $key => $value)
$total_ttc = -$total_ttc; $total_ttc = -$total_ttc;
} }
switch ($classname) { /*switch ($classname) {
case 'FactureFournisseur': case 'FactureFournisseur':
$newclassname = 'SupplierInvoice'; $newclassname = 'SupplierInvoice';
break; break;
@@ -653,12 +653,12 @@ foreach ($listofreferent as $key => $value)
break; break;
default: default:
$newclassname = $classname; $newclassname = $classname;
} }*/
$var = ! $var; $var = ! $var;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Module // Module
print '<td align="left">'.$langs->trans($newclassname).'</td>'; print '<td align="left">'.$name.'</td>';
// Nb // Nb
print '<td align="right">'.$i.'</td>'; print '<td align="right">'.$i.'</td>';
// Amount HT // Amount HT
@@ -711,7 +711,7 @@ foreach ($listofreferent as $key => $value)
$idtofilterthirdparty=0; $idtofilterthirdparty=0;
$array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur'); $array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur');
if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty))
{ {
$idtofilterthirdparty=$object->thirdparty->id; $idtofilterthirdparty=$object->thirdparty->id;
if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
@@ -854,7 +854,7 @@ foreach ($listofreferent as $key => $value)
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>'; print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>';
} }
print "</td>\n"; print "</td>\n";
// Ref // Ref
print '<td align="left" class="nowrap">'; print '<td align="left" class="nowrap">';
if ($tablename == 'expensereport_det') if ($tablename == 'expensereport_det')
@@ -922,7 +922,7 @@ foreach ($listofreferent as $key => $value)
print dol_print_date($element->datep,'dayhour'); print dol_print_date($element->datep,'dayhour');
if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef,'dayhour'); if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef,'dayhour');
} }
else if (in_array($tablename, array('projet_task'))) else if (in_array($tablename, array('projet_task')))
{ {
$tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$idofelement.'&withproject=1">'; print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$idofelement.'&withproject=1">';
@@ -1018,7 +1018,7 @@ foreach ($listofreferent as $key => $value)
else else
{ {
$othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled"));
} }
} }
else else
{ {
@@ -1074,8 +1074,8 @@ foreach ($listofreferent as $key => $value)
$total_ht_by_third += $total_ht_by_line; $total_ht_by_third += $total_ht_by_line;
$total_ttc_by_third += $total_ttc_by_line; $total_ttc_by_third += $total_ttc_by_line;
$total_time = $total_time + $total_time_by_line; $total_time = $total_time + $total_time_by_line;
} }
if (canApplySubtotalOn($tablename)) if (canApplySubtotalOn($tablename))
@@ -1115,7 +1115,7 @@ foreach ($listofreferent as $key => $value)
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>'; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("Total").' : '.price($total_ht).'</td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("Total").' : '.price($total_ht).'</td>';
print '<td align="right">'; print '<td align="right">';
if (empty($value['disableamount'])) if (empty($value['disableamount']))
{ {
if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht);
} }
@@ -1123,7 +1123,7 @@ foreach ($listofreferent as $key => $value)
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>'; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td align="right" width="100"></td>'; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td align="right" width="100"></td>';
print '<td align="right">'; print '<td align="right">';
if (empty($value['disableamount'])) if (empty($value['disableamount']))
{ {
if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc);
} }

View File

@@ -98,12 +98,12 @@ if ($id > 0 || ! empty($ref))
$param=($mode=='mine'?'&mode=mine':''); $param=($mode=='mine'?'&mode=mine':'');
// Project card // Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Title // Title
$morehtmlref.=$object->title; $morehtmlref.=$object->title;
@@ -113,29 +113,29 @@ if ($id > 0 || ! empty($ref))
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
} }
$morehtmlref.='</div>'; $morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref. // Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire) if (! $user->rights->projet->all->lire)
{ {
$objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0);
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
} }
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Visibility // Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject'); if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject'); else print $langs->trans('PrivateProject');
print '</td></tr>'; print '</td></tr>';
// Date start - end // Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($object->date_start,'dayhour'); $start = dol_print_date($object->date_start,'dayhour');
@@ -145,45 +145,45 @@ if ($id > 0 || ! empty($ref))
print ($end?$end:'?'); print ($end?$end:'?');
if ($object->hasDelay()) print img_warning("Late"); if ($object->hasDelay()) print img_warning("Late");
print '</td></tr>'; print '</td></tr>';
// Budget // Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>'; print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>'; print '</td></tr>';
// Other attributes // Other attributes
$cols = 2; $cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Description // Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($object->description); print nl2br($object->description);
print '</td></tr>'; print '</td></tr>';
// Categories // Categories
if($conf->categorie->enabled) { if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id,'project',1); print $form->showCategories($object->id,'project',1);
print "</td></tr>"; print "</td></tr>";
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
dol_fiche_end(); dol_fiche_end();
} }

View File

@@ -371,6 +371,7 @@ llxHeader("", $title, $help_url);
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_all != '') $param.='&search_all='.$search_all;
if ($search_sday) $param.='&search_sday='.$search_sday; if ($search_sday) $param.='&search_sday='.$search_sday;
if ($search_smonth) $param.='&search_smonth='.$search_smonth; if ($search_smonth) $param.='&search_smonth='.$search_smonth;
if ($search_syear) $param.='&search_syear=' .$search_syear; if ($search_syear) $param.='&search_syear=' .$search_syear;
@@ -378,7 +379,6 @@ if ($search_eday) $param.='&search_eday='.$search_eday;
if ($search_emonth) $param.='&search_emonth='.$search_emonth; if ($search_emonth) $param.='&search_emonth='.$search_emonth;
if ($search_eyear) $param.='&search_eyear=' .$search_eyear; if ($search_eyear) $param.='&search_eyear=' .$search_eyear;
if ($socid) $param.='&socid='.$socid; if ($socid) $param.='&socid='.$socid;
if ($search_all != '') $param.='&search_all='.$search_all;
if ($search_ref != '') $param.='&search_ref='.$search_ref; if ($search_ref != '') $param.='&search_ref='.$search_ref;
if ($search_label != '') $param.='&search_label='.$search_label; if ($search_label != '') $param.='&search_label='.$search_label;
if ($search_societe != '') $param.='&search_societe='.$search_societe; if ($search_societe != '') $param.='&search_societe='.$search_societe;
@@ -451,7 +451,7 @@ if (! empty($conf->categorie->enabled))
// If the user can view user other than himself // If the user can view user other than himself
$moreforfilter.='<div class="divsearchfield">'; $moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
$includeonly=''; $includeonly='hierachyme';
if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.='</div>'; $moreforfilter.='</div>';

View File

@@ -32,9 +32,6 @@ if (empty($usedolheader))
<!-- Includes for JQuery (Ajax library) --> <!-- Includes for JQuery (Ajax library) -->
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/css/smoothness/jquery-ui.css" /> <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/css/smoothness/jquery-ui.css" />
<!-- <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css" /> --> <!-- <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css" /> -->
<?php if ($_GET["dol_use_jmobile"] == 1) { ?>
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/mobile/jquery.mobile-latest.min.css" />
<?php } ?>
<link rel="stylesheet" type="text/css" title="default" href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php<?php echo ($_GET["dol_use_jmobile"] == 1)?'?dol_use_jmobile=1&dol_optimize_smallscreen=1':''; ?>" /> <link rel="stylesheet" type="text/css" title="default" href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php<?php echo ($_GET["dol_use_jmobile"] == 1)?'?dol_use_jmobile=1&dol_optimize_smallscreen=1':''; ?>" />
<!-- Includes JS for JQuery --> <!-- Includes JS for JQuery -->
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery.min.js"></script> <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery.min.js"></script>
@@ -43,9 +40,6 @@ if (empty($usedolheader))
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js"></script> <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js"></script>
<!-- <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/js/jquery.dataTables.js"></script> --> <!-- <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/js/jquery.dataTables.js"></script> -->
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/select2/select2.min.js?version=4.0.0-beta"></script> <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/select2/select2.min.js?version=4.0.0-beta"></script>
<?php if ($_GET["dol_use_jmobile"] == 1) { ?>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/mobile/jquery.mobile-latest.min.js"></script>
<?php } ?>
</head> </head>
<body style="padding: 10px;"> <body style="padding: 10px;">
@@ -74,7 +68,7 @@ else
'/includes/pdfmake/vfs_fonts.js' '/includes/pdfmake/vfs_fonts.js'
); );
*/ */
llxHeader('','','','',0,0,$arrayjs,$arraycss); llxHeader('','','','',0,0,$arrayjs,$arraycss);
} }
@@ -92,7 +86,7 @@ This page is a sample of page using tables. It is designed to make test with<br>
- tablednd<br> - tablednd<br>
</h2> </h2>
<?php ?> <?php ?>
<br><hr><br>Example 0a : Table with div+div+div containg a select that should be overflowed and truncated => Use this to align text or form<br> <br><hr><br>Example 0a : Table with div+div+div containg a select that should be overflowed and truncated => Use this to align text or form<br>
@@ -139,7 +133,7 @@ This page is a sample of page using tables. It is designed to make test with<br>
<br><hr><br>Example 1 : Standard table/thead/tbody/tr/th-td (no class pair/impair on td) => Use this if you need the drag and drop for lines or for long result tables<br> <br><hr><br>Example 1 : Standard table/thead/tbody/tr/th-td (no class pair/impair on td) => Use this if you need the drag and drop for lines or for long result tables<br>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
/*jQuery(document).ready(function() { /*jQuery(document).ready(function() {
$(document).ready(function() { $(document).ready(function() {
@@ -157,7 +151,7 @@ $(document).ready(function() {
});*/ });*/
</script> </script>
<?php <?php
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$productspecimen=new Product($db); $productspecimen=new Product($db);
@@ -223,7 +217,7 @@ if (! empty($moreforfilter))
} }
?> ?>
<table class="stripe row-border order-column centpercent tagtable liste<?php echo $moreforfilter?" listwithfilterbefore":""; ?>" id="tablelines3"> <table class="stripe row-border order-column centpercent tagtable liste<?php echo $moreforfilter?" listwithfilterbefore":""; ?>" id="tablelines3">
<thead> <thead>
<tr class="liste_titre"> <tr class="liste_titre">
@@ -243,7 +237,7 @@ if (! empty($moreforfilter))
<br> <br>
<!-- <!--
<br><hr><br>Example 1b : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br> <br><hr><br>Example 1b : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br>

View File

@@ -2188,6 +2188,11 @@ span.butAction, span.butActionDelete {
border: 1px solid #bbb; border: 1px solid #bbb;
} }
.butActionTransparent {
color: #222 ! important;
background-color: transparent ! important;
}
<?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?> <?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?>
.butActionRefused { .butActionRefused {
display: none; display: none;
@@ -2656,7 +2661,6 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se
} }
tr.liste_titre th, tr.liste_titre td, th.liste_titre tr.liste_titre th, tr.liste_titre td, th.liste_titre
{ {
/* border-bottom: 1px solid #<?php echo ($colorbacktitle1 == '255,255,255'?'BBBBBB':'ddd'); ?>; */
border-bottom: 1px solid #888; border-bottom: 1px solid #888;
} }
tr.liste_titre:first-child th, tr:first-child th.liste_titre { tr.liste_titre:first-child th, tr:first-child th.liste_titre {
@@ -2782,6 +2786,13 @@ div.tabBar .noborder {
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
} }
ul.noborder li:nth-child(even):not(.liste_titre) {
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
}
/* /*
@@ -2808,7 +2819,7 @@ div.tabBar .noborder {
} }
.boxstats { .boxstats {
padding: 3px; padding: 3px;
width: 105px; width: 103px;
} }
.boxstats130 { .boxstats130 {
width: 160px; width: 160px;
@@ -3431,6 +3442,15 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; }
cursor:pointer; cursor:pointer;
} }
/* ============================================================================== */
/* Gantt
/* ============================================================================== */
td.gtaskname {
overflow: hidden;
text-overflow: ellipsis;
}
/* ============================================================================== */ /* ============================================================================== */
/* jQuery - jeditable */ /* jQuery - jeditable */

View File

@@ -2161,7 +2161,6 @@ span.butAction, span.butActionDelete {
} }
/* Prepare for bootstrap look */
.button, .butAction, .butActionDelete, .butActionRefused { .button, .butAction, .butActionDelete, .butActionRefused {
border-color: #c5c5c5; border-color: #c5c5c5;
border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25);
@@ -2257,7 +2256,10 @@ a.butAction:hover, a.butActionDelete:hover {
opacity: 0.9; opacity: 0.9;
} }
/* End bootstrap */ .butActionTransparent {
color: #222 ! important;
background-color: transparent ! important;
}
<?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?> <?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
.butActionRefused { .butActionRefused {
@@ -2626,6 +2628,15 @@ div.pagination li.paginationafterarrows {
} }
*/ */
ul.noborder li:nth-child(odd):not(.liste_titre) {
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
background-color: rgb(<?php echo $colorbacklinepair2; ?>) !important;
}
/* Set the color for hover lines */ /* Set the color for hover lines */
.oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover .oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover
{ {
@@ -2726,19 +2737,19 @@ tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, tabl
{ {
height: 26px !important; height: 26px !important;
} }
div.liste_titre, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr
{ {
background: rgb(<?php echo $colorbacktitle1; ?>); background: rgb(<?php echo $colorbacktitle1; ?>);
font-weight: <?php echo $useboldtitle?'bold':'normal'; ?>; font-weight: <?php echo $useboldtitle?'bold':'normal'; ?>;
border-bottom: 1px solid #FDFFFF;
color: rgb(<?php echo $colortexttitle; ?>); color: rgb(<?php echo $colortexttitle; ?>);
font-family: <?php print $fontlist ?>; font-family: <?php print $fontlist ?>;
border-bottom: 1px solid #FDFFFF;
text-align: <?php echo $left; ?>; text-align: <?php echo $left; ?>;
} }
tr.liste_titre th, tr.liste_titre td, th.liste_titre, form.liste_titre div, div.liste_titre tr.liste_titre th, tr.liste_titre td, th.liste_titre
{ {
border-bottom: 1px solid #<?php echo ($colorbacktitle1 == '255,255,255'?'BBBBBB':'FDFFFF'); ?>; border-bottom: 1px solid #aaa;
} }
/* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ /* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */
tr:first-child th.liste_titre { tr:first-child th.liste_titre {
@@ -2892,7 +2903,7 @@ div .tdtop {
} }
.boxstats { .boxstats {
padding: 3px; padding: 3px;
width: 105px; width: 100px;
} }
.boxstats130 { .boxstats130 {
width: 135px; width: 135px;
@@ -3514,6 +3525,17 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; }
cursor:pointer; cursor:pointer;
} }
/* ============================================================================== */
/* Gantt
/* ============================================================================== */
td.gtaskname {
overflow: hidden;
text-overflow: ellipsis;
}
/* ============================================================================== */ /* ============================================================================== */
/* jQuery - jeditable */ /* jQuery - jeditable */
/* ============================================================================== */ /* ============================================================================== */