diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index ac51e43f2ef..3cb86055d0e 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -179,7 +179,7 @@ class modMyModule extends DolibarrModules // Cronjobs $this->cronjobs = array(); // List of cron jobs entries to add - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600), + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) // ); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 55b9e103474..ec03e023e7a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -72,11 +72,29 @@ if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='c.rowid'; +if (! $sortfield) $sortfield='c.ref'; if (! $sortorder) $sortorder='DESC'; $viewstatut=GETPOST('viewstatut'); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('orderlist')); + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'c.ref'=>'Ref', + 'c.ref_client'=>'RefCustomerOrder', + 'pd.description'=>'Description', + 's.nom'=>"ThirdParty", + 'c.note_public'=>'NotePublic', +); +if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; + + +/* + * Actions + */ + // 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 { @@ -96,24 +114,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $billed=''; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('orderlist')); - -// List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 'c.ref'=>'Ref', - 'c.ref_client'=>'RefCustomerOrder', - 'pd.description'=>'Description', - 's.nom'=>"ThirdParty", - 'c.note_public'=>'NotePublic', -); -if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; - - -/* - * Actions - */ - $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 35238d71a2f..f89d1220e4a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -504,43 +504,6 @@ class FactureRec extends Facture } } - - /** - * Rend la facture automatique - * - * @param User $user User object - * @param int $freq Freq - * @param string $courant Courant - * @return int 0 if OK, <0 if KO - */ - function set_auto($user, $freq, $courant) - { - if ($user->rights->facture->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec "; - $sql .= " SET frequency = '".$freq."', last_gen='".$courant."'"; - $sql .= " WHERE rowid = ".$this->id; - - $resql = $this->db->query($sql); - - if ($resql) - { - $this->frequency = $freq; - $this->last_gen = $courant; - return 0; - } - else - { - dol_print_error($this->db); - return -1; - } - } - else - { - return -2; - } - } - /** * Return clicable name (with picto eventually) * diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 51e47c0ee8a..4fa103b49e0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1118,7 +1118,9 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e if (! is_object($outputlangs)) $outputlangs=$langs; if (! $format) $format='daytextshort'; $reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0; - + $formatwithoutreduce = preg_replace('/reduceformat/','',$format); + if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day + // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index b35ca382c03..4a3b5cf710d 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -251,7 +251,7 @@ function project_admin_prepare_head() * @param string $inc Line number (start to 0, then increased by recursive call) * @param string $parent Id of parent project to show (0 to show all) * @param Task[] $lines Array of lines - * @param int $level Level (start to 0, then increased/decrease by recursive call) + * @param int $level Level (start to 0, then increased/decrease by recursive call), or -1 to show all level in order of $lines without the recursive groupment feature. * @param string $var Color * @param int $showproject Show project columns * @param int $taskrole Array of roles of user for each tasks @@ -281,12 +281,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t for ($i = 0 ; $i < $numlines ; $i++) { - if ($parent == 0) $level = 0; + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines // Process line // print "i:".$i."-".$lines[$i]->fk_project.'
'; - if ($lines[$i]->fk_parent == $parent) + if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines { // Show task line. $showline=1; @@ -459,9 +459,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (! $showlineingray) $inc++; - $level++; - if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); - $level--; + if ($level >= 0) // Call sublevels + { + $level++; + if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); + $level--; + } + $total_projectlinesa_spent += $lines[$i]->duration; $total_projectlinesa_planned += $lines[$i]->planned_workload; if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration; @@ -473,7 +477,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0) && $level==0) + if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0) && $level <= 0) { print ''; print ''.$langs->trans("Total").''; @@ -800,17 +804,19 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; $alreadyspent=''; if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); + $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); + $tableCell =''; - $tableCell.=''; - //$placeholder=' placeholder="00:00"'; - $placeholder=''; - //if (! $disabledtask) - //{ - $tableCell.='+'; - $tableCell.=''; - //} + if ($alreadyspent) + { + $tableCell.=''; + //$placeholder=' placeholder="00:00"'; + $placeholder=''; + //$tableCell.='+'; + } + $tableCell.=''; $tableCell.=''; print $tableCell; } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index badaecbc17d..912b432174e 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -265,7 +265,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3703__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3800__+MAX_llx_menu__, 'project', '', 7__+MAX_llx_menu__, '/projet/activity/index.php?leftmenu=projects&mode=mine', 'MyActivities', 0, 'projects', '$user->rights->projet->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3801__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&action=create&mode=mine', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3801__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&action=create', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3802__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks/list.php?leftmenu=projects&mode=mine', 'List', 1, 'projects', '$user->rights->projet->lire', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3803__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects&mode=mine', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 3, __ENTITY__); -- Tools diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f6b626b3d28..2af8ed09118 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1191,7 +1191,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { // Project affected to user $newmenu->add("/projet/activity/index.php?mode=mine", $langs->trans("MyActivities"), 0, $user->rights->projet->lire); - $newmenu->add("/projet/tasks.php?action=create&mode=mine", $langs->trans("NewTask"), 1, $user->rights->projet->creer); + $newmenu->add("/projet/tasks.php?action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks/list.php?mode=mine", $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/activity/perweek.php?mode=mine", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer); diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index d3d81ed7723..11d904f58d4 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -906,6 +906,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $label = isset($this->cronjobs[$key]['label'])?$this->cronjobs[$key]['label']:''; $jobtype = isset($this->cronjobs[$key]['jobtype'])?$this->cronjobs[$key]['jobtype']:''; $class = isset($this->cronjobs[$key]['class'])?$this->cronjobs[$key]['class']:''; + $objectname = isset($this->cronjobs[$key]['objectname'])?$this->cronjobs[$key]['objectname']:''; $method = isset($this->cronjobs[$key]['method'])?$this->cronjobs[$key]['method']:''; $command = isset($this->cronjobs[$key]['command'])?$this->cronjobs[$key]['command']:''; $parameters = isset($this->cronjobs[$key]['parameters'])?$this->cronjobs[$key]['parameters']:''; @@ -917,6 +918,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; $sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'"; if ($class) $sql.= " AND classesname = '".$this->db->escape($class)."'"; + if ($objectname) $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; if ($method) $sql.= " AND methodename = '".$this->db->escape($method)."'"; if ($command) $sql.= " AND command = '".$this->db->escape($command)."'"; $sql.= " AND entity = ".$conf->entity; @@ -934,13 +936,14 @@ class DolibarrModules // Can not be abstract, because we need to insta if (! $err) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, label, jobtype, classesname, methodename, command, params, note, frequency, unitfrequency, entity)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, label, jobtype, classesname, objectname, methodename, command, params, note, frequency, unitfrequency, entity)"; $sql.= " VALUES ("; $sql.= "'".$this->db->escape($this->rights_class)."', "; $sql.= "'".$this->db->idate($now)."', "; $sql.= "'".$this->db->escape($label)."', "; $sql.= "'".$this->db->escape($jobtype)."', "; $sql.= ($class?"'".$this->db->escape($class)."'":"null").","; + $sql.= ($objectname?"'".$this->db->escape($objectname)."'":"null").","; $sql.= ($method?"'".$this->db->escape($method)."'":"null").","; $sql.= ($command?"'".$this->db->escape($command)."'":"null").","; $sql.= ($parameters?"'".$this->db->escape($parameters)."'":"null").","; @@ -949,7 +952,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= "'".$this->db->escape($unitfrequency)."', "; $sql.= $conf->entity; $sql.= ")"; -print $sql; dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3996a2ca710..eaba97d093b 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -107,7 +107,7 @@ class modFacture extends DolibarrModules // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'Facture', 'method'=>'generateRecurringInvoices', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24), + 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'Facture', 'method'=>'generateRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) ); // List of cron jobs entries to add diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 569c85b2ce8..e91b359ed98 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -42,6 +42,7 @@ $id=GETPOST('id','int'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $cancel=GETPOST('cancel'); +$backtourl=GETPOST('backtourl','alpha'); /* @@ -60,14 +61,22 @@ if (!empty($id)) if (!empty($cancel)) { - if (!empty($id)) + if (!empty($id) && empty($backtourl)) { $action=''; } else { - Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2'); - exit; + if ($backtourl) + { + header("Location: ".$backtourl); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2'); + exit; + } } } @@ -134,8 +143,9 @@ if ($action=='add') $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); $object->unitfrequency=GETPOST('unitfrequency','int'); - $object->frequency=$object->unitfrequency * GETPOST('nbfrequency','int'); - + $object->frequency=GETPOST('nbfrequency','int'); + $object->maxrun=GETPOST('maxrun','int'); + // Add cron task $result = $object->create($user); @@ -168,8 +178,9 @@ if ($action=='update') $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); $object->unitfrequency=GETPOST('unitfrequency','int'); - $object->frequency=$object->unitfrequency * GETPOST('nbfrequency','int'); - + $object->frequency=GETPOST('nbfrequency','int'); + $object->maxrun=GETPOST('maxrun','int'); + // Add cron task $result = $object->update($user); @@ -291,6 +302,7 @@ if (($action=="create") || ($action=="edit")) { print '
'; print ''."\n"; + print ''."\n"; if (!empty($object->id)) { print ''."\n"; print ''."\n"; @@ -318,105 +330,6 @@ if (($action=="create") || ($action=="edit")) print ""; print "\n"; - print ""; - print $langs->trans('CronDtStart').""; - if(!empty($object->datestart)) - { - $form->select_date($object->datestart,'datestart',1,1,'',"cronform"); - } - else - { - $form->select_date('','datestart',1,1,'',"cronform"); - } - print ""; - print ""; - print ""; - print "\n"; - - print ""; - print $langs->trans('CronDtEnd').""; - if(!empty($object->dateend)){ - $form->select_date($object->dateend,'dateend',1,1,'',"cronform"); - } - else{ - $form->select_date('','dateend',1,1,1,"cronform"); - } - print ""; - print ""; - print ""; - print "\n"; - - print ""; - print $langs->trans('CronPriority').""; - $priority=0; - if (!empty($object->priority)) { - $priority=$object->priority; - } - print " "; - print ""; - print ""; - print ""; - print "\n"; - - print ""; - print $langs->trans('CronEvery').""; - print "unitfrequency=="60") - { - $input .= ' checked />'; - } - else{ - $input .= ' />'; - } - $input .= ""; - print $input; - - $input = "unitfrequency=="3600"){ - $input .= ' checked />'; - } - else{ - $input .= ' />'; - } - $input .= ""; - print $input; - - $input = "unitfrequency=="86400"){ - $input .= ' checked />'; - } - else{ - $input .= ' />'; - } - $input .= ""; - print $input; - - $input = "unitfrequency=="604800"){ - $input .= ' checked />'; - } - else{ - $input .= ' />'; - } - $input .= ""; - print $input; - print ""; - print ""; - print ""; - print "\n"; - print ''; print $langs->trans('CronModule').""; print "module_name."\" /> "; @@ -480,6 +393,119 @@ if (($action=="create") || ($action=="edit")) print ""; print "\n"; + print ""; + print $langs->trans('CronEvery').""; + print ""; + print ""; + $input = " unitfrequency=="60") + { + $input .= ' checked />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + + $input = " unitfrequency=="3600"){ + $input .= ' checked />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + + $input = " unitfrequency=="86400"){ + $input .= ' checked />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + + $input = " unitfrequency=="604800"){ + $input .= ' checked />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + print ""; + print ""; + print ""; + print "\n"; + + print ""; + print $langs->trans('CronDtStart').""; + if(!empty($object->datestart)) + { + $form->select_date($object->datestart,'datestart',1,1,'',"cronform"); + } + else + { + $form->select_date('','datestart',1,1,'',"cronform"); + } + print ""; + print ""; + print ""; + print "\n"; + + print ""; + print $langs->trans('CronDtEnd').""; + if(!empty($object->dateend)){ + $form->select_date($object->dateend,'dateend',1,1,'',"cronform"); + } + else{ + $form->select_date('','dateend',1,1,1,"cronform"); + } + print ""; + print ""; + print ""; + print "\n"; + + print ""; + print $langs->trans('CronPriority').""; + $priority=0; + if (!empty($object->priority)) { + $priority=$object->priority; + } + print " "; + print ""; + print ""; + print ""; + print "\n"; + + print ''; + $maxrun=''; + if (!empty($object->maxrun)) { + $maxrun=$object->maxrun; + } + print $langs->trans('CronMaxRun').""; + print " "; + print ""; + print ""; + print ""; + print "\n"; + print ''; dol_fiche_end(); @@ -501,12 +527,14 @@ else dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron'); + $linkback = '' . $langs->trans("BackToList") . ''; + // box add_jobs_box print ''; print '"; - print "\n"; print '"; - print ""; - - print ""; - - print '"; - - print ""; - print ""; - - print ""; - print ""; - - print ""; - print ""; - - print ''; + print ''; } print ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2c67d41549d..397ee4a72db 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1016,7 +1016,7 @@ class Project extends CommonObject * Return array of projects a user has permission on, is affected to, or all projects * * @param User $user User object - * @param int $mode 0=All project I have permission on, 1=Projects affected to me only, 2=Will return list of all projects with no test on contacts + * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts * @param int $list 0=Return array,1=Return string list * @param int $socid 0=No filter on third party, id of third party * @return array or string Array of projects id, or string with projects id separated with "," @@ -1031,29 +1031,42 @@ class Project extends CommonObject if ($mode == 0 || $mode == 1) { $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; - $sql.= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } $sql.= " WHERE p.entity IN (".getEntity('project',1).")"; // Internal users must see project he is contact to even if project linked to a third party he can't see. //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; + // Get id of types of contacts for projects (This list never contains a lot of elements) + $listofprojectcontacttype=array(); + $sql2 = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql2.= " WHERE ctc.element = '" . $this->element . "'"; + $sql2.= " AND ctc.source = 'internal'"; + $resql = $this->db->query($sql2); + if ($resql) + { + while($obj = $this->db->fetch_object($resql)) + { + $listofprojectcontacttype[$obj->rowid]=$obj->code; + } + } + else dol_print_error($this->db); + if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found + if ($mode == 0) { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ( p.public = 1"; - $sql.= " OR ( ctc.rowid = ec.fk_c_type_contact"; - $sql.= " AND ctc.element = '" . $this->element . "'"; - $sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")"; + $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; + $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; - $sql.= " ))"; } if ($mode == 1) { $sql.= " AND ec.element_id = p.rowid"; - $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; - $sql.= " AND ctc.element = '" . $this->element . "'"; - $sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")"; + $sql.= " AND ("; + $sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; + $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } if ($mode == 2) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index a644e9663bb..b5fb7e31666 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -76,17 +76,28 @@ $search_sale=GETPOST('search_sale','int'); $optioncss = GETPOST('optioncss','alpha'); $mine = $_REQUEST['mode']=='mine' ? 1 : 0; -if ($mine) $search_user = $user->id; +if ($mine) { $search_user = $user->id; $mine=0; } -$day = GETPOST('day','int'); -$month = GETPOST('month','int'); -$year = GETPOST('year','int'); $sday = GETPOST('sday','int'); $smonth = GETPOST('smonth','int'); $syear = GETPOST('syear','int'); +$day = GETPOST('day','int'); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); if ($search_status == '') $search_status=-1; // -1 or 1 +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='p.ref'; +if (! $sortorder) $sortorder='DESC'; + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $contextpage='projectlist'; @@ -115,11 +126,11 @@ $arrayfields=array( 'p.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), 'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), 'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102), - 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmount"), 'checked'=>1, 'enabled'=>$conf->global->PROJECT_USE_OPPORTUNITIES, 'position'=>103), - 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatus"), 'checked'=>1, 'enabled'=>$conf->global->PROJECT_USE_OPPORTUNITIES, 'position'=>104), - 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>$conf->global->PROJECT_USE_OPPORTUNITIES, 'position'=>103), + 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>$conf->global->PROJECT_USE_OPPORTUNITIES, 'position'=>104), + 'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'p.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -150,12 +161,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_public=""; $search_sale=""; $search_user=''; - $day=""; - $month=""; - $year=""; $sday=""; $smonth=""; $syear=""; + $day=""; + $month=""; + $year=""; $search_array_options=array(); } @@ -171,12 +182,32 @@ $form = new Form($db); $formother = new FormOther($db); $formproject = new FormProjets($db); -llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); +$title=$langs->trans("Projects"); +if ($search_user == $user->id) $title=$langs->trans("MyProjects"); +llxHeader("",$title,"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:($user->rights->projet->all->lire?2:0)),1,$socid); +// Get list of project id allowed to user (in a string list separated by coma) +if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); -$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; +// Get id of types of contacts for projects (This list never contains a lot of elements) +$listofprojectcontacttype=array(); +$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; +$sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; +$sql.= " AND ctc.source = 'internal'"; +$resql = $db->query($sql); +if ($resql) +{ + while($obj = $db->fetch_object($resql)) + { + $listofprojectcontacttype[$obj->rowid]=$obj->code; + } +} +else dol_print_error($db); +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found + +$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. +$sql = "SELECT ".$distinct." p.rowid as projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; $sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.tms as date_update"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= ", cls.code as opp_status_code"; @@ -194,14 +225,12 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = c if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; } $sql.= " WHERE p.entity IN (".getEntity('project').')'; -if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; +if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser -//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); @@ -243,26 +272,36 @@ if ($search_opp_status) if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; -if ($search_user > 0) $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='project' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; +if ($search_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_user; // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; - $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($conf->liste_limit+1, $offset); -//print $sql; + +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit + 1,$offset); + dol_syslog("list allowed project", LOG_DEBUG); +//print $sql; $resql = $db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); - $i = 0; $param=''; - //if ($mine) $param.='&mode=mine'; + if ($sday) $param.='&sday='.$day; + if ($smonth) $param.='&smonth='.$smonth; + if ($syear) $param.='&syear=' .$syear; + if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; if ($socid) $param.='&socid='.$socid; @@ -311,12 +350,6 @@ if ($resql) print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } - - $colspan=8; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan+=2; - if (empty($conf->global->PROJECT_LIST_HIDE_STARTDATE)) $colspan++; - - // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { @@ -327,7 +360,7 @@ if ($resql) $moreforfilter.=''; } - // If the user can view prospects other than his' + // If the user can view user other than himself $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; $includeonly=''; @@ -351,15 +384,15 @@ if ($resql) print '
'; print $langs->trans('CronId')."".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id'); + print "".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id', '', '', 0); print "
'; @@ -519,43 +547,6 @@ else print $formCron->select_typejob('jobtype',$object->jobtype,1); print "
"; - print $langs->trans('CronDtStart').""; - if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhourtext');} - print "
"; - print $langs->trans('CronDtEnd').""; - if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhourtext');} - print "
'; - print $langs->trans('CronDtNextLaunch'); - print ' ('.$langs->trans('CronFrom').')'; - print ""; - if(!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhoursec');} else {print $langs->trans('CronNone');} - print "
"; - print $langs->trans('CronPriority')."".$object->priority; - print "
"; - print $langs->trans('CronNbRun')."".$object->nbrun; - print "
"; - print $langs->trans('CronEvery').""; - if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Minutes'); - if($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Hours'); - if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Days'); - if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Weeks'); - print "
'; print $langs->trans('CronModule').""; print $object->module_name; @@ -601,6 +592,53 @@ else print '
'; + print ''; + + print ""; + print ""; + + print '"; + + print ""; + + print ""; + print ""; + + print ""; + print ""; + + print ""; + print ""; + + print '"; + + print '
"; + print $langs->trans('CronEvery').""; + if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Minutes'); + if($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Hours'); + if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Days'); + if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks'); + print "
'; + print $langs->trans('CronDtStart').""; + if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhourtext');} + print "
"; + print $langs->trans('CronDtEnd').""; + if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhourtext');} + print "
"; + print $langs->trans('CronPriority')."".$object->priority; + print "
"; + print $langs->trans('CronMaxRun')."".$object->maxrun; + print "
"; + print $langs->trans('CronNbRun')."".$object->nbrun; + print "
'; + print $langs->trans('CronDtNextLaunch'); + print ' ('.$langs->trans('CronFrom').')'; + print ""; + if(!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhoursec');} else {print $langs->trans('CronNone');} + print "
'; + + print '
'; + print ''; print ''; print_liste_field_titre($langs->trans("ID"),$_SERVER["PHP_SELF"],"t.rowid","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"t.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronTask"),'','',"",$param,'',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronDtStart"),$_SERVER["PHP_SELF"],"t.datestart","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVER["PHP_SELF"],"t.dateend","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronMaxRun"),$_SERVER["PHP_SELF"],"t.maxrun","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronNbRun"),$_SERVER["PHP_SELF"],"t.nbrun","",$param,'align="right"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVER["PHP_SELF"],"t.datelastrun","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronLastResult"),$_SERVER["PHP_SELF"],"t.lastresult","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder); @@ -233,7 +234,7 @@ if ($num > 0) print ''; + + print ''; print ''; - print ''; - - print ''; - print ''; @@ -287,6 +288,10 @@ if ($num > 0) if (!empty($line->nbrun)) {print $line->nbrun;} else {print '0';} print ''; + print ''; + print ''; @@ -307,6 +312,10 @@ if ($num > 0) print ''; print ''; -print ''; -print ''; -print "\n"; -print "
'; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 39eaacd303f..a66fcd9597c 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -175,8 +175,9 @@ class Cronjob extends CommonObject $sql.= "fk_user_author,"; $sql.= "fk_user_mod,"; $sql.= "note,"; - $sql.= "nbrun"; - $sql .= ",libname"; + $sql.= "nbrun,"; + $sql.= "maxrun,"; + $sql.= "libname"; $sql.= ") VALUES ("; @@ -206,12 +207,10 @@ class Cronjob extends CommonObject $sql.= " ".$user->id.","; $sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").","; $sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'").","; + $sql.= " ".(empty($this->maxrun)?'null':"'".$this->db->escape($this->maxrun)."'").","; $sql.= " ".(! isset($this->libname)?'NULL':"'".$this->db->escape($this->libname)."'").""; - - $sql.= ")"; - $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -291,8 +290,9 @@ class Cronjob extends CommonObject $sql.= " t.fk_user_author,"; $sql.= " t.fk_user_mod,"; $sql.= " t.note,"; - $sql.= " t.nbrun"; - $sql .= ", t.libname"; + $sql.= " t.nbrun,"; + $sql.= " t.maxrun,"; + $sql.= " t.libname"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; @@ -335,6 +335,7 @@ class Cronjob extends CommonObject $this->fk_user_mod = $obj->fk_user_mod; $this->note = $obj->note; $this->nbrun = $obj->nbrun; + $this->maxrun = $obj->maxrun; $this->libname = $obj->libname; } @@ -517,6 +518,7 @@ class Cronjob extends CommonObject if (isset($this->status)) $this->status=trim($this->status); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); + if (isset($this->maxrun)) $this->maxrun=trim($this->maxrun); if (isset($this->libname)) $this->libname = trim($this->libname); // Check parameters @@ -585,10 +587,9 @@ class Cronjob extends CommonObject $sql.= " status=".(isset($this->status)?$this->status:"null").","; $sql.= " fk_user_mod=".$user->id.","; $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; - $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null"); - $sql.= ", libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null"); - - + $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null").","; + $sql.= " maxrun=".(isset($this->maxrun)?$this->maxrun:"null").","; + $sql.= " libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null"); $sql.= " WHERE rowid=".$this->id; $this->db->begin(); @@ -786,6 +787,7 @@ class Cronjob extends CommonObject $this->fk_user_mod=''; $this->note=''; $this->nbrun=''; + $this->maxrun=100; $this->libname = ''; } @@ -1087,7 +1089,7 @@ class Cronjob extends CommonObject if (empty($this->datenextrun)) { - $this->datenextrun = $now + $this->frequency; + $this->datenextrun = $now + ($this->frequency * $this->unitfrequency); } else { @@ -1096,12 +1098,14 @@ class Cronjob extends CommonObject // Loop until date is after future while ($this->datenextrun < $now) { - $this->datenextrun += $this->frequency; + $this->datenextrun += ($this->frequency * $this->unitfrequency); + + // TODO For exact frequency (every month, every year, ...), use instead a dol_time_plus_duree($time, $duration_value, $duration_unit) } } else { - //$this->datenextrun=$this->datenextrun+$this->frequency; + //$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency); } } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 9645d42261b..867695cade6 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; $langs->load("admin"); $langs->load("cron"); +$langs->load("bills"); if (!$user->rights->cron->read) accessforbidden(); @@ -174,12 +175,12 @@ print '
'; if (! empty($line->label)) { - print ''.$line->label.''; + print ''.$langs->trans($line->label).''; } else { @@ -244,20 +245,31 @@ if ($num > 0) print ''; if ($line->jobtype=='method') { - print $langs->trans('CronModule').':'.$line->module_name.'
'; - print $langs->trans('CronClass').':'. $line->classesname.'
'; - print $langs->trans('CronObject').':'. $line->objectname.'
'; - print $langs->trans('CronMethod').':'. $line->methodename; + $text=$langs->trans("CronClass"); + $texttoshow=$langs->trans('CronModule').':'.$line->module_name.'
'; + $texttoshow.=$langs->trans('CronClass').':'. $line->classesname.'
'; + $texttoshow.=$langs->trans('CronObject').':'. $line->objectname.'
'; + $texttoshow.=$langs->trans('CronMethod').':'. $line->methodename; if(!empty($line->params)) { - print '
'.$langs->trans('CronArgs').':'. $line->params; - } - - }elseif ($line->jobtype=='command') { - print $langs->trans('CronCommand').':'. dol_trunc($line->command); - if(!empty($line->params)) { - print '
'.$langs->trans('CronArgs').':'. $line->params; + $texttoshow.='
'.$langs->trans('CronArgs').':'. $line->params; } } + elseif ($line->jobtype=='command') + { + $text=$langs->trans('CronCommand'); + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($line->command); + if(!empty($line->params)) { + $texttoshow='
'.$langs->trans('CronArgs').':'. $line->params; + } + } + print $form->textwithpicto($text, $texttoshow, 1); + print '
'; + if($line->unitfrequency == "60") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Minutes'); + if($line->unitfrequency == "3600") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Hours'); + if($line->unitfrequency == "86400") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Days'); + if($line->unitfrequency == "604800") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Weeks'); print ''; @@ -268,17 +280,6 @@ if ($num > 0) if(!empty($line->dateend)) {print dol_print_date($line->dateend,'dayhour');} print ''; - if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhour');} - print ''; - if($line->unitfrequency == "60") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Minutes'); - if($line->unitfrequency == "3600") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Hours'); - if($line->unitfrequency == "86400") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Days'); - if($line->unitfrequency == "604800") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Weeks'); - print ''; if (!empty($line->maxrun)) {print $line->maxrun;} print ''; + if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhour');} + print ''; if(!empty($line->datelastrun)) {print dol_print_date($line->datelastrun,'dayhour');} print ''; + if ($user->rights->cron->create) + { + print "id."&action=edit&backtourl=".urlencode($_SERVER["PHP_SELF"])."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; + } if ($user->rights->cron->delete) { print "id."&status=".$status."&action=delete\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'),'delete')."  "; diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 95dfb2683f9..ae452f85bf8 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -33,6 +33,7 @@ -- Visible in misc page insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_NOT_INSTALLED','1','chaine','Setup is running',1,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show: -1=stable+deprecated, 0=stable only (default), 1=stable+experimental, 2=stable+experimental+development',1,0); +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_LOGTOHTML','0','chaine','If this constants is defined, it is possible to have logs inside pages by adding the parameter &logtohtml=1',1,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAILING_LIMIT_SENDBYWEB','25','chaine','Number of targets to defined packet size when sending mass email',1,0); -- Hidden and common to all entities diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 4b9bf0df0aa..911e8c957d3 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -36,3 +36,5 @@ ALTER TABLE llx_overwrite_trans ADD UNIQUE INDEX uk_overwrite_trans(lang, transk ALTER TABLE llx_cronjob MODIFY COLUMN unitfrequency varchar(255) NOT NULL DEFAULT '3600'; +ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); + diff --git a/htdocs/install/mysql/tables/llx_facture.key.sql b/htdocs/install/mysql/tables/llx_facture.key.sql index fd687e9d827..b0755bf5d94 100644 --- a/htdocs/install/mysql/tables/llx_facture.key.sql +++ b/htdocs/install/mysql/tables/llx_facture.key.sql @@ -28,6 +28,7 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_facture_source (fk_facture_sour ALTER TABLE llx_facture ADD INDEX idx_facture_fk_projet (fk_projet); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_account (fk_account); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_currency (fk_currency); +ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index bc8062a5f9d..23f9ba4b532 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -224,6 +224,7 @@ NonPercuRecuperable=Non-recoverable SetConditions=Set payment terms SetMode=Set payment mode Billed=Billed +RecurringInvoices=Recurring invoices RepeatableInvoice=Template invoice RepeatableInvoices=Template invoices Repeatable=Template diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 0d98fb099fe..1944ee0cf11 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -208,7 +208,7 @@ if ($db->type != 'pgsql') // TODO Do not use week function to be compatible with all database if ($db->type != 'pgsql') - { +{ print '
'; /* Affichage de la liste des projets de la semaine */ @@ -265,53 +265,56 @@ if ($db->type != 'pgsql') } /* Affichage de la liste des projets du mois */ -print ''; -print ''; -print ''; -print ''; -print "\n"; - -$sql = "SELECT p.rowid, p.ref, p.title, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND date_format(task_date,'%y-%m') = '".strftime("%y-%m",$now)."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title"; - -$resql = $db->query($sql); -if ( $resql ) +if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) { - $var=false; - - while ($row = $db->fetch_object($resql)) - { - print ""; - print ''; - print ''; - print "\n"; - $var=!$var; - } - $db->free($resql); + print '
'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now,"%B %Y").''.$langs->trans("Time").'
'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - print $projectstatic->getNomUrl(1, '', 1); - print ''.convertSecondToTime($row->nb).'
'; + print ''; + print ''; + print ''; + print "\n"; + + $sql = "SELECT p.rowid, p.ref, p.title, SUM(tt.task_duration) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql.= " WHERE t.fk_projet = p.rowid"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND tt.fk_task = t.rowid"; + $sql.= " AND tt.fk_user = ".$user->id; + $sql.= " AND date_format(task_date,'%y-%m') = '".strftime("%y-%m",$now)."'"; + $sql.= " AND p.rowid in (".$projectsListId.")"; + $sql.= " GROUP BY p.rowid, p.ref, p.title"; + + $resql = $db->query($sql); + if ( $resql ) + { + $var=false; + + while ($row = $db->fetch_object($resql)) + { + print ""; + print ''; + print ''; + print "\n"; + $var=!$var; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + print ''; + print ''; + print ''; + print "\n"; + print "
'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now,"%B %Y").''.$langs->trans("Time").'
'; + $projectstatic->id=$row->rowid; + $projectstatic->ref=$row->ref; + $projectstatic->title=$row->title; + print $projectstatic->getNomUrl(1, '', 1); + print ''.convertSecondToTime($row->nb).'
'.$langs->trans('Total').''.convertSecondToTime($total).'
"; } -else -{ - dol_print_error($db); -} -print '
'.$langs->trans('Total').''.convertSecondToTime($total).'
"; /* Affichage de la liste des projets de l'annee */ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4376811142b..cc31d1090f8 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -316,7 +316,7 @@ $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['fi for($i=0;$i<7;$i++) { - print '
'.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'day').'
'.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'dayreduceformat').'
'; print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($langs->trans("SalesRepresentative"),$_SERVER["PHP_SELF"],"","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($langs->trans("OpportunityAmountShort"),$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($langs->trans("OpportunityStatusShort"),$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'],$_SERVER["PHP_SELF"],"","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'],$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'],$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'],$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'],$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -376,9 +409,9 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -466,7 +499,7 @@ if ($resql) print ''; } - if (! empty($arrayfields['p.statut']['checked'])) + if (! empty($arrayfields['p.fk_statut']['checked'])) { print ''."\n"; - - while ($i < $num) + $i = 0; + while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); $projectstatic->id = $obj->projectid; $projectstatic->user_author_id = $obj->fk_user_creat; $projectstatic->public = $obj->public; - - $userAccess = $projectstatic->restrictedProjectArea($user); - + $projectstatic->ref = $obj->ref; + + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { $var=!$var; @@ -500,7 +533,6 @@ if ($resql) if (! empty($arrayfields['p.ref']['checked'])) { print ''; } @@ -636,7 +668,7 @@ if ($resql) print ''; } // Status - if (! empty($arrayfields['p.statut']['checked'])) + if (! empty($arrayfields['p.fk_statut']['checked'])) { $projectstatic->statut = $obj->fk_statut; print ''; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 48cbcb86a1a..037360bb4de 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -28,9 +28,11 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; 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'); $id=GETPOST('id','int'); @@ -38,50 +40,116 @@ $search_all=GETPOST('search_all'); $search_project=GETPOST('search_project'); if (! isset($_GET['search_projectstatus']) && ! isset($_POST['search_projectstatus'])) $search_projectstatus=1; else $search_projectstatus=GETPOST('search_projectstatus'); +$search_project_ref=GETPOST('search_project_ref'); +$search_project_title=GETPOST('search_project_title'); $search_task_ref=GETPOST('search_task_ref'); $search_task_label=GETPOST('search_task_label'); +$search_task_description=GETPOST('search_task_description'); $search_project_user=GETPOST('search_project_user'); $search_task_user=GETPOST('search_task_user'); $mine = $_REQUEST['mode']=='mine' ? 1 : 0; -if ($mine) $search_task_user = $user->id; +if ($mine) { $search_task_user = $user->id; $mine = 0; } + +$sday = GETPOST('sday','int'); +$smonth = GETPOST('smonth','int'); +$syear = GETPOST('syear','int'); +$day = GETPOST('day','int'); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$contextpage='tasklist'; + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array($contextpage)); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('project'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); -$sortfield = GETPOST("sortfield"); -$sortorder = GETPOST("sortorder"); -$page = GETPOST("page"); -$page = is_numeric($page) ? $page : 0; -$page = $page == -1 ? 0 : $page; - -// Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $search_all=""; - $search_project=""; - $search_projectstatus=""; - $search_task_ref=""; - $search_task_label=""; - $search_task_user=-1; - $search_project_user=-1; -} -if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='p.ref'; +if (! $sortorder) $sortorder='DESC'; // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 't.ref'=>"Ref", - 't.label'=>"Label", + 't.label'=>"Label", + 't.description'=>"Description", + 't.note_public'=>"NotePublic", ); +if (empty($user->socid)) $fieldstosearchall['t.note_private']="NotePrivate"; + +$arrayfields=array( + 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1), + 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>0), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>0), + 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1), + 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), + 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), + 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), + 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), + 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>102), + 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103), + 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104), + 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105), + 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} /* * Actions */ -// None +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +// Purge criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_all=""; + $search_project=""; + $search_projectstatus=-1; + $search_project_ref=""; + $search_project_title=""; + $search_task_ref=""; + $search_task_label=""; + $search_task_description=""; + $search_task_user=-1; + $search_project_user=-1; + $sday=''; + $smonth=''; + $syear=''; + $day=''; + $month=''; + $year=''; +} +if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; + + /* @@ -89,6 +157,8 @@ $fieldstosearchall = array( */ $form=new Form($db); +$formother=new FormOther($db); +$socstatic=new Societe($db); $projectstatic = new Project($db); $taskstatic = new Task($db); $puser=new User($db); @@ -97,7 +167,7 @@ if ($search_project_user > 0) $puser->fetch($search_project_user); if ($search_task_user > 0) $tuser->fetch($search_task_user); $title=$langs->trans("Activities"); -if ($mine) $title=$langs->trans("MyActivities"); +if ($search_task_user == $user->id) $title=$langs->trans("MyActivities"); llxHeader("",$title,"Projet"); @@ -107,133 +177,548 @@ if ($id) $projectstatic->societe->fetch($projectstatic->societe->id); } -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); - -// Show description of content -if ($mine) print $langs->trans("MyTasksDesc").'

'; -else -{ - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; - else print $langs->trans("ProjectsPublicDesc").'

'; -} - // Get list of project id allowed to user (in a string list separated by coma) -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); +if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); //var_dump($projectsListId); -// Get list of tasks in tasksarray and taskarrayfiltered -// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents). -$morewherefilter=''; -if ($search_all) $morewherefilter.=natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label); - -$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_projectstatus, $morewherefilter, $search_project_user, 0); // We don't use filter on task user. Because sometimes a task is assigned but not the parent one and we want to show also parent, so filtering is done during output -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, ($tuser->id?$tuser:null), $projectstatic->id, 0, $search_projectstatus); // We load also tasks limited to a particular user - -print ''; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -if ($search_all) +// Get id of types of contacts for projects (This list never contains a lot of elements) +$listofprojectcontacttype=array(); +$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; +$sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; +$sql.= " AND ctc.source = 'internal'"; +$resql = $db->query($sql); +if ($resql) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + while($obj = $db->fetch_object($resql)) + { + $listofprojectcontacttype[$obj->rowid]=$obj->code; + } +} +else dol_print_error($db); +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found +// Get id of types of contacts for tasks (This list never contains a lot of elements) +$listoftaskcontacttype=array(); +$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; +$sql.= " WHERE ctc.element = '" . $taskstatic->element . "'"; +$sql.= " AND ctc.source = 'internal'"; +$resql = $db->query($sql); +if ($resql) +{ + while($obj = $db->fetch_object($resql)) + { + $listoftaskcontacttype[$obj->rowid]=$obj->code; + } +} +else dol_print_error($db); +if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found + +$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. +$sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate"; +$sql.= ", s.nom as name, s.rowid as socid"; +$sql.= ", t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update"; +$sql.= ", t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; +// Add fields for extrafields +foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid,"; +$sql.= " ".MAIN_DB_PREFIX."projet_task as t"; +if ($search_project_user > 0) +{ + $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; +} +if ($search_task_user > 0) +{ + $sql.=", ".MAIN_DB_PREFIX."element_contact as ect"; +} +$sql.= " WHERE t.fk_projet = p.rowid"; +$sql.= " AND p.entity IN (".getEntity('project').')'; +if (! $user->rights->projet->all->lire) $sql.=" p.rowid IN (".join(',',$projectsListId).")"; // public and assigned to projects, or restricted to company for external users +// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser +if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); +if ($search_project_title) $sql .= natural_search('p.title', $search_project_title); +if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref); +if ($search_task_label) $sql .= natural_search('t.label', $search_task_label); +if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($smonth > 0) +{ + if ($syear > 0 && empty($sday)) + $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($syear,$smonth,false))."' AND '".$db->idate(dol_get_last_day($syear,$smonth,false))."'"; + else if ($syear > 0 && ! empty($sday)) + $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; + else + $sql.= " AND date_format(t.dateo, '%m') = '".$smonth."'"; +} +else if ($syear > 0) +{ + $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($syear,1,false))."' AND '".$db->idate(dol_get_last_day($syear,12,false))."'"; +} +if ($month > 0) +{ + if ($year > 0 && empty($day)) + $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND t.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(t.datee, '%m') = '".$month."'"; +} +else if ($year > 0) +{ + $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; +} +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_projectstatus >= 0) $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); +if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); +if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql.= $db->order($sortfield,$sortorder); + +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); } +$sql.= $db->plimit($limit + 1,$offset); -// If the user can view users -//if ($mine) $search_project_user=$user->id; // We want by default all project. "mine" is a filter for task contact on this page -$moreforfilter.='
'; -$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; -$includeonly=''; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user, 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); -$moreforfilter.='
'; -// If the user can view users -$moreforfilter.='
'; -$moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; -$includeonly=''; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); -$moreforfilter.='
'; - -if (! empty($moreforfilter)) +dol_syslog("list allowed project", LOG_DEBUG); +//print $sql; +$resql = $db->query($sql); +if ($resql) { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $var=true; + $num = $db->num_rows($resql); + + $param=''; + if ($sday) $param.='&sday='.$day; + if ($smonth) $param.='&smonth='.$smonth; + if ($syear) $param.='&syear=' .$syear; + if ($day) $param.='&day='.$day; + if ($month) $param.='&month='.$month; + if ($year) $param.='&year=' .$year; + if ($socid) $param.='&socid='.$socid; + if ($search_all != '') $param.='&search_all='.$search_all; + if ($search_project_ref != '') $param.='&search_project_ref='.$search_project_ref; + if ($search_project_title != '') $param.='&search_project_title='.$search_project_title; + if ($search_ref != '') $param.='&search_ref='.$search_ref; + if ($search_label != '') $param.='&search_label='.$search_label; + if ($search_societe != '') $param.='&search_societe='.$search_societe; + if ($search_projectstatus != '') $param.='&search_projectstatus='.$search_projectstatus; + if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); + if ($search_public != '') $param.='&search_public='.$search_public; + if ($search_project_user > 0) $param.='&search_project_user='.$search_project_user; + if ($search_task_user > 0) $param.='&search_task_user='.$search_task_user; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Show description of content + if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; + else + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; + else print $langs->trans("ProjectsPublicDesc").'

'; + } + + if ($search_all) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); + } + + // If the user can view users + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; + $includeonly=''; + if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); + $moreforfilter.=$form->select_dolusers($search_project_user, 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.='
'; + + // If the user can view users + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; + $includeonly=''; + if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); + $moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.='
'; + + if (! empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; print ''; print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('Draft'),'1'=>$langs->trans('Opened'),'2'=>$langs->trans('Closed')),$search_status); @@ -480,17 +513,17 @@ if ($resql) print '
'; - $projectstatic->ref = $obj->ref; print $projectstatic->getNomUrl(1); print ''.$projectstatic->getLibStatut(5).'
'; + + print ''; + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'],$_SERVER["PHP_SELF"],"t.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'],$_SERVER["PHP_SELF"],"t.dateo","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'],$_SERVER["PHP_SELF"],"t.datee","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'],$_SERVER["PHP_SELF"],"t.planned_workload","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'],$_SERVER["PHP_SELF"],"t.duration_effective","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'],$_SERVER["PHP_SELF"],"","",$param,'align="center"'); + if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'],$_SERVER["PHP_SELF"],"t.progress","",$param,'align="center"',$sortfield,$sortorder); + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } + } + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print ''; -} + if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; + print ''; + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.title']['checked'])) + { + print ''; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.fk_statut']['checked'])) + { + print ''; + } + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['t.label']['checked'])) + { + print ''; + } + // Start date + if (! empty($arrayfields['t.dateo']['checked'])) + { + print ''; + } + // End date + if (! empty($arrayfields['t.datee']['checked'])) + { + print ''; + } + if (! empty($arrayfields['t.planned_workload']['checked'])) print ''; + if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; + if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; + if (! empty($arrayfields['t.progress']['checked'])) print ''; + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) print ''; + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['t.datec']['checked'])) + { + // Date creation + print ''; + } + if (! empty($arrayfields['t.tms']['checked'])) + { + // Date modification + print ''; + } + // Action column + print ''; + print ''; + + + $i = 0; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + $projectstatic->id = $obj->projectid; + $projectstatic->ref = $obj->projectref; + $projectstatic->title = $obj->projecttitle; + $projectstatic->public = $obj->public; + $projectstatic->statut = $obj->projectstatus; + + $taskstatic->id = $obj->id; + $taskstatic->ref = $obj->ref; + $taskstatic->label = $obj->label; + $taskstatic->fk_statut = $obj->fk_statut; + $taskstatic->progress = $obj->progress; + + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? + if ($userAccess >= 0) + { + $var=!$var; + print ""; -$max=10000; + // Project url + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + // Title + if (! empty($arrayfields['p.title']['checked'])) + { + print ''; + } + // Company + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + // Status + if (! empty($arrayfields['p.fk_statut']['checked'])) + { + print ''; + } + // Ref + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + } + // Label + if (! empty($arrayfields['t.label']['checked'])) + { + print ''; + } + // Date start + if (! empty($arrayfields['t.dateo']['checked'])) + { + print ''; + } + // Date end + if (! empty($arrayfields['t.datee']['checked'])) + { + print ''; + } + + $plannedworkloadoutputformat='allhourmin'; + $timespentoutputformat='allhourmin'; + if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + + // Planned workload + if (! empty($arrayfields['t.planned_workload']['checked'])) + { + print ''; + } + // Time spent + if (! empty($arrayfields['t.duration_effective']['checked'])) + { + $showlineingray=0;$showproject=1; + print ''; + } + // Calculated progress + if (! empty($arrayfields['t.progress_calculated']['checked'])) + { + print ''; + } + // Declared progress + if (! empty($arrayfields['t.progress']['checked'])) + { + print ''; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['t.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['t.tms']['checked'])) + { + print ''; + } + // Status + /*if (! empty($arrayfields['p.fk_statut']['checked'])) + { + $projectstatic->statut = $obj->fk_statut; + print ''; + }*/ + // Action column + print ''; -if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?$max:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) -{ - $langs->load("errors"); - print ''; - print ''; + print "\n"; + + //print projectLinesa(); + } + + $i++; + } + $db->free($resql); + + $parameters=array('sql' => $sql); + $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print "
'.$langs->trans("Project").''.$langs->trans("ProjectStatus").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("PlannedWorkload"); -// TODO Replace 86400 and 7 to take account working hours per day and working day per weeks -//print '
('.$langs->trans("DelayWorkHour").')'; -print '
'.$langs->trans("TimeSpent").''.$langs->trans("ProgressCalculated").''.$langs->trans("ProgressDeclared").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $listofstatus=array(-1=>' '); + foreach($projectstatic->statuts_short as $key => $val) $listofstatus[$key]=$langs->trans($val); + print $form->selectarray('search_projectstatus', $listofstatus, $search_projectstatus); + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($syear?$syear:-1,'syear',1, 20, 5); + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; -print ''; -print ''; -$listofstatus=array(-1=>' '); -foreach($projectstatic->statuts_short as $key => $val) $listofstatus[$key]=$langs->trans($val); -print $form->selectarray('search_projectstatus', $listofstatus, $search_projectstatus); -print ''; -print ''; -print ''; -print ''; -print ''; -print ' '; -print ''; -print ''; -print ''; -print '
'; + print $projectstatic->getNomUrl(1); + print ''; + print dol_trunc($obj->projecttitle,80); + print ''; + if ($obj->socid) + { + $socstatic->id=$obj->socid; + $socstatic->name=$obj->name; + print $socstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + print $projectstatic->getLibStatut(1); + print ''; + print $taskstatic->getNomUrl(1); + print ''; + print $taskstatic->label; + print ''; + print dol_print_date($db->jdate($obj->date_start),'day'); + print ''; + print dol_print_date($db->jdate($obj->date_end),'day'); + print ''; + $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat); + $workingdelay=convertSecondToTime($obj->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + if ($obj->planned_workload != '') + { + print $fullhour; + // TODO Add delay taking account of working hours per day and working day per week + //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; + } + //else print '--:--'; + print '
'; + if ($showlineingray) print ''; + else print ''; + if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); + else print '--:--'; + if ($showlineingray) print ''; + else print ''; + print ''; + if ($obj->planned_workload || $obj->duration_effective) + { + if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %'; + else print $langs->trans('WorkloadNotDefined'); + } + print ''; + if ($obj->progress != '') + { + print $obj->progress.' %'; + } + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''.$projectstatic->getLibStatut(5).'
'; - print $langs->trans("WarningTooManyDataPleaseUseMoreFilters", $max, 'PROJECT_LIMIT_TASK_PROJECT_AREA'); - print '
"; + + print '
'; } else { - // Show all lines in taskarray (recursive function to go down on tree) - $j=0; $level=0; - //var_dump($tasksarray); - $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId, 0); + dol_print_error($db); } -print ""; - -print ''; - llxFooter(); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7a4a4b2a837..82027cd613b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -284,10 +284,15 @@ input.removedassigned { vertical-align: text-bottom; margin-bottom: -3px; } -input.smallpadd { +input.smallpadd { /* Used for timesheet input */ padding-left: 0px !important; padding-right: 0px !important; } +span.timesheetalreadyrecorded input { + /*font-size: smaller;*/ + border: none; + /*background: transparent;*/ +} select.flat, form.flat select {