diff --git a/README.md b/README.md index b8d067ffb7a..fbf59a27a74 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Releases can be downloaded from [official website](https://www.dolibarr.org/). You can use a Web server and a supported database (MariaDB, MySQL or PostgreSQL) to install the standard version. +- Check that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Versions). + - Uncompress the downloaded .zip archive to copy the "dolibarr/htdocs" directory and all its files inside your web server root or get the files directly from GitHub (recommanded if you known git): `git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is main version like 3.6, 9.0, ...) @@ -68,6 +70,7 @@ If you don't have time to install it yourself, you can try some commercial 'read ## UPGRADING - At first make a backup of your Dolibarr files & than see https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr +- Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md). - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. - At first next access, Dolibarr will redirect your to the "install/" page to follow the upgrade process.  If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file into the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*"). diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 96c00f48312..78b82f42b82 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -1,7 +1,8 @@ - * Copyright (C) 2015 Frederic France - * Copyright (C) 2016 Juanjo Menent +/* Copyright (C) 2013-2016 Laurent Destailleur + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juanjo Menent + * Copyright (C) 2020 Andreu Bisquerra Gaya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -355,7 +356,7 @@ if ($mode == 'config' && $user->admin) { print ''.$langs->trans("CONNECTOR_NETWORK_PRINT").':'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").''; print ''.$langs->trans("CONNECTOR_FILE_PRINT").':'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").''; print ''.$langs->trans("CONNECTOR_WINDOWS_PRINT").':'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").''; - //print ''.$langs->trans("CONNECTOR_JAVA").':'.$langs->trans("CONNECTOR_JAVA_HELP").''; + print ''.$langs->trans("CONNECTOR_CUPS_PRINT").':'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").''; print ''; dol_fiche_end(); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index aedef905b7b..887a319aefe 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -523,6 +523,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $keyforbreak = 'duration'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + print ''.$langs->trans("TotalCost").''.price($object->total_cost).''; + print ''.$langs->trans("UnitCost").''.price($object->unit_cost).''; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -542,9 +545,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - print '
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b53e2a7bc88..c2779429ebc 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -166,6 +166,16 @@ class BOM extends CommonObject */ public $lines = array(); + /** + * @var int Calculated cost for the BOM + */ + public $total_cost = 0; + + /** + * @var int Calculated cost for 1 unit of the product in BOM + */ + public $unit_cost = 0; + /** @@ -324,6 +334,7 @@ class BOM extends CommonObject { $result = $this->fetchCommon($id, $ref); if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + $this->calculateCosts(); return $result; } @@ -991,6 +1002,29 @@ class BOM extends CommonObject return $error; } + + /** + * BOM costs calculation based on cost_price or pmp of each BOM line + * @return void + */ + public function calculateCosts() + { + include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + $this->unit_cost = 0; + $this->total_cost = 0; + + foreach ($this->lines as &$line) { + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($line->fk_product); + + $line->unit_cost = (!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp; // TODO : add option to work with cost_price or pmp + $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + $this->total_cost += $line->total_cost; + } + + $this->total_cost = price2num($this->total_cost, 'MT'); + $this->unit_cost = price2num($this->total_cost / $this->qty, 'MU'); + } } @@ -1072,6 +1106,16 @@ class BOMLine extends CommonObjectLine public $import_key; // END MODULEBUILDER PROPERTIES + /** + * @var int Calculated cost for the BOM line + */ + public $total_cost = 0; + + /** + * @var int Line unit cost based on product cost price or pmp + */ + public $unit_cost = 0; + /** * Constructor diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 445466a27a1..66bcf0cece5 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -133,6 +133,11 @@ print ''; print ''; print ''; +$coldisplay++; +print ''; +print ' '; +print ''; + $coldisplay += $colspan; print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 138a0b9aa58..ce440dbaab6 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -60,13 +60,16 @@ if ($conf->global->PRODUCT_USE_UNITS) } // Qty frozen -print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; +print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; // Disable stock change -print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; +print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; // Efficiency -print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; +print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; + +// Cost +print ''.$langs->trans('CostPrice').''; print ''; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 16aa5382f53..ad2c2d3e4c6 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -103,6 +103,11 @@ $coldisplay++; echo $line->efficiency; print ''; +print ''; +$coldisplay++; +echo price($line->total_cost); +print ''; + if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { print ''; $coldisplay++; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 37bf3d36d70..3f2112537b1 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -83,7 +83,7 @@ $form = new Form($db); $userstatic = new User($db); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Summary"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Symmary"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Summary"); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index d241c2a8c5a..468cdf050bc 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -104,6 +104,7 @@ require_once DOL_DOCUMENT_ROOT.'/includes/mike42/escpos-php/autoload.php'; use Mike42\Escpos\PrintConnectors\FilePrintConnector; use Mike42\Escpos\PrintConnectors\NetworkPrintConnector; use Mike42\Escpos\PrintConnectors\WindowsPrintConnector; +use Mike42\Escpos\PrintConnectors\CupsPrintConnector; use Mike42\Escpos\PrintConnectors\DummyPrintConnector; use Mike42\Escpos\CapabilityProfile; use Mike42\Escpos\Printer; @@ -119,7 +120,7 @@ class dolReceiptPrinter extends Printer const CONNECTOR_FILE_PRINT = 2; const CONNECTOR_NETWORK_PRINT = 3; const CONNECTOR_WINDOWS_PRINT = 4; - //const CONNECTOR_JAVA = 5; + const CONNECTOR_CUPS_PRINT = 5; /** * @var DoliDB Database handler. @@ -262,7 +263,7 @@ class dolReceiptPrinter extends Printer $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; break; case 5: - $row['fk_type_name'] = 'CONNECTOR_JAVA'; + $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; break; default: $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; @@ -343,6 +344,7 @@ class dolReceiptPrinter extends Printer 2 => $langs->trans('CONNECTOR_FILE_PRINT'), 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), + 5 => $langs->trans('CONNECTOR_CUPS_PRINT'), ); $this->resprint = Form::selectarray($htmlname, $options, $selected); @@ -839,6 +841,9 @@ class dolReceiptPrinter extends Printer break; case 4: $this->connector = new WindowsPrintConnector($parameter); + break; + case 5: + $this->connector = new CupsPrintConnector($parameter); break; default: $this->connector = 'CONNECTOR_UNKNOWN'; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 39c7d3ba778..2031d23eece 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -490,9 +490,9 @@ class SMTPs } // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. - if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) + if (!$_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { - $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); + $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections.'); return $_retVal; } } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 7d3658d4f97..a31159c22d2 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1780,8 +1780,10 @@ function company_admin_prepare_head() $head[$h][2] = 'accountant'; $h++; - complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'mycompany_admin', 'add'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'mycompany_admin', 'remove'); + return $head; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e5550f9ddd0..9b9f000cf17 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -354,12 +354,13 @@ function project_admin_prepare_head() * @param int $projectidfortotallink 0 or Id of project to use on total line (link to see all time consumed for project) * @param string $filterprogresscalc filter text * @param string $showbilltime Add the column 'TimeToBill' and 'TimeBilled' + * @param array $arrayfields Array with displayed coloumn information * @return int Nb of tasks shown */ -function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc = '', $showbilltime = 0) +function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc = '', $showbilltime = 0, $arrayfields = array()) { - global $user, $langs, $conf, $db; - global $projectstatic, $taskstatic; + global $user, $langs, $conf, $db, $hookmanager; + global $projectstatic, $taskstatic, $extrafields; $lastprojectid = 0; @@ -375,7 +376,6 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } $lines = array_values($lines); } - $numlines = count($lines); // We declare counter as global because we want to edit them into recursive call @@ -487,44 +487,56 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Ref of task - print ''; - if ($showlineingray) - { - print ''.img_object('', 'projecttask').' '.$lines[$i]->ref.''; + if (count($arrayfields)>0 && !empty($arrayfields['t.ref']['checked'])) { + print ''; + if ($showlineingray) { + print '' . img_object('', 'projecttask') . ' ' . $lines[$i]->ref . ''; + } else { + print $taskstatic->getNomUrl(1, 'withproject'); + } + print ''; } - else - { - print $taskstatic->getNomUrl(1, 'withproject'); - } - print ''; // Title of task - print ""; - if ($showlineingray) print ''; - //else print ''; - for ($k = 0; $k < $level; $k++) - { - print ''; + + if (count($arrayfields)>0 && !empty($arrayfields['t.description']['checked'])) { + print ""; + print $lines[$i]->description; + print "\n"; } - if ($showlineingray) print ''; - //else print ''; - print "\n"; // Date start - print ''; - print dol_print_date($lines[$i]->date_start, 'dayhour'); - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.dateo']['checked'])) { + print ''; + print dol_print_date($lines[$i]->date_start, 'dayhour'); + print ''; + } // Date end - print ''; - print dol_print_date($lines[$i]->date_end, 'dayhour'); - if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.datee']['checked'])) { + print ''; + print dol_print_date($lines[$i]->date_end, 'dayhour'); + if ($taskstatic->hasDelay()) + print img_warning($langs->trans("Late")); + print ''; + } $plannedworkloadoutputformat = 'allhourmin'; $timespentoutputformat = 'allhourmin'; @@ -532,79 +544,88 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) - print ''; - $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); - $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks - if ($lines[$i]->planned_workload != '') - { - print $fullhour; - // TODO Add delay taking account of working hours per day and working day per week - //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; + if (count($arrayfields)>0 && !empty($arrayfields['t.planned_workload']['checked'])) { + print ''; + $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + if ($lines[$i]->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 ''; } - //else print '--:--'; - print ''; // Time spent - print ''; - if ($showlineingray) print ''; - else print ''; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); - else print '--:--'; - if ($showlineingray) print ''; - else print ''; - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.duration_effective']['checked'])) { + print ''; + if ($showlineingray) + print ''; + else print ''; + if ($lines[$i]->duration) + print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); + else print '--:--'; + if ($showlineingray) + print ''; + else print ''; + print ''; + } // Progress calculated (Note: ->duration is time spent) - print ''; - if ($lines[$i]->planned_workload || $lines[$i]->duration) - { - if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; - else print ''.$langs->trans('WorkloadNotDefined').''; + if (count($arrayfields)>0 && !empty($arrayfields['t.progress_calculated']['checked'])) { + print ''; + if ($lines[$i]->planned_workload || $lines[$i]->duration) { + if ($lines[$i]->planned_workload) + print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2) . ' %'; + else print '' . $langs->trans('WorkloadNotDefined') . ''; + } + print ''; } - print ''; // Progress declared - print ''; - if ($lines[$i]->progress != '') - { - print getTaskProgressBadge($taskstatic); + if (count($arrayfields)>0 && !empty($arrayfields['t.progress']['checked'])) { + print ''; + if ($lines[$i]->progress != '') { + print getTaskProgressBadge($taskstatic); + } + print ''; } - print ''; // resume - print ''; - if ($lines[$i]->progress != '' && $lines[$i]->duration) { - print getTaskProgressView($taskstatic, false, false); - } - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.progress_summary']['checked'])) { + print ''; + if ($lines[$i]->progress != '' && $lines[$i]->duration) { + print getTaskProgressView($taskstatic, false, false); + } + print ''; + } if ($showbilltime) { // Time not billed - print ''; - if ($lines[$i]->usage_bill_time) - { - print convertSecondToTime($lines[$i]->tobill, 'allhourmin'); - $total_projectlinesa_tobill += $lines[$i]->tobill; - } - else - { - print ''.$langs->trans("NA").''; - } - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.tobill']['checked'])) { + print ''; + if ($lines[$i]->usage_bill_time) { + print convertSecondToTime($lines[$i]->tobill, 'allhourmin'); + $total_projectlinesa_tobill += $lines[$i]->tobill; + } else { + print '' . $langs->trans("NA") . ''; + } + print ''; + } // Time billed - print ''; - if ($lines[$i]->usage_bill_time) - { - print convertSecondToTime($lines[$i]->billed, 'allhourmin'); - $total_projectlinesa_billed += $lines[$i]->billed; - } - else - { - print ''.$langs->trans("NA").''; - } - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.billed']['checked'])) { + print ''; + if ($lines[$i]->usage_bill_time) { + print convertSecondToTime($lines[$i]->billed, 'allhourmin'); + $total_projectlinesa_billed += $lines[$i]->billed; + } else { + print '' . $langs->trans("NA") . ''; + } + print ''; + } } // Contacts of task @@ -628,6 +649,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } + // Extra fields + $extrafieldsobjectkey=$taskstatic->table_element; + $obj=$lines[$i]; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$lines[$i]); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Tick to drag and drop if ($addordertick) { @@ -641,7 +671,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($level >= 0) // Call sublevels { $level++; - if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime); + if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields); $level--; } @@ -663,17 +693,23 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; print ''.$langs->trans("Total").''; if ($showproject) print ''; - print ''; - print ''; - print ''; - print ''; - print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); - print ''; - print ''; - if ($projectidfortotallink > 0) print ''; - print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); - if ($projectidfortotallink > 0) print ''; - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.label']['checked'])) print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.dateo']['checked'])) print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.datee']['checked'])) print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.planned_workload']['checked'])) { + print ''; + print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); + print ''; + } + if (count($arrayfields)>0 && !empty($arrayfields['t.duration_effective']['checked'])) { + print ''; + if ($projectidfortotallink > 0) + print ''; + print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); + if ($projectidfortotallink > 0) + print ''; + print ''; + } if ($total_projectlinesa_planned) { $totalAverageDeclaredProgress = round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2); @@ -698,33 +734,45 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - print ''; - if ($total_projectlinesa_planned) print $totalCalculatedProgress.' %'; - print ''; - print ''; - if ($total_projectlinesa_planned) print ''.$totalAverageDeclaredProgress.' %'; - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.progress_calculated']['checked'])) { + print ''; + if ($total_projectlinesa_planned) + print $totalCalculatedProgress . ' %'; + print ''; + } + if (count($arrayfields)>0 && !empty($arrayfields['t.progress']['checked'])) { + print ''; + if ($total_projectlinesa_planned) + print '' . $totalAverageDeclaredProgress . ' %'; + print ''; + } // resume - print ''; - if ($total_projectlinesa_planned) { - print ''; - print '
'; - print '
'; - print '
'; - print ''; - } - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.progress_summary']['checked'])) { + print ''; + if ($total_projectlinesa_planned) { + print ''; + print '
'; + print '
'; + print '
'; + print ''; + } + print ''; + } if ($showbilltime) { - print ''; - print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin'); - print ''; - print ''; - print convertSecondToTime($total_projectlinesa_billed, 'allhourmin'); - print ''; + if (count($arrayfields)>0 && !empty($arrayfields['t.tobill']['checked'])) { + print ''; + print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin'); + print ''; + } + if (count($arrayfields)>0 && !empty($arrayfields['t.billed']['checked'])) { + print ''; + print convertSecondToTime($total_projectlinesa_billed, 'allhourmin'); + print ''; + } } // Contacts of task if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index c6d3776cfe4..9b06fc37eff 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -8,6 +8,7 @@ if (empty($conf) || ! is_object($conf)) } if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element; +if (!isset($disablesortlink)) $disablesortlink=0; // Loop to show all columns of extrafields for the title line if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... @@ -30,7 +31,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ { $tooltip = empty($extrafields->attributes[$extrafieldsobjectkey]['help'][$key]) ? '' : $extrafields->attributes[$extrafieldsobjectkey]['help'][$key]; - print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', 0, $tooltip)."\n"; + print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', $disablesortlink, $tooltip)."\n"; } } } diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index cb2e27b1a97..c569e84c795 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -90,13 +90,14 @@ class SupplierOrders extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $product_ids Product ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of order objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $product_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -115,8 +116,11 @@ class SupplierOrders extends DolibarrApi if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if (!empty($product_ids)) $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; // We need this table joined to the select in order to filter by product + $sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if (!empty($product_ids)) $sql.= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$product_ids.")"; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 41be1d993b8..4e653e04409 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -70,4 +70,6 @@ ProductQtyToConsumeByMO=Product quantity still to consume by open MO ProductQtyToProduceByMO=Product quentity still to produce by open MO AddNewConsumeLines=Add new line to consume ProductsToConsume=Products to consume -ProductsToProduce=Products to produce \ No newline at end of file +ProductsToProduce=Products to produce +UnitCost=Unit cost +TotalCost=Total cost diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ead6dbf0ade..4a4c70d2bb7 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -266,3 +266,4 @@ InvoiceToUse=Draft invoice to use NewInvoice=New invoice OneLinePerTask=One line per task OneLinePerPeriod=One line per period +RefTaskParent=Ref. Parent Task diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 3df49b9fe67..b0b60c60840 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -15,10 +15,12 @@ CONNECTOR_DUMMY=Dummy Printer CONNECTOR_NETWORK_PRINT=Network Printer CONNECTOR_FILE_PRINT=Local Printer CONNECTOR_WINDOWS_PRINT=Local Windows Printer +CONNECTOR_CUPS_PRINT=Cups Printer CONNECTOR_DUMMY_HELP=Fake Printer for test, does nothing CONNECTOR_NETWORK_PRINT_HELP=10.x.x.x:9100 CONNECTOR_FILE_PRINT_HELP=/dev/usb/lp0, /dev/usb/lp1 CONNECTOR_WINDOWS_PRINT_HELP=LPT1, COM1, smb://FooUser:secret@computername/workgroup/Receipt Printer +CONNECTOR_CUPS_PRINT_HELP=CUPS printer name, example: HPRT_TP805L PROFILE_DEFAULT=Default Profile PROFILE_SIMPLE=Simple Profile PROFILE_EPOSTEP=Epos Tep Profile diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 96b2165c65a..a4f60d48dcd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2445,8 +2445,7 @@ class Product extends CommonObject public function load_stats_propale($socid = 0) { // phpcs:enable - global $conf; - global $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_customers, COUNT(DISTINCT p.rowid) as nb,"; $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; @@ -2497,6 +2496,10 @@ class Product extends CommonObject } } + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsCustomerProposal', $parameters, $this, $action); + if ($reshook > 0) $this->stats_propale = $hookmanager->resArray['stats_propale']; + return 1; } else @@ -2517,8 +2520,7 @@ class Product extends CommonObject public function load_stats_proposal_supplier($socid = 0) { // phpcs:enable - global $conf; - global $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,"; $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; @@ -2544,6 +2546,11 @@ class Product extends CommonObject $this->stats_proposal_supplier['nb'] = $obj->nb; $this->stats_proposal_supplier['rows'] = $obj->nb_rows; $this->stats_proposal_supplier['qty'] = $obj->qty ? $obj->qty : 0; + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsSupplierProposal', $parameters, $this, $action); + if ($reshook > 0) $this->stats_proposal_supplier = $hookmanager->resArray['stats_proposal_supplier']; + return 1; } else @@ -2566,7 +2573,7 @@ class Product extends CommonObject public function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf, $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; @@ -2644,6 +2651,9 @@ class Product extends CommonObject } } + $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); + $reshook = $hookmanager->executeHooks('loadStatsCustomerOrder', $parameters, $this, $action); + if ($reshook > 0) $this->stats_commande = $hookmanager->resArray['stats_commande']; return 1; } else @@ -2665,7 +2675,7 @@ class Product extends CommonObject public function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf, $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,"; $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; @@ -2696,6 +2706,11 @@ class Product extends CommonObject $this->stats_commande_fournisseur['nb'] = $obj->nb; $this->stats_commande_fournisseur['rows'] = $obj->nb_rows; $this->stats_commande_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; + + $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); + $reshook = $hookmanager->executeHooks('loadStatsSupplierOrder', $parameters, $this, $action); + if ($reshook > 0) $this->stats_commande_fournisseur = $hookmanager->resArray['stats_commande_fournisseur']; + return 1; } else @@ -2718,7 +2733,7 @@ class Product extends CommonObject public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $filterShipmentStatus = '') { // phpcs:enable - global $conf, $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,"; $sql .= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; @@ -2775,6 +2790,11 @@ class Product extends CommonObject } } } + + $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock, 'filterShipmentStatus' => $filterShipmentStatus); + $reshook = $hookmanager->executeHooks('loadStatsSending', $parameters, $this, $action); + if ($reshook > 0) $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + return 1; } else @@ -2796,7 +2816,7 @@ class Product extends CommonObject public function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf, $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_suppliers, COUNT(DISTINCT cf.rowid) as nb,"; $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; @@ -2823,6 +2843,11 @@ class Product extends CommonObject $this->stats_reception['nb'] = $obj->nb; $this->stats_reception['rows'] = $obj->nb_rows; $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; + + $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); + $reshook = $hookmanager->executeHooks('loadStatsReception', $parameters, $this, $action); + if ($reshook > 0) $this->stats_reception = $hookmanager->resArray['stats_reception']; + return 1; } else @@ -2844,7 +2869,7 @@ class Product extends CommonObject public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf, $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT m.fk_soc) as nb_customers, COUNT(DISTINCT m.rowid) as nb,"; $sql .= " COUNT(mp.rowid) as nb_rows, SUM(mp.qty) as qty, role"; @@ -2910,6 +2935,10 @@ class Product extends CommonObject if ($this->stats_mrptoconsume['qty'] < 0) $this->stats_mrptoconsume['qty'] = 0; if ($this->stats_mrptoproduce['qty'] < 0) $this->stats_mrptoproduce['qty'] = 0; + $parameters = array('socid' => $socid, 'filtrestatut' => $filtrestatut, 'forVirtualStock' => $forVirtualStock); + $reshook = $hookmanager->executeHooks('loadStatsInProduction', $parameters, $this, $action); + if ($reshook > 0) $this->stats_mrptoproduce = $hookmanager->resArray['stats_mrptoproduce']; + return 1; } else @@ -2929,8 +2958,7 @@ class Product extends CommonObject public function load_stats_contrat($socid = 0) { // phpcs:enable - global $conf; - global $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; @@ -2980,6 +3008,11 @@ class Product extends CommonObject } } } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsContract', $parameters, $this, $action); + if ($reshook > 0) $this->stats_contrat = $hookmanager->resArray['stats_contrat']; + return 1; } else @@ -2999,7 +3032,7 @@ class Product extends CommonObject public function load_stats_facture($socid = 0) { // phpcs:enable - global $db, $conf, $user; + global $db, $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,"; $sql .= " COUNT(fd.rowid) as nb_rows, SUM(".$db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty"; @@ -3049,6 +3082,11 @@ class Product extends CommonObject } } } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsCustomerInvoice', $parameters, $this, $action); + if ($reshook > 0) $this->stats_facture = $hookmanager->resArray['stats_facture']; + return 1; } else @@ -3068,8 +3106,7 @@ class Product extends CommonObject public function load_stats_facture_fournisseur($socid = 0) { // phpcs:enable - global $conf; - global $user; + global $conf, $user, $hookmanager; $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,"; $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; @@ -3098,6 +3135,11 @@ class Product extends CommonObject $this->stats_facture_fournisseur['nb'] = $obj->nb; $this->stats_facture_fournisseur['rows'] = $obj->nb_rows; $this->stats_facture_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsSupplierInvoice', $parameters, $this, $action); + if ($reshook > 0) $this->stats_facture_fournisseur = $hookmanager->resArray['stats_facture_fournisseur']; + return 1; } else diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 3b91c867ebe..2eb9f014831 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -158,7 +158,6 @@ class Task extends CommonObject $sql .= "entity"; $sql .= ", fk_projet"; $sql .= ", ref"; - $sql .= ", entity"; $sql .= ", fk_task_parent"; $sql .= ", label"; $sql .= ", description"; @@ -172,7 +171,6 @@ class Task extends CommonObject $sql .= $conf->entity; $sql .= ", ".$this->fk_project; $sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null'); - $sql .= ", ".$conf->entity; $sql .= ", ".$this->fk_task_parent; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->description)."'"; @@ -743,11 +741,12 @@ class Task extends CommonObject * @param string $filterontaskuser Filter on user assigned to task * @param array $extrafields Show additional column from project or task * @param int $includebilltime Calculate also the time to bill and billed + * @param array $search_array_options Array of search * @return array Array of tasks */ - public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0) + public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array()) { - global $conf; + global $conf, $hookmanager; $tasks = array(); @@ -759,6 +758,7 @@ class Task extends CommonObject $sql .= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; $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 .= " 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"; if (!empty($extrafields->attributes['projet']['label'])) @@ -853,12 +853,21 @@ class Task extends CommonObject if ($filteronproj) $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); if ($filteronprojstatus && $filteronprojstatus != '-1') $sql .= " AND p.fk_statut IN (".$filteronprojstatus.")"; if ($morewherefilter) $sql .= $morewherefilter; + // Add where from extra fields + $extrafieldsobjectkey='projet_task'; + $extrafieldsobjectprefix='efpt.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + // 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; if ($includebilltime) { $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; $sql .= " t.datec, t.dateo, t.datee, t.tms,"; $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 .= " 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'])) @@ -871,6 +880,7 @@ class Task extends CommonObject } } + $sql .= " ORDER BY p.ref, t.rang, t.dateo"; //print $sql;exit; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index b125ed7306e..a95d7162a87 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -52,6 +52,7 @@ $cancel = GETPOST('cancel', 'alpha'); $search_user_id = GETPOST('search_user_id', 'int'); $search_taskref = GETPOST('search_taskref'); $search_tasklabel = GETPOST('search_tasklabel'); +$search_taskdescription=GETPOST('search_taskdescription'); $search_dtstartday = GETPOST('search_dtstartday'); $search_dtstartmonth = GETPOST('search_dtstartmonth'); $search_dtstartyear = GETPOST('search_dtstartyear'); @@ -63,6 +64,8 @@ $search_timespend = GETPOST('search_timespend'); $search_progresscalc = GETPOST('search_progresscalc'); $search_progressdeclare = GETPOST('search_progressdeclare'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projecttasklist'; + //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); @@ -78,6 +81,7 @@ if ($id > 0 || !empty($ref)) $extrafields->fetch_name_optionals_label($object->table_element); } $extrafields->fetch_name_optionals_label($taskstatic->table_element); +$search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_element, '', 'search_'); // Security check $socid = 0; @@ -96,37 +100,36 @@ $planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planne $planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0); $planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60; +// Definition of fields for list $arrayfields = array( - '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), - '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.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.tobill'=>array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>110), - 't.billed'=>array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>111), - '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), + 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>1), + 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>2), + 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>3), + 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>4), + 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>5), + 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>6), + 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>7), + '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), ); -// Extra fields project -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +if ($object->usage_bill_time) { + $arrayfields['t.tobill']=array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>11); + $arrayfields['t.billed']=array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>12); +} + +// Extra fields +if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); } } -$object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; /* * Actions @@ -204,7 +207,6 @@ if (!empty($search_progressdeclare)) { $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1); } - $morewherefilter = ''; if (count($morewherefilterarray) > 0) { $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray); @@ -332,21 +334,18 @@ $projectstatic = new Project($db); $taskstatic = new Task($db); $userstatic = new User($db); -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); + if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); $res = $object->fetch_optionals(); - // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user, 'write'); @@ -359,8 +358,25 @@ if ($id > 0 || !empty($ref)) $head = project_prepare_head($object); dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); - $param = ''; - if ($search_user_id > 0) $param .= '&search_user_id='.dol_escape_htmltag($search_user_id); + $param = 'id='.$object->id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($search_user_id) $param .= '&search_user_id='.urlencode($search_user_id); + if ($search_taskref) $param .= '&search_taskref='.urlencode($search_taskref); + if ($search_tasklabel) $param .= '&search_tasklabel='.urlencode($search_tasklabel); + if ($search_taskdescription) $param .= '&search_taskdescription='.urlencode($search_taskdescription); + if ($search_dtstartday) $param .= '&search_dtstartday='.urlencode($search_dtstartday); + if ($search_dtstartmonth) $param .= '&search_dtstartmonth='.urlencode($search_dtstartmonth); + if ($search_dtstartyear) $param .= '&search_dtstartyear='.urlencode($search_dtstartyear); + if ($search_dtendday) $param .= '&search_dtendday='.urlencode($search_dtendday); + if ($search_dtendmonth) $param .= '&search_dtendmonth='.urlencode($search_dtendmonth); + if ($search_dtendyear) $param .= '&search_dtendyear='.urlencode($search_dtendyear); + if ($search_planedworkload) $param .= '&search_planedworkload='.urlencode($search_planedworkload); + if ($search_timespend) $param .= '&search_timespend='.urlencode($search_timespend); + if ($search_progresscalc) $param .= '&search_progresscalc='.urlencode($search_progresscalc); + if ($search_progressdeclare) $param .= '&search_progressdeclare='.urlencode($search_progressdeclare); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Project card @@ -425,25 +441,6 @@ if ($id > 0 || !empty($ref)) else print $langs->trans('PrivateProject'); print ''; - /*if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { - // Opportunity status - print ''.$langs->trans("OpportunityStatus").''; - $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); - print ''; - - // Opportunity percent - print ''.$langs->trans("OpportunityProbability").''; - if (strcmp($object->opp_percent,'')) print price($object->opp_percent,'',$langs,1,0).' %'; - print ''; - - // Opportunity Amount - print ''.$langs->trans("OpportunityAmount").''; - if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,1,0,0,$conf->currency); - print ''; - }*/ - // Date start - end print ''.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'day'); @@ -618,27 +615,12 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } elseif ($id > 0 || !empty($ref)) { + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + /* * Projet card in view mode */ - // Definition of fields for list - $arrayfields = array(); - $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); - $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); - $arrayfields['t.task_date_start'] = array('label'=>$langs->trans("DateStart"), 'checked'=>1); - $arrayfields['t.task_date_end'] = array('label'=>$langs->trans("DateEnd"), 'checked'=>1); - // Extra fields - if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) - { - foreach ($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) - $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); - } - } - $arrayfields = dol_sort_array($arrayfields, 'position'); - print '
'; // Link to create task @@ -654,7 +636,6 @@ elseif ($id > 0 || !empty($ref)) $linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam); - print ''; if ($optioncss != '') print ''; print ''; @@ -674,7 +655,7 @@ elseif ($id > 0 || !empty($ref)) // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $filteronthirdpartyid = $socid; - $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, array(), 1); + $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options); // We load also tasks limited to a particular user $tmpuser = new User($db); if ($search_user_id > 0) $tmpuser->fetch($search_user_id); @@ -704,64 +685,90 @@ elseif ($id > 0 || !empty($ref)) print ''; } - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print '
'; print ''; // Fields title search print ''; - print ''; + if (!empty($arrayfields['t.ref']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.label']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.description']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.dateo']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.datee']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.planned_workload']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.duration_effective']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.progress_calculated']['checked'])) { + print ''; + } + + if (!empty($arrayfields['t.progress']['checked'])) { + print ''; + } // progress resume not searchable print ''; if ($object->usage_bill_time) { - print ''; + if (!empty($arrayfields['t.tobill']['checked'])) { + print ''; + } - print ''; + if (!empty($arrayfields['t.billed']['checked'])) { + print ''; + } } - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print ''; + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print ''; + + $extrafieldsobjectkey=$taskstatic->table_element; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Action column print ''; // print ''; - print_liste_field_titre("RefTask", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, ''); - print_liste_field_titre("LabelTask", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, ''); - print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("PlannedWorkload", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("TimeSpent", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("ProgressCalculated", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("ProgressDeclared", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("TaskProgressSummary", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, ''); + if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); + if (!empty($arrayfields['t.description']['checked'])) print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, ''); + if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center '); if ($object->usage_bill_time) { - print_liste_field_titre("TimeToBill", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("TimeBilled", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); } - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', '', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder); + // Extra fields + $disablesortlink=1; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) $j = 0; $level = 0; - $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0)); + $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields); } else { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 09135733e9e..f55bcb36e9b 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -56,6 +56,7 @@ $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_task_ref_parent = GETPOST('search_task_ref_parent'); $search_project_user = GETPOST('search_project_user'); $search_task_user = GETPOST('search_task_user'); @@ -109,8 +110,10 @@ $fieldstosearchall = array( if (empty($user->socid)) $fieldstosearchall['t.note_private'] = "NotePrivate"; $arrayfields = array( + 't.fk_task_parent'=>array('label'=>$langs->trans("RefTaskParent"), 'checked'=>0, 'position'=>70), 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), + 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>80), 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1), @@ -169,6 +172,7 @@ if (empty($reshook)) $search_task_ref = ""; $search_task_label = ""; $search_task_description = ""; + $search_task_ref_parent = ""; $search_task_user = -1; $search_project_user = -1; $search_sday = ''; @@ -262,7 +266,8 @@ $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,"; $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.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"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add sum fields @@ -302,6 +307,8 @@ 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_task_description) $sql .= natural_search('t.description', $search_task_description); +if ($search_task_ref_parent) $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')'; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); $sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); @@ -385,8 +392,10 @@ if ($socid) $param .= '&socid='.urlencode($socid); if ($search_all != '') $param .= '&search_all='.urlencode($search_all); if ($search_project_ref != '') $param .= '&search_project_ref='.urlencode($search_project_ref); if ($search_project_title != '') $param .= '&search_project_title='.urlencode($search_project_title); -if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); -if ($search_label != '') $param .= '&search_label='.urlencode($search_label); +if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_ref); +if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_label); +if ($search_task_description != '') $param .= '&search_task_description='.urlencode($search_description); +if ($search_task_ref_parent != '') $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent); if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); if ($search_projectstatus != '') $param .= '&search_projectstatus='.urlencode($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); @@ -491,6 +500,12 @@ print '
'; print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); - print ''; + print ''; + print ''; - print ''; - print ''; - $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); - print ''; + print ''; + print ''; + $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); + print ''; - print ''; - print ''; + print ''; + print ''; + $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; + print ''; - print ''; + print ''; @@ -772,29 +779,37 @@ elseif ($id > 0 || !empty($ref)) print '
'.$langs->trans("Project").'
'."\n"; print ''; +if (!empty($arrayfields['t.fk_task_parent']['checked'])) +{ + print ''; +} if (!empty($arrayfields['t.ref']['checked'])) { print ''; } +//Task Description +if (!empty($arrayfields['t.description']['checked'])) +{ + print ''; +} // Start date if (!empty($arrayfields['t.dateo']['checked'])) { @@ -581,17 +603,19 @@ print ''; print "\n"; print ''; +if (!empty($arrayfields['t.fk_task_parent']['checked'])) print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $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, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.description']['checked'])) print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "t.description", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); 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, 'center '); -if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); +if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); 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.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); @@ -622,12 +646,14 @@ while ($i < min($num, $limit)) $object->id = $obj->id; $object->ref = $obj->ref; $object->label = $obj->label; + $object->description = $obj->description; $object->fk_statut = $obj->fk_statut; $object->progress = $obj->progress; $object->datee = $db->jdate($obj->date_end); // deprecated $object->date_end = $db->jdate($obj->date_end); $object->planned_workload = $obj->planned_workload; $object->duration_effective = $obj->duration_effective; + $object->fk_task_parent = $obj->fk_task_parent; $projectstatic->id = $obj->projectid; @@ -642,6 +668,23 @@ while ($i < min($num, $limit)) { print ''; + // Ref Parent + if (!empty($arrayfields['t.fk_task_parent']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Ref if (!empty($arrayfields['t.ref']['checked'])) { @@ -659,6 +702,14 @@ while ($i < min($num, $limit)) print ''; if (!$i) $totalarray['nbfield']++; } + // Description + if (!empty($arrayfields['t.description']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Date start if (!empty($arrayfields['t.dateo']['checked'])) { @@ -874,13 +925,11 @@ while ($i < min($num, $limit)) print "\n"; - //print projectLinesa(); } $i++; } // Show total line -//include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']) || isset($totalarray['totalprogress_calculatedfield']) || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled'])) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 9d50d98e243..4b9284b06a2 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -11,6 +11,7 @@ * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -715,7 +716,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - elseif ((GETPOST('price_ht') !== '' || GETPOST('price_ttc') !== '') && empty($error)) // Free product. // $price_ht is already set + elseif ((GETPOST('price_ht') !== '' || GETPOST('price_ttc') !== '' || GETPOST('multicurrency_price_ht') != '') && empty($error)) // Free product. // $price_ht is already set { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -745,8 +746,31 @@ if (empty($reshook)) $price_base_type = 'HT'; $pu_ht_devise = price2num($price_ht_devise, 'MU'); - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_supplier, $fk_unit); - //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); + $result = $object->addline( + $desc, + $pu_ht, + $qty, + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $idprod, + $remise_percent, + $price_base_type, + $pu_ttc, + $info_bits, + $type, + -1, // rang + 0, // special_code + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label, + $array_options, + $ref_supplier, + $fk_unit, + '', // origin + 0, // origin_id + $pu_ht_devise); } @@ -839,10 +863,10 @@ if (empty($reshook)) if (GETPOST('price_ht') != '') { - $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht')); } - else + + if (GETPOST('price_ttc') != '') { $reg = array(); $vatratecleaned = $vat_rate; @@ -854,9 +878,9 @@ if (empty($reshook)) $ttc = price2num(GETPOST('price_ttc')); $ht = $ttc / (1 + ($vatratecleaned / 100)); - $price_base_type = 'HT'; } + $price_base_type = 'HT'; $pu_ht_devise = GETPOST('multicurrency_subprice'); // Add buying price diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d1d3b08bc2d..ab451b02177 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -14,6 +14,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Frédéric France + * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -595,12 +596,12 @@ class SupplierProposal extends CommonObject //var_dump($this->line->fk_fournprice);exit; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code = 3; @@ -708,6 +709,10 @@ class SupplierProposal extends CommonObject $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } + if ($conf->multicurrency->enabled && $pu_ht_devise > 0) { + $pu = 0; + } + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -719,6 +724,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; //Fetch current line from the database and then clone the object and set it in $oldline property $line = new SupplierProposalLine($this->db); @@ -784,11 +790,11 @@ class SupplierProposal extends CommonObject } } - // Multicurrency - $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + // Multicurrency + $this->line->multicurrency_subprice = $pu_ht_devise; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; $result = $this->line->update(); if ($result > 0) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 7d4fd9be051..5f0006d24fe 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -153,7 +153,7 @@ button.actionbutton { vertical-align: middle; text-align: center; overflow: visible; /* removes extra width in IE */ - width:33%; + width: calc(33% - 2px); height: calc(25% - 2px); margin: 1px; border-width: 0;
'; + print ''; + print ''; @@ -503,6 +518,13 @@ if (!empty($arrayfields['t.label']['checked'])) print ''; print ''; + print ''; + print '
'; + if (!empty($object->fk_task_parent)) { + $object_parent = new Task($db); + $result = $object_parent->fetch($object->fk_task_parent); + if ($result < 0) { + setEventMessage($object_parent->error, 'errors'); + } else { + print $object_parent->getNomUrl(1, 'withproject'); + if ($object_parent->hasDelay()) + print img_warning("Late"); + } + } + print ''; + print $object->description; + print '