From 725600e0007d730ef574948220fc547da5c7a99c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 18:37:54 +0200 Subject: [PATCH 01/10] Fix typo --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1bf86f9ffbc..1a1d36f9fb1 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -926,7 +926,7 @@ if ($source == 'contractline') { $amount=$contractline->total_ttc; - if ($contractline->fk_product && ! empty($conf->global-PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) + if ($contractline->fk_product && ! empty($conf->global->PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) { $product=new Product($db); $result=$product->fetch($contractline->fk_product); From 47d2350ad457b205cd47b9bb5c9664669765488f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 19:03:12 +0200 Subject: [PATCH 02/10] Fix bugs reported by scrutinizer --- .../mailing/class/advtargetemailing.class.php | 8 +- .../product/class/html.formproduct.class.php | 4 +- htdocs/product/class/product.class.php | 2 +- htdocs/projet/class/task.class.php | 110 +++++++++--------- 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ce6a9cf9896..ea2569b863e 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -640,16 +640,16 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]=$this->transformToSQL('t.firstname',$arrayquery['contact_firstname']); } if (!empty($arrayquery['contact_country']) && count($arrayquery['contact_country'])) { - $sqlwhere[]= " (t.fk_pays IN (".$db->escape(implode(',',$arrayquery['contact_country']))."))"; + $sqlwhere[]= " (t.fk_pays IN (".$this->db->escape(implode(',',$arrayquery['contact_country']))."))"; } if (!empty($arrayquery['contact_status']) && count($arrayquery['contact_status'])>0) { - $sqlwhere[]= " (t.statut IN (".$db->escape(implode(',',$arrayquery['contact_status']))."))"; + $sqlwhere[]= " (t.statut IN (".$this->db->escape(implode(',',$arrayquery['contact_status']))."))"; } if (!empty($arrayquery['contact_civility']) && count($arrayquery['contact_civility'])>0) { - $sqlwhere[]= " (t.civility IN ('".$db->escape(implode("','",$arrayquery['contact_civility']))."'))"; + $sqlwhere[]= " (t.civility IN ('".$this->db->escape(implode("','",$arrayquery['contact_civility']))."'))"; } if ($arrayquery['contact_no_email']!='') { - $sqlwhere[]= " (t.no_email='".$db->escape($arrayquery['contact_no_email'])."')"; + $sqlwhere[]= " (t.no_email='".$this->db->escape($arrayquery['contact_no_email'])."')"; } if ($arrayquery['contact_update_st_dt']!='') { $sqlwhere[]= " (t.tms >= '".$this->db->idate($arrayquery['contact_update_st_dt'])."' AND t.tms <= '".$this->db->idate($arrayquery['contact_update_end_dt'])."')"; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index c526e7ae52b..1c4c3249791 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -115,14 +115,14 @@ class FormProduct $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { - $sql.= " AND e.statut IN (".$db->escape(implode(',',$warehouseStatus)).")"; + $sql.= " AND e.statut IN (".$this->db->escape(implode(',',$warehouseStatus)).")"; } else { $sql.= " AND e.statut = 1"; } - if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$db->escape(implode(',', $exclude)).')'; + if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description, e.fk_parent"; $sql.= " ORDER BY e.label"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3d53e1d4089..7aecf127fea 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3750,7 +3750,7 @@ class Product extends CommonObject $sql.= " WHERE w.entity IN (".getEntity('stock').")"; $sql.= " AND w.rowid = ps.fk_entrepot"; $sql.= " AND ps.fk_product = ".$this->id; - if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql.= " AND w.statut IN (".$db->escape(implode(',',$warehouseStatus)).")"; + if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql.= " AND w.statut IN (".$this->db->escape(implode(',',$warehouseStatus)).")"; dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 3789759c2e9..0a2fddcb8b6 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -69,7 +69,7 @@ class Task extends CommonObject var $timespent_withhour; // 1 = we entered also start hours for timesheet line var $timespent_fk_user; var $timespent_note; - + var $comments = array(); public $oldcopy; @@ -1783,7 +1783,7 @@ class Task extends CommonObject return ($datetouse > 0 && ($datetouse < ($now - $conf->projet->task->warning_delay))); } - + /** * Return nb comments already posted * @@ -1793,21 +1793,21 @@ class Task extends CommonObject { return count($this->comments); } - + /** * Load comments linked with current task * * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetchComments() - { + { $this->comments = array(); $sql = "SELECT"; $sql.= " c.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; $sql.= " WHERE c.fk_task = ".$this->id; $sql.= " ORDER BY c.tms DESC"; - + dol_syslog(get_class($this)."::fetchComments", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1843,24 +1843,24 @@ class TaskComment extends CommonObject public $table_element='projet_task_comment'; //!< Name of table without prefix where object is stored public $fk_element='fk_task'; public $picto = 'task'; - + var $fk_task; - + var $description; - + var $tms; - + var $datec; - + var $fk_user; - + var $entity; - + var $import_key; - + public $oldcopy; - - + + /** * Constructor * @@ -1870,8 +1870,8 @@ class TaskComment extends CommonObject { $this->db = $db; } - - + + /** * Create into database * @@ -1882,9 +1882,9 @@ class TaskComment extends CommonObject function create($user, $notrigger=0) { global $conf, $langs; - + $error=0; - + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_comment ("; $sql.= "description"; @@ -1901,20 +1901,20 @@ class TaskComment extends CommonObject $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); $sql.= ", ".(!empty($this->import_key)?"'".$this->import_key."'":"null"); $sql.= ")"; - - var_dump($this->db); - echo $sql; - + + //var_dump($this->db); + //echo $sql; + $this->db->begin(); - + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); - + if (! $notrigger) { // Call trigger @@ -1923,7 +1923,7 @@ class TaskComment extends CommonObject // End call triggers } } - + // Commit or rollback if ($error) { @@ -1941,8 +1941,8 @@ class TaskComment extends CommonObject return $this->id; } } - - + + /** * Load object in memory from database * @@ -1953,7 +1953,7 @@ class TaskComment extends CommonObject function fetch($id) { global $langs; - + $sql = "SELECT"; $sql.= " c.rowid,"; $sql.= " c.description,"; @@ -1965,17 +1965,17 @@ class TaskComment extends CommonObject $sql.= " c.import_key"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c"; $sql.= " WHERE c.rowid = ".$id; - + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $num_rows = $this->db->num_rows($resql); - + if ($num_rows) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; $this->description = $obj->description; $this->datec = $this->db->jdate($obj->datec); @@ -1985,9 +1985,9 @@ class TaskComment extends CommonObject $this->entity = $obj->entity; $this->import_key = $obj->import_key; } - + $this->db->free($resql); - + if ($num_rows) return 1; else return 0; } @@ -1997,8 +1997,8 @@ class TaskComment extends CommonObject return -1; } } - - + + /** * Update database * @@ -2006,17 +2006,17 @@ class TaskComment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <=0 if KO, >0 if OK */ - function update($user=null, $notrigger=0) + function update($user, $notrigger=0) { global $conf, $langs; $error=0; - + // Clean parameters - if (isset($this->fk_task)) $this->fk_project=trim($this->fk_task); - if (isset($this->fk_user)) $this->fk_project=trim($this->fk_user); + if (isset($this->fk_task)) $this->fk_project=(int) trim($this->fk_task); + if (isset($this->fk_user)) $this->fk_user=(int) trim($this->fk_user); if (isset($this->description)) $this->description=trim($this->description); - - + + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; @@ -2026,13 +2026,13 @@ class TaskComment extends CommonObject $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; $sql.= " import_key=".(!empty($this->import_key)?"'".$this->import_key."'":"null"); $sql.= " WHERE rowid=".$this->id; - + $this->db->begin(); - + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { if (! $notrigger) @@ -2043,7 +2043,7 @@ class TaskComment extends CommonObject // End call triggers } } - + // Commit or rollback if ($error) { @@ -2061,8 +2061,8 @@ class TaskComment extends CommonObject return 1; } } - - + + /** * Delete task from database * @@ -2074,17 +2074,17 @@ class TaskComment extends CommonObject { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $error=0; - + $this->db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_comment"; $sql.= " WHERE rowid=".$this->id; - + $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { if (! $notrigger) @@ -2095,7 +2095,7 @@ class TaskComment extends CommonObject // End call triggers } } - + // Commit or rollback if ($error) { From 6370e2f51458360d924c192c0f0beb24646aca78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 19:03:30 +0200 Subject: [PATCH 03/10] Force type of object --- htdocs/projet/class/task.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 0a2fddcb8b6..371d214c7f8 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -2006,7 +2006,7 @@ class TaskComment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <=0 if KO, >0 if OK */ - function update($user, $notrigger=0) + function update(User $user, $notrigger=0) { global $conf, $langs; $error=0; From 2cdea7e37cc67b13c3072b512070bb2f8f428bc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 19:05:13 +0200 Subject: [PATCH 04/10] Fix bug reported by scrutinizer --- htdocs/accountancy/class/accountancycategory.class.php | 2 +- htdocs/categories/class/categorie.class.php | 6 ++++-- htdocs/core/class/html.formwebsite.class.php | 6 ++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 2715337c7fc..3e661958931 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -354,7 +354,7 @@ class AccountancyCategory } if ($thirdparty_code != 'nofilter') { - $sql .= " AND thirdparty_code = '".$ths->db->escape($thirdparty_code)."'"; + $sql .= " AND thirdparty_code = '".$this->db->escape($thirdparty_code)."'"; } dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 12804a5fab9..7a1a3985dd9 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1549,8 +1549,10 @@ class Categorie extends CommonObject } if (file_exists($dir)) { - if (is_array($file['name']) && count($file['name']) > 0) { - for($i = 0; $i <= count($file['name']); $i ++) { + if (is_array($file['name']) && count($file['name']) > 0) + { + $nbfile = count($file['name']); + for ($i = 0; $i <= $nbfile; $i ++) { $originImage = $dir . $file['name'][$i]; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 666311d1744..a42bdd0158a 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -510,8 +510,6 @@ class FormWebsite { if ($lines[$i]->fk_parent == $parent) { - $var = !$var; - //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines // Break on a new project @@ -1119,7 +1117,7 @@ class FormWebsite $emptybox=new ModeleBoxes($db); - $boxlista.="\n\n"; + $boxlista ="\n\n"; $boxlista.='
'."\n"; // Define $box_max_lines @@ -1152,7 +1150,7 @@ class FormWebsite $boxlista.= "
\n"; $boxlista.= "\n"; - $boxlistb.= "\n\n"; + $boxlistb = "\n\n"; $boxlistb.= ''; - + print '
'; /* @@ -409,7 +409,7 @@ if ($result > 0) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'supplier_payment',$socid,0,'listaction'.($genallowed?'largetitle':'')); + $somethingshown = $formactions->showactions($object,'supplier_payment',$socid,1,'listaction'.($genallowed?'largetitle':'')); print '
'; //print ''; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 84ed3e28ca5..8aa6cc3ad9a 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -505,7 +505,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'myobject', $socid); + $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1); print ''; } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 5506bad0fbb..c5eca27b348 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -487,7 +487,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'order', $socid); + $somethingshown = $formactions->showactions($object, 'order', $socid, 1); print ''; } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 8e506b5d454..3c21d9e0ced 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -184,7 +184,7 @@ if (!empty($object->id)) // List of actions on element /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'project',0);*/ + $somethingshown = $formactions->showactions($object,'project',0);*/ // List of todo actions //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 336b8c64431..04d0a09a804 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1806,7 +1806,7 @@ if ($action == 'create') // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'supplier_proposal', $socid); + $somethingshown = $formactions->showactions($object, 'supplier_proposal', $socid, 1); print ''; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ca60060c438..0eac875046b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2538,7 +2538,7 @@ else // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'user', $socid); + $somethingshown = $formactions->showactions($object, 'user', $socid, 1); print ''; diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index a32db37d3fb..678bd9f0ec2 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -517,7 +517,7 @@ else // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'usergroup', $socid); + $somethingshown = $formactions->showactions($object, 'usergroup', $socid, 1); print ''; From 7767ac2aa7cd632ad550249b8f082a5baa6ff668 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 15:12:54 +0200 Subject: [PATCH 10/10] FIX Several problem with the last event box on project/tasks --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 4 ++- htdocs/core/class/html.formactions.class.php | 30 ++++++++++++++----- htdocs/core/lib/functions2.lib.php | 9 ++++-- ...terface_50_modAgenda_ActionsAuto.class.php | 5 +++- htdocs/langs/en_US/main.lang | 1 + htdocs/projet/card.php | 4 +++ htdocs/projet/tasks/task.php | 5 ++++ 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c2dbdd46ed6..7b1c81af59c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -670,7 +670,7 @@ if ($action == 'create') } // Title - print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Label").''; // Full day print ''.$langs->trans("EventOnFullDay").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 72d3081aca3..c337616ed41 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -860,9 +860,10 @@ class ActionComm extends CommonObject * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='', $sortorder='') + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) { global $conf, $langs; @@ -879,6 +880,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); + if ($limit) $sql.=$db->plimit($limit); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index dccde65c9c3..15a9b781290 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -155,16 +155,18 @@ class FormActions * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @param string $morecss More css on table + * @param int $max Max number of record + * @param string $moreparambacktopage More param for the backtopage * @return int <0 if KO, >=0 if OK */ - function showactions($object,$typeelement,$socid=0,$forceshowtitle=0,$morecss='listactions') + function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='') { global $langs,$conf,$user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement); + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -177,12 +179,15 @@ class FormActions elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - else $title=$langs->trans("Actions"); + elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + else $title=$langs->trans("Actions"); - $buttontoaddnewevent = '
'; + $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + + $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); @@ -197,7 +202,7 @@ class FormActions print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); print ''; @@ -205,8 +210,11 @@ class FormActions $userstatic = new User($this->db); + $cursorevent = 0; foreach($listofactions as $action) { + if ($max && $cursorevent >= $max) break; + $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); @@ -226,7 +234,7 @@ class FormActions } print $action->type; print ''; - print ''.dol_print_date($action->datep,'dayhour'); + print ''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { $tmpa=dol_getdate($action->datep); @@ -254,7 +262,15 @@ class FormActions } print ''; print ''; + + $cursorevent++; } + + if ($max && $num > $max) + { + print ''.$langs->trans("More").'...'; + } + print ''; print ''; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 9d3e6ee1b63..f8a073d5fa9 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1808,6 +1808,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') $module='ficheinter'; $subelement='fichinter'; } + if ($objecttype == 'task') { + $classpath = 'projet/class'; + $module='projet'; + $subelement='task'; + } //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; @@ -2243,7 +2248,7 @@ function getModuleDirForApiClass($module) /* * Return 2 hexa code randomly - * + * * @param $min int Between 0 and 255 * @param $max int Between 0 and 255 * @return String @@ -2254,7 +2259,7 @@ function random_color_part($min=0,$max=255) { /* * Return hexadecimal color randomly - * + * * @param $min int Between 0 and 255 * @param $max int Between 0 and 255 * @return String diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 751a5fa1361..4e09fef4d43 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -747,6 +747,9 @@ class InterfaceActionsAuto extends DolibarrTriggers // Set societeforaction. if ($object->socid > 0) $societeforaction->fetch($object->socid); + $projectid = isset($object->fk_project)?$object->fk_project:0; + if ($object->element == 'project') $projectid = $object->id; + // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); @@ -754,7 +757,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg - $actioncomm->fk_project = isset($object->fk_project)?$object->fk_project:0; + $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index e9d3b0ec141..e7171fb94b1 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -410,6 +410,7 @@ ActionRunningNotStarted=To start ActionRunningShort=In progress ActionDoneShort=Finished ActionUncomplete=Uncomplete +LatestLinkedEvents=Latest %s linked events CompanyFoundation=Company/Organisation ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 73f0c06bf1e..085af055f38 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1198,6 +1198,10 @@ elseif ($object->id > 0) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', 10); print '
'; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index a04a4573aea..1b43940029f 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -588,6 +588,11 @@ if ($id > 0 || ! empty($ref)) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + print '
'; } }