From 759315aef514aee450348c8d41c853c26a247eaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2017 02:48:16 +0200 Subject: [PATCH] NEW Mass action delete available on project and tasks --- htdocs/core/actions_massactions.inc.php | 3 +- htdocs/core/ajax/row.php | 3 +- htdocs/core/lib/project.lib.php | 15 ++++++ htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/class/project.class.php | 3 +- htdocs/projet/list.php | 47 ++++++++++++---- htdocs/projet/tasks.php | 72 +++++++++++++++++-------- htdocs/projet/tasks/list.php | 46 +++++++++++++--- htdocs/projet/tasks/task.php | 13 +++-- htdocs/societe/list.php | 55 +++++++++++++++---- 10 files changed, 201 insertions(+), 57 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index a44e5f2450e..74badc6daae 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -489,7 +489,8 @@ if (! $error && $massaction == 'delete' && $permtodelete) $result=$objecttmp->fetch($toselectid); if ($result > 0) { - $result = $objecttmp->delete($user); + if ($objecttmp->element == 'societe') $result = $objecttmp->delete($objecttmp->id, $user, 1); + else $result = $objecttmp->delete($user); if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 41d411f01fd..331b4ceaac8 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2010-2015 Regis Houssin + * Copyright (C) 2017 Laurent Destailleur * * 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 diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 42e2ad57498..592988da9b9 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -150,8 +150,23 @@ function task_prepare_head($object) $head[$h][2] = 'task_contact'; $h++; + // Is there timespent ? + $nbTimeSpent=0; + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + $sql .= " AND t.fk_task =".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbTimeSpent=1; + } + else dol_print_error($db); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $head[$h][1] = $langs->trans("TimeSpent"); + if ($nbTimeSpent > 0) $head[$h][1].= ' ...'; $head[$h][2] = 'task_time'; $h++; diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index af02afaa44a..97d47589d53 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -170,6 +170,7 @@ ProjectsWithThisUserAsContact=Projects with this user as contact TasksWithThisUserAsContact=Tasks assigned to this user ResourceNotAssignedToProject=Not assigned to project ResourceNotAssignedToTheTask=Not assigned to the task +TasksAssignedTo=Tasks assigned to AssignTaskToMe=Assign task to me AssignTask=Assign ProjectOverview=Overview diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7748534c970..4bc4718368f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -593,7 +593,8 @@ class Project extends CommonObject // Set fk_projet into elements to null $listoftables=array( - 'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet','facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet', + 'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet', + 'facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet','supplier_proposal'=>'fk_projet', 'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet','don'=>'fk_projet' ); foreach($listoftables as $key => $value) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 038e9b8cdd5..3310b6d8cf7 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -32,9 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -$langs->load('projects'); -$langs->load('companies'); -$langs->load('commercial'); +$langs->loadLangs(array('projects', 'companies', 'commercial')); + +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); $title = $langs->trans("Projects"); @@ -49,6 +53,7 @@ if ($socid > 0) } if (!$user->rights->projet->lire) accessforbidden(); +$diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id; $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); @@ -155,7 +160,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_all=''; $search_categ=''; @@ -177,8 +182,18 @@ if (empty($reshook)) $day=""; $month=""; $year=""; + $toselect=''; $search_array_options=array(); } + + + // Mass actions + $objectclass='Project'; + $objectlabel='Project'; + $permtoread = $user->rights->projet->lire; + $permtodelete = $user->rights->projet->supprimer; + $uploaddir = $conf->projet->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -341,6 +356,8 @@ if (! $resql) $num = $db->num_rows($resql); +$arrayofselected=is_array($toselect)?$toselect:array(); + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); @@ -349,7 +366,8 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -llxHeader("",$title,"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); +$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +llxHeader("", $title, $help_url); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; @@ -382,6 +400,16 @@ foreach ($search_array_options as $key => $val) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } +// List of mass actions available +$arrayofmassactions = array( +// 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), +); +//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); +if ($user->rights->societe->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + print '
'; if ($optioncss != '') print ''; print ''; @@ -392,7 +420,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); // Show description of content if ($search_project_user == $user->id) print $langs->trans("MyProjectsDesc").'

'; @@ -450,6 +478,7 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -577,7 +606,7 @@ if (! empty($arrayfields['p.fk_statut']['checked'])) } // Action column print ''; @@ -831,8 +860,8 @@ while ($i < min($num,$limit)) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + if (in_array($obj->projectid, $arrayofselected)) $selected=1; + print ''; } print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 8b72a6448ec..e76ed9b2e00 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -41,8 +41,8 @@ $taskref = GETPOST('taskref', 'alpha'); $backtopage=GETPOST('backtopage','alpha'); $cancel=GETPOST('cancel'); -$mode = GETPOST('mode', 'alpha'); -$mine = ($mode == 'mine' ? 1 : 0); +$search_user_id = GETPOST('search_user_id', 'int'); + //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); @@ -62,7 +62,7 @@ $extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->tab // Security check $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result = restrictedArea($user, 'projet', $id,'projet&project'); +$result = restrictedArea($user, 'projet', $id, 'projet&project'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('projecttaskcard','globalcard')); @@ -80,6 +80,14 @@ $userAccess=0; * Actions */ +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +{ + $search_user_id=""; + $toselect=''; + $search_array_options=array(); +} + if ($action == 'createtask' && $user->rights->projet->creer) { $error=0; @@ -209,8 +217,8 @@ if ($id > 0 || ! empty($ref)) $head=project_prepare_head($object); dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); - $param=($mode=='mine'?'&mode=mine':''); - + $param=''; + if ($search_user_id > 0) $param.='&search_user_id='.dol_escape_htmltag($search_user_id); // Project card @@ -330,7 +338,6 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; print ''; if (! empty($object->id)) print ''; - if (! empty($mode)) print ''; dol_fiche_head(''); @@ -450,7 +457,16 @@ else if ($id > 0 || ! empty($ref)) print ''; - + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $title=$langs->trans("ListOfTasks"); $linktotasks=''.$langs->trans("GoToListOfTimeConsumed").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); @@ -461,7 +477,10 @@ else if ($id > 0 || ! empty($ref)) $filteronthirdpartyid = $socid; $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0); // We load also tasks limited to a particular user - $tasksrole=($mode=='mine' ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); + $tmpuser=new User($db); + if ($search_user_id > 0) $tmpuser->fetch($search_user_id); + + $tasksrole=($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); @@ -471,6 +490,22 @@ else if ($id > 0 || ! empty($ref)) } print '
'; -$searchpitco=$form->showFilterAndCheckAddButtons(0); +$searchpitco=$form->showFilterButtons(); print $searchpitco; print '
'; + + if (count($tasksarray) > 0) + { + // Link to switch in "my task" / "all task" + print ''; + + // Action column + print ''; + } + print ''; // print ''; print ''; @@ -483,37 +518,28 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print "\n"; - + if (count($tasksarray) > 0) { - // Link to switch in "my task" / "all task" - print ''; - // Show all lines in taskarray (recursive function to go down on tree) $j=0; $level=0; $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id); } else { - print ''; + print ''; } + print "
'; + print $langs->trans("TasksAssignedTo"); + print $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); + print ''; + $searchpitco=$form->showFilterButtons(); + print $searchpitco; + print '
'.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("ProgressDeclared").' 
'; - if ($mode == 'mine') - { - print ''.$langs->trans("DoNotShowMyTasksOnly").''; - } - else - { - print ''.$langs->trans("ShowMyTasksOnly").''; - } - print '
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; + print ''; + // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'
'; if (! empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) { - if ($mode=='mine') + if ($search_user_id == $user->id) { if ($nboftaskshown < count($tasksrole)) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index ca7cff35a0a..59c6d1e6afa 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -30,9 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -$langs->load('projects'); -$langs->load('users'); -$langs->load('companies'); +$langs->loadLangs(array('projects', 'users', 'companies')); + +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); $id=GETPOST('id','int'); @@ -79,6 +83,8 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); +$diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; + $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -162,8 +168,17 @@ if (empty($reshook)) $day=''; $month=''; $year=''; + $toselect=''; $search_array_options=array(); } + + // Mass actions + $objectclass='Task'; + $objectlabel='Tasks'; + $permtoread = $user->rights->projet->lire; + $permtodelete = $user->rights->projet->supprimer; + $uploaddir = $conf->projet->dir_output.'/tasks'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; @@ -337,6 +352,8 @@ if (! $resql) $num = $db->num_rows($resql); +$arrayofselected=is_array($toselect)?$toselect:array(); + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); @@ -345,7 +362,8 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -llxHeader("",$title,"Projet"); +$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +llxHeader("", $title, $help_url); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; @@ -377,6 +395,16 @@ foreach ($search_array_options as $key => $val) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } +// List of mass actions available +$arrayofmassactions = array( +// 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), +); +//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); +if ($user->rights->societe->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + print '
'; if ($optioncss != '') print ''; print ''; @@ -385,8 +413,9 @@ print ''; print ''; print ''; +print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); // Show description of content if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; @@ -442,6 +471,7 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -549,7 +579,7 @@ if (! empty($arrayfields['t.tms']['checked'])) } // Action column print ''; print "\n"; @@ -804,8 +834,8 @@ while ($i < min($num,$limit)) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + if (in_array($obj->id, $arrayofselected)) $selected=1; + print ''; } print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 3e6d658bcc1..243881821e0 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -569,9 +569,16 @@ if ($id > 0 || ! empty($ref)) } // Delete - if ($user->rights->projet->supprimer && ! $object->hasChildren() && ! $object->hasTimeSpent()) + if ($user->rights->projet->supprimer) { - print ''.$langs->trans('Delete').''; + if (! $object->hasChildren() && ! $object->hasTimeSpent()) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } } else { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 88e7a7a631e..19b26a3ceeb 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -35,12 +35,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -$langs->load("companies"); -$langs->load("commercial"); -$langs->load("customers"); -$langs->load("suppliers"); -$langs->load("bills"); -$langs->load("compta"); +$langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta")); + +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); // Security check $socid = GETPOST('socid','int'); @@ -80,7 +81,8 @@ $search_stcomm=GETPOST('search_stcomm','int'); $type=GETPOST('type'); $optioncss=GETPOST('optioncss','alpha'); $mode=GETPOST("mode"); -$action=GETPOST('action'); + +$diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); @@ -230,9 +232,18 @@ if (empty($reshook)) $search_stcomm=''; $search_level_from=''; $search_level_to=''; + $toselect=''; $search_array_options=array(); } + // Mass actions + $objectclass='Societe'; + $objectlabel='ThirdParty'; + $permtoread = $user->rights->societe->lire; + $permtodelete = $user->rights->societe->supprimer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + if ($action == 'setstcomm') { $object = new Client($db); @@ -457,6 +468,8 @@ if (! $resql) $num = $db->num_rows($resql); +$arrayofselected=is_array($toselect)?$toselect:array(); + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && $action != 'list') { $obj = $db->fetch_object($resql); @@ -513,6 +526,16 @@ if (GETPOST('delsoc')) setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); } +// List of mass actions available +$arrayofmassactions = array( +// 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), +); +//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); +if ($user->rights->societe->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + print ''; if ($optioncss != '') print ''; print ''; @@ -520,7 +543,7 @@ print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); $langs->load("other"); $textprofid=array(); @@ -586,6 +609,7 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); if (empty($arrayfields['customerorsupplier']['checked'])) print ''; @@ -837,7 +861,7 @@ if (! empty($arrayfields['s.status']['checked'])) } // Action column print ''; @@ -1100,9 +1124,18 @@ while ($i < min($num, $limit)) { print ''; } - // Action column - print ''; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + print ''."\n"; $i++; }
'; -$searchpitco=$form->showFilterAndCheckAddButtons(0); +$searchpitco=$form->showFilterButtons(); print $searchpitco; print '
'; -$searchpitco=$form->showFilterAndCheckAddButtons(0); +$searchpitco=$form->showFilterButtons(); print $searchpitco; print ''.$companystatic->getLibStatut(3).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '