diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 067f76ed2c8..35c49df8d1e 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -220,6 +220,9 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; + if ($limit > 0 && $limit != $conf->liste_limit) { + $param.='&limit='.urlencode($limit); + } $param = "&id=".urlencode($id); // Lines of title fields diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9d6b9c48192..bbc6da6a7e4 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -572,7 +572,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $numlines = count($lines); // We declare counter as global because we want to edit them into recursive call - global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed; + global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed, $total_budget_amount; if ($level == 0) { $total_projectlinesa_spent = 0; @@ -581,6 +581,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $total_projectlinesa_declared_if_planned = 0; $total_projectlinesa_tobill = 0; $total_projectlinesa_billed = 0; + $total_budget_amount = 0; } for ($i = 0; $i < $numlines; $i++) { @@ -651,6 +652,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $taskstatic->datee = $lines[$i]->date_end; // deprecated $taskstatic->planned_workload = $lines[$i]->planned_workload; $taskstatic->duration_effective = $lines[$i]->duration; + $taskstatic->budget_amount = $lines[$i]->budget_amount; if ($showproject) { @@ -850,6 +852,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } print ''; }*/ + if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) { + print ''; + print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + $total_budget_amount += $lines[$i]->budget_amount; + print ''; + } // Contacts of task if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) { @@ -921,7 +929,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0) + if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0) && $level <= 0) { print ''; print ''.$langs->trans("Total").''; @@ -1021,6 +1029,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } } + + if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) { + print ''; + print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + print ''; + } + // Contacts of task for backward compatibility, if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 56ac0290292..44f7d08bab1 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -374,3 +374,5 @@ ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOR -- Manage accountancy auxiliary account for thirdparties per entity ALTER TABLE llx_societe_perentity ADD COLUMN accountancy_code_customer varchar(24) AFTER entity; -- equivalent to code_compta in llx_societe ALTER TABLE llx_societe_perentity ADD COLUMN accountancy_code_supplier varchar(24) AFTER accountancy_code_customer; -- equivalent to code_compta_supplier in llx_societe + +ALTER TABLE llx_projet_task ADD COLUMN budget_amount double(24,8) AFTER priority; diff --git a/htdocs/install/mysql/tables/llx_projet_task.sql b/htdocs/install/mysql/tables/llx_projet_task.sql index 01edb857738..721dbf8355f 100644 --- a/htdocs/install/mysql/tables/llx_projet_task.sql +++ b/htdocs/install/mysql/tables/llx_projet_task.sql @@ -35,6 +35,7 @@ create table llx_projet_task planned_workload real DEFAULT 0, progress integer DEFAULT 0, -- percentage increase priority integer DEFAULT 0, -- priority + budget_amount double(24,8), fk_user_creat integer, -- user who created the task fk_user_modif integer, -- user who modify the task fk_user_valid integer, -- user who validated the task diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 085d092c2ac..240552ecc48 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -121,6 +121,16 @@ class Task extends CommonObject public $comments = array(); + /** + * @var float budget_amount + */ + public $budget_amount; + + /** + * @var float project_budget_amount + */ + public $project_budget_amount; + public $oldcopy; @@ -172,6 +182,7 @@ class Task extends CommonObject $sql .= ", datee"; $sql .= ", planned_workload"; $sql .= ", progress"; + $sql .= ", budget_amount"; $sql .= ") VALUES ("; $sql .= ((int) $conf->entity); $sql .= ", ".((int) $this->fk_project); @@ -185,6 +196,7 @@ class Task extends CommonObject $sql .= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : 'null'); $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? ((int) $this->planned_workload) : 'null'); $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? ((int) $this->progress) : 'null'); + $sql .= ", ".(($this->budget_amount != '' && $this->budget_amount >= 0) ? ((int) $this->budget_amount) : 'null'); $sql .= ")"; $this->db->begin(); @@ -261,6 +273,7 @@ class Task extends CommonObject $sql .= " t.fk_user_valid,"; $sql .= " t.fk_statut,"; $sql .= " t.progress,"; + $sql .= " t.budget_amount,"; $sql .= " t.priority,"; $sql .= " t.note_private,"; $sql .= " t.note_public,"; @@ -304,6 +317,7 @@ class Task extends CommonObject $this->fk_user_valid = $obj->fk_user_valid; $this->fk_statut = $obj->fk_statut; $this->progress = $obj->progress; + $this->budget_amount = $obj->budget_amount; $this->priority = $obj->priority; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; @@ -366,6 +380,9 @@ class Task extends CommonObject if (isset($this->planned_workload)) { $this->planned_workload = trim($this->planned_workload); } + if (isset($this->budget_amount)) { + $this->budget_amount = trim($this->budget_amount); + } // Check parameters // Put here code to add control on parameters values @@ -382,6 +399,7 @@ class Task extends CommonObject $sql .= " dateo=".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null').","; $sql .= " datee=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null').","; $sql .= " progress=".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null').","; + $sql .= " budget_amount=".(($this->budget_amount != '' && $this->budget_amount >= 0) ? $this->budget_amount : 'null').","; $sql .= " rang=".((!empty($this->rang)) ? $this->rang : "0"); $sql .= " WHERE rowid=".((int) $this->id); @@ -791,8 +809,9 @@ class Task extends CommonObject $sql .= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; $sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; $sql .= " t.description, "; + $sql .= " t.budget_amount, "; $sql .= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; - $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; + $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount as project_budget_amount"; if (!empty($extrafields->attributes['projet']['label'])) { foreach ($extrafields->attributes['projet']['label'] as $key => $val) { $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key." as options_".$key : ''); @@ -897,6 +916,7 @@ class Task extends CommonObject $sql .= " t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; $sql .= " t.dateo, t.datee, t.planned_workload, t.rang,"; $sql .= " t.description, "; + $sql .= " t.budget_amount, "; $sql .= " s.rowid, s.nom, s.email,"; $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; if (!empty($extrafields->attributes['projet']['label'])) { @@ -950,6 +970,7 @@ class Task extends CommonObject $tasks[$i]->opp_amount = $obj->opp_amount; $tasks[$i]->opp_percent = $obj->opp_percent; $tasks[$i]->budget_amount = $obj->budget_amount; + $tasks[$i]->project_budget_amount = $obj->project_budget_amount; $tasks[$i]->usage_bill_time = $obj->usage_bill_time; $tasks[$i]->label = $obj->label; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 2a814cd9cc5..cfd2b89b0c2 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -82,6 +82,7 @@ $search_planedworkload = GETPOST('search_planedworkload'); $search_timespend = GETPOST('search_timespend'); $search_progresscalc = GETPOST('search_progresscalc'); $search_progressdeclare = GETPOST('search_progressdeclare'); +$search_task_budget_amount = GETPOST('search_task_budget_amount'); $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int'); $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int'); @@ -142,6 +143,7 @@ $diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$ $hookmanager->initHooks(array('projecttaskscard', 'globalcard')); $progress = GETPOST('progress', 'int'); +$budget_amount = GETPOST('budget_amount', 'int'); $label = GETPOST('label', 'alpha'); $description = GETPOST('description', 'restricthtml'); $planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0); @@ -160,7 +162,8 @@ $arrayfields = array( 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>8), 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>9), 't.progress_summary'=>array('label'=>$langs->trans("TaskProgressSummary"), 'checked'=>1, 'position'=>10), - 'c.assigned'=>array('label'=>$langs->trans("TaskRessourceLinks"), 'checked'=>1, 'position'=>11), + 't.budget_amount'=>array('label'=>"Budget", 'checked'=>1, 'position'=>11), + 'c.assigned'=>array('label'=>$langs->trans("TaskRessourceLinks"), 'checked'=>1, 'position'=>12), ); if ($object->usage_bill_time) { $arrayfields['t.tobill'] = array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>11); @@ -204,6 +207,7 @@ if (empty($reshook)) { $search_timespend = ''; $search_progresscalc = ''; $search_progressdeclare = ''; + $search_task_budget_amount = ''; $toselect = ''; $search_array_options = array(); $search_date_start_startmonth = ""; @@ -285,6 +289,10 @@ if (!empty($search_progressdeclare)) { $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1); } +if ($search_task_budget_amount) { + $morewherefilterarray[]= natural_search('t.budget_amount', $search_task_budget_amount, 1, 1); +} + $morewherefilter = ''; if (count($morewherefilterarray) > 0) { $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray); @@ -338,6 +346,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) { $task->date_start = $date_start; $task->date_end = $date_end; $task->progress = $progress; + $task->budget_amount = $budget_amount; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $task); @@ -524,6 +533,9 @@ if ($id > 0 || !empty($ref)) { if ($search_progressdeclare) { $param .= '&search_progressdeclare='.urlencode($search_progressdeclare); } + if ($search_task_budget_amount) { + $param .= '&search_task_budget_amount='.urlencode($search_task_budget_amount); + } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -757,6 +769,10 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; print ''; + print ''.$langs->trans("Budget").''; + print ''; + print ''; + // Other options $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook @@ -944,6 +960,12 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } */ + if (!empty($arrayfields['t.budget_amount']['checked'])) { + print ''; + print ''; + print ''; + } + if (!empty($arrayfields['c.assigned']['checked'])) { print ''; print ''; @@ -1005,6 +1027,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder); } */ + + if (!empty($arrayfields['t.budget_amount']['checked'])) { + print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.assigned']['checked'])) { print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', ''); } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e6d8e5c6dfa..e1ed162f9c2 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -65,6 +65,7 @@ $search_task_ref_parent = GETPOST('search_task_ref_parent'); $search_project_user = GETPOST('search_project_user', 'int'); $search_task_user = GETPOST('search_task_user', 'int'); $search_task_progress = GETPOST('search_task_progress'); +$search_task_budget_amount = GETPOST('search_task_budget_amount'); $search_societe = GETPOST('search_societe'); $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; @@ -154,6 +155,7 @@ $arrayfields = array( 't.progress_calculated'=>array('label'=>"ProgressCalculated", 'checked'=>1, 'position'=>104), 't.progress'=>array('label'=>"ProgressDeclared", 'checked'=>1, 'position'=>105), 't.progress_summary'=>array('label'=>"TaskProgressSummary", 'checked'=>1, 'position'=>106), + 't.budget_amount'=>array('label'=>"Budget", 'checked'=>1, 'position'=>107), 't.tobill'=>array('label'=>"TimeToBill", 'checked'=>0, 'position'=>110), 't.billed'=>array('label'=>"TimeBilled", 'checked'=>0, 'position'=>111), 't.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -200,6 +202,7 @@ if (empty($reshook)) { $search_task_description = ""; $search_task_ref_parent = ""; $search_task_progress = ""; + $search_task_budget_amount = ""; $search_task_user = -1; $search_project_user = -1; $search_date_startday = ''; @@ -314,6 +317,7 @@ $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, "; $sql .= " t.description, t.fk_task_parent"; +$sql .= " ,t.budget_amount"; // We'll need these fields in order to filter by categ if ($search_categ) { $sql .= ", cs.fk_categorie, cs.fk_project"; @@ -390,6 +394,9 @@ if ($search_task_ref_parent) { if ($search_task_progress) { $sql .= natural_search('t.progress', $search_task_progress, 1); } +if ($search_task_budget_amount) { + $sql .= natural_search('t.budget_amount', $search_task_budget_amount, 1); +} if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } @@ -431,7 +438,7 @@ if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; $sql .= " s.nom, s.rowid,"; $sql .= " t.datec, t.dateo, t.datee, t.tms,"; - $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; + $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress,t.budget_amount, t.fk_statut"; if ($search_categ) { $sql .= ", cs.fk_categorie, cs.fk_project"; } @@ -521,6 +528,9 @@ if ($search_datelimit_endmonth) { if ($search_datelimit_endyear) { $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear); } +if ($search_task_budget_amount) { + $param .= '&search_task_budget_amount='.urlencode($search_task_budget_amount); +} if ($socid) { $param .= '&socid='.urlencode($socid); } @@ -760,6 +770,13 @@ if (!empty($arrayfields['t.progress']['checked'])) { if (!empty($arrayfields['t.progress_summary']['checked'])) { print ''; } + +if (!empty($arrayfields['t.budget_amount']['checked'])) { + print ''; + print ''; + print ''; +} + if (!empty($arrayfields['t.tobill']['checked'])) { print ''; } @@ -835,6 +852,9 @@ if (!empty($arrayfields['t.progress']['checked'])) { if (!empty($arrayfields['t.progress_summary']['checked'])) { print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['t.budget_amount']['checked'])) { + print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "t.budget_amount", "", $param, '', $sortfield, $sortorder, 'center '); +} if (!empty($arrayfields['t.tobill']['checked'])) { print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); } @@ -877,6 +897,7 @@ while ($i < min($num, $limit)) { $object->description = $obj->description; $object->fk_statut = $obj->fk_statut; $object->progress = $obj->progress; + $object->budget_amount = $obj->budget_amount; $object->date_start = $db->jdate($obj->date_start); $object->date_end = $db->jdate($obj->date_end); $object->planned_workload = $obj->planned_workload; @@ -1116,6 +1137,22 @@ while ($i < min($num, $limit)) { $totalarray['totalprogress_summary'] = $totalarray['nbfield']; } } + if (!empty($arrayfields['t.budget_amount']['checked'])) { + print ''; + print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.budget_amount'; + } + $totalarray['val']['t.budget_amount'] += $obj->budget_amount; + if (!$i) { + $totalarray['totalbudget_amount'] = $totalarray['nbfield']; + } + $totalarray['totalbudgetamount'] += $obj->budget_amount; + print ''; + } // Time not billed if (!empty($arrayfields['t.tobill']['checked'])) { print ''; @@ -1232,6 +1269,8 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota print ''.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).''; } elseif ($totalarray['totalbilledfield'] == $i) { print ''.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).''; + } elseif ($totalarray['totalbudget_amount'] == $i) { + print ''.price($totalarray['totalbudgetamount'], 0, $langs, 1, 0, 0, $conf->currency).''; } else { print ''; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 2ae9bb7cc80..42280f57c67 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -105,6 +105,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { $object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int')); $object->date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int')); $object->progress = price2num(GETPOST('progress', 'alphanohtml')); + $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml')); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -442,6 +443,10 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; + print ''.$langs->trans("Budget").''; + print ''; + print ''; + // Other options $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -564,6 +569,13 @@ if ($id > 0 || !empty($ref)) { } print ''; + // Budget + print ''.$langs->trans("Budget").''; + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + } + print ''; + // Other attributes $cols = 3; $parameters = array('socid'=>$socid);