From 4e1dc2792cefa577b274fcadda5ab966ab6a2635 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 5 Jul 2022 13:58:35 +0200 Subject: [PATCH 01/69] Add default workstation in service card --- .../install/mysql/migration/15.0.0-16.0.0.sql | 3 + htdocs/install/mysql/tables/llx_product.sql | 1 + htdocs/langs/fr_FR/mrp.lang | 1 + htdocs/product/card.php | 21 +++ .../product/class/html.formproduct.class.php | 157 ++++++++++++++++++ htdocs/product/class/product.class.php | 11 +- 6 files changed, 192 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index b57cab5b4eb..c2cb299a63c 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -648,4 +648,7 @@ ALTER TABLE llx_paiement MODIFY COLUMN ext_payment_id varchar(255); ALTER TABLE llx_payment_donation MODIFY COLUMN ext_payment_id varchar(255); ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar(255); +ALTER TABLE llx_product ADD COLUMN fk_default_workstation integer DEFAULT NULL; + + diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 83e8882caa7..9b124c8fede 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -107,4 +107,5 @@ create table llx_product mandatory_period tinyint DEFAULT 0, -- is used to signal to the user that the start and end dates are mandatory for this type of product the fk_product_type == 1 (service) (non-blocking action) fk_default_bom integer DEFAULT NULL + fk_default_workstation integer DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index e65244b584f..6211db86e72 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -91,6 +91,7 @@ WorkstationSetup = Configuration du module Poste de travail WorkstationSetupPage = Configuration du module Poste de travail WorkstationList=Liste des postes de travail WorkstationCreate=Ajouter un nouveau poste de travail +DefaultWorkstation=Poste de travail par défaut ConfirmEnableWorkstation=Voulez-vous vraiment activer le poste de travail %s? EnableAWorkstation=Activer le module Poste de travail ConfirmDisableWorkstation=Voulez-vous vraiment désactiver la station de travail %s? diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d0b7e4ece73..087c7bc11ce 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -52,6 +52,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; if (!empty($conf->propal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; @@ -552,6 +553,7 @@ if (empty($reshook)) { $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); + $object->fk_default_workstation = GETPOST('fk_default_workstation'); $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte') ?GETPOST('seuil_stock_alerte') : 0; $object->desiredstock = GETPOST('desiredstock') ?GETPOST('desiredstock') : 0; $object->canvas = GETPOST('canvas'); @@ -704,6 +706,7 @@ if (empty($reshook)) { $object->status_batch = GETPOST('status_batch', 'aZ09'); $object->batch_mask = GETPOST('batch_mask', 'alpha'); $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); + $object->fk_default_workstation = GETPOST('fk_default_workstation'); // removed from update view so GETPOST always empty /* $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); @@ -1996,6 +1999,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; */ } + + if($object->isService() && $conf->workstation->enabled) { + // Default workstation + print ''.$langs->trans("DefaultWorkstation").''; + print img_picto($langs->trans("DefaultWorkstation"), 'workstation', 'class="pictofixedwidth"'); + print $formproduct->selectWorkstations($object->fk_default_workstation, 'fk_default_workstation', 1); + print ''; + } + /* else { @@ -2475,6 +2487,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } + if($object->isService() && $conf->workstation->enabled) { + $workstation = new Workstation($db); + $workstation->fetch($object->fk_default_workstation); + + print ''.$langs->trans("DefaultWorkstation").''; + print (!empty($workstation->id) ? $workstation->getNomUrl(1) : ''); + print ''; + } + // Parent product. if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 4ede9e1e297..d6017877375 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -42,6 +42,7 @@ class FormProduct // Cache arrays public $cache_warehouses = array(); public $cache_lot = array(); + public $cache_workstations = array(); /** @@ -172,6 +173,63 @@ class FormProduct } } + /** + * Load in cache array list of workstations + * If fk_product is not 0, we do not use cache + * + * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. + * @param array $exclude warehouses ids to exclude + * @param string $orderBy [='e.ref'] Order by + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + * @throws Exception + */ + public function loadWorkstations($fk_product = 0, $exclude = array(), $orderBy = 'w.ref') + { + global $conf, $langs; + + if (empty($fk_product) && count($this->cache_workstations)) { + return 0; // Cache already loaded and we do not want a list with information specific to a product + } + + $sql = "SELECT w.rowid, w.ref as label, w.type, w.nb_operators_required,w.thm_operator_estimated,w.thm_machine_estimated"; + $sql .= " FROM ".$this->db->prefix()."workstation_workstation as w"; + $sql .= " WHERE 1 = 1"; + if (!empty($fk_product) && $fk_product > 0) { + $sql .= " AND w.fk_product = ".((int) $fk_product); + } + $sql .= " AND w.entity IN (".getEntity('workstation').")"; + + if (is_array($exclude) && !empty($exclude)) { + $sql .= ' AND w.rowid NOT IN('.$this->db->sanitize(implode(',', $exclude)).')'; + } + + $sql .= " ORDER BY ".$orderBy; + + dol_syslog(get_class($this).'::loadWorkstations', LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + + $this->cache_workstations[$obj->rowid]['id'] = $obj->rowid; + $this->cache_workstations[$obj->rowid]['ref'] = $obj->ref; + $this->cache_workstations[$obj->rowid]['label'] = $obj->label; + $this->cache_workstations[$obj->rowid]['type'] = $obj->type; + $this->cache_workstations[$obj->rowid]['nb_operators_required'] = $obj->nb_operators_required; + $this->cache_workstations[$obj->rowid]['thm_operator_estimated'] = $obj->thm_operator_estimated; + $this->cache_workstations[$obj->rowid]['thm_machine_estimated'] = $obj->thm_machine_estimated; + $i++; + } + + return $num; + } else { + dol_print_error($this->db); + return -1; + } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return full path to current warehouse in $tab (recursive function) @@ -320,6 +378,105 @@ class FormProduct return $out; } + /** + * Return list of workstations + * + * @param string|int $selected Id of preselected warehouse ('' or '-1' for no value, 'ifone' and 'ifonenodefault' = select value if one value otherwise no value, '-2' to use the default value from setup) + * @param string $htmlname Name of html select html + * @param int $empty 1=Can be empty, 0 if not + * @param int $disabled 1=Select is disabled + * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. + * @param string $empty_label Empty label if needed (only if $empty=1) + * @param int $forcecombo 1=Force combo iso ajax select2 + * @param array $events Events to add to select2 + * @param string $morecss Add more css classes to HTML select + * @param array $exclude Warehouses ids to exclude + * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse + * @param string $orderBy [='e.ref'] Order by + * @return string HTML select + * + * @throws Exception + */ + public function selectWorkstations($selected = '', $htmlname = 'idworkstations', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = array(), $showfullpath = 1, $orderBy = 'e.ref') + { + global $conf, $langs, $user, $hookmanager; + + dol_syslog(get_class($this)."::selectWorkstations $selected, $htmlname, $empty, $disabled, $fk_product, $empty_label, $forcecombo, $morecss", LOG_DEBUG); + + $out = ''; + if (!empty($fk_product) && $fk_product > 0) { + $this->cache_workstations = array(); + } + + $this->loadWorkstations($fk_product); + $nbofworkstations = count($this->cache_workstations); + + if ($conf->use_javascript_ajax && !$forcecombo) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlname, $events); + $out .= $comboenhancement; + } + + if (strpos($htmlname, 'search_') !== 0) { + if (empty($user->fk_workstation) || $user->fk_workstation == -1) { + if (($selected == '-2' || $selected == 'ifone') && !empty($conf->global->MAIN_DEFAULT_WORKSTATION)) { + $selected = $conf->global->MAIN_DEFAULT_WORKSTATION; + } + } else { + if (($selected == '-2' || $selected == 'ifone') && !empty($conf->global->MAIN_DEFAULT_WORKSTATION)) { + $selected = $user->fk_workstation; + } + } + } + + $out .= ' - + + print load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); + + $res = $object->fetchLinesbytype(0); + $object->calculateCosts(); + + if($res > 0) { + + print '
+ + - + '; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form - - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } + + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form + + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print "
\n"; + + mrpCollapseBomManagement(); + } - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; + $filtertype = 1; + + + $res = $object->fetchLinesbytype(1); + $object->calculateCosts(); + + if($res > 0) { + print load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + + + print '
+ + + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form + + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; } - print ''; print "
\n"; - - mrpCollapseBomManagement(); } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 598c4c73945..f1c5803311b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -23,6 +23,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -399,6 +400,56 @@ class BOM extends CommonObject return $result; } + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLinesbytype($type = 0) + { + $this->lines = array(); + + $objectlineclassname = get_class($this).'Line'; + if (!class_exists($objectlineclassname)) { + $this->error = 'Error, class '.$objectlineclassname.' not found during call of fetchLinesCommon'; + return -1; + } + + $objectline = new $objectlineclassname($this->db); + + $sql = "SELECT ".$objectline->getFieldList('l'); + $sql .= " FROM ".$this->db->prefix().$objectline->table_element." as l"; + $sql .= " LEFT JOIN ".$this->db->prefix()."product as p ON p.rowid = l.fk_product"; + $sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id); + $sql .= " AND p.fk_product_type = ". $type; + if (isset($objectline->fields['position'])) { + $sql .= $this->db->order('position', 'ASC'); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num_rows = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_rows) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $newline = new $objectlineclassname($this->db); + $newline->setVarsFromFetchObj($obj); + + $this->lines[] = $newline; + } + $i++; + } + + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; + } + } + + /** * Load list of objects in memory from the database. * @@ -1044,6 +1095,8 @@ class BOM extends CommonObject */ public function calculateCosts() { + global $conf; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $this->unit_cost = 0; $this->total_cost = 0; @@ -1056,38 +1109,54 @@ class BOM extends CommonObject foreach ($this->lines as &$line) { $tmpproduct->cost_price = 0; $tmpproduct->pmp = 0; + $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading - if (empty($line->fk_bom_child)) { - $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading - if ($result < 0) { - $this->error = $tmpproduct->error; - return -1; - } - $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); - if (empty($line->unit_cost)) { - if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { - $line->unit_cost = $productFournisseur->fourn_unitprice; + if($tmpproduct->type == $tmpproduct::TYPE_PRODUCT) { + if (empty($line->fk_bom_child)) { + if ($result < 0) { + $this->error = $tmpproduct->error; + return -1; + } + $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); + if (empty($line->unit_cost)) { + if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { + $line->unit_cost = $productFournisseur->fourn_unitprice; + } + } + + $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + + $this->total_cost += $line->total_cost; + } else { + $bom_child = new BOM($this->db); + $res = $bom_child->fetch($line->fk_bom_child); + if ($res > 0) { + $bom_child->calculateCosts(); + $line->childBom[] = $bom_child; + $this->total_cost += $bom_child->total_cost * $line->qty; + } else { + $this->error = $bom_child->error; + return -2; } } - - $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); - - $this->total_cost += $line->total_cost; } else { - $bom_child= new BOM($this->db); - $res = $bom_child->fetch($line->fk_bom_child); - if ($res>0) { - $bom_child->calculateCosts(); - $line->childBom[] = $bom_child; - $this->total_cost += $bom_child->total_cost * $line->qty; + if(!($conf->workstation->enabled)) { + $line->total_cost = price2num($line->qty * $tmpproduct->cost_price, 'MT'); } else { - $this->error = $bom_child->error; - return -2; + + if($tmpproduct->fk_default_workstation){ + $workstation = new Workstation($this->db); + $workstation->fetch($tmpproduct->fk_default_workstation); + + $line->total_cost = price2num($line->qty * $workstation->thm_operator_estimated, 'MT'); + } } + $this->total_cost += $line->total_cost; } } $this->total_cost = price2num($this->total_cost, 'MT'); + if ($this->qty > 0) { $this->unit_cost = price2num($this->total_cost / $this->qty, 'MU'); } elseif ($this->qty < 0) { diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 0a3a3b34e7a..82154dcb078 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -36,12 +36,17 @@ if (empty($object) || !is_object($object)) { } -global $forceall, $forcetoshowtitlelines; +global $forceall, $forcetoshowtitlelines, $filtertype; if (empty($forceall)) { $forceall = 0; } +if(empty($filtertype)) $filtertype = 0; +if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) { + $filtertype = -1; +} + // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete @@ -53,6 +58,7 @@ $objectline = new BOMLine($this->db); print "\n"; $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); + if ($nolinesbefore) { print ''; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { @@ -62,16 +68,25 @@ if ($nolinesbefore) { print '
'.$langs->trans('AddNewLine').''; print ''; print ''.$langs->trans('Qty').''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; - print ''; - print $langs->trans('Unit'); - print ''; + + if($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + print ''; + print $langs->trans('Unit'); + print ''; + } + print '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . ''; + print '' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . ''; + print '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ''; } - print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; - print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; - print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; - print ' '; + else { + print '' . $form->textwithpicto($langs->trans('Unit'), '').''; + if($conf->workstation->enabled) print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ''; + print '' . $form->textwithpicto($langs->trans('TotalCost'), '') . ''; + } + + print ' '; print ''; } print ''; @@ -88,14 +103,14 @@ print ''; // Predefined product/service if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - if (!empty($conf->global->BOM_SUB_BOM)) { + if($filtertype == 1){ + print $langs->trans("Service"); + } + elseif (!empty($conf->global->BOM_SUB_BOM)) { print $langs->trans("Product"); } echo ''; - $filtertype = 0; - if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) { - $filtertype = -1; - } + $statustoshow = -1; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer @@ -106,7 +121,7 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { echo ''; } -if (!empty($conf->global->BOM_SUB_BOM)) { +if (!empty($conf->global->BOM_SUB_BOM) && $filtertype!=1) { print '
'.$langs->trans("or").'
'.$langs->trans("BOM"); // TODO Add component to select a BOM $form->select_bom(); @@ -118,35 +133,53 @@ $coldisplay++; print ''; print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { +if($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $coldisplay++; + print ''; + print ''; + } + $coldisplay++; - print ''; + print ''; + print ''; + + $coldisplay++; + print ''; + print ''; + + $coldisplay++; + print ''; + print ''; + print ''; + + $coldisplay++; + print ''; + print ' '; + print ''; +} else { + $coldisplay++; + print ''; + print ' '; + print ''; + + $coldisplay++; + print ''; + print ' '; + print ''; + + $coldisplay++; + print ''; + print ' '; print ''; } -$coldisplay++; -print ''; -print ''; + $coldisplay += $colspan; + print ''; + print ''; + print ''; + print ''; -$coldisplay++; -print ''; -print ''; - -$coldisplay++; -print ''; -print ''; -print ''; - -$coldisplay++; -print ''; -print ' '; -print ''; - -$coldisplay += $colspan; -print ''; -print ''; -print ''; -print ''; if (is_object($objectline)) { print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1, 'line'); diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index e5f24fa994f..7812c2fcc16 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -38,12 +38,14 @@ if (empty($object) || !is_object($object)) { } -global $forceall; +global $forceall, $filtertype; if (empty($forceall)) { $forceall = 0; } +if(empty($filtertype)) $filtertype = 0; + // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete @@ -108,28 +110,47 @@ if (($line->info_bits & 2) != 2) { } print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { +if($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $coldisplay++; + print ''; + print ''; + } + $coldisplay++; - print ''; + print 'qty_frozen ? ' checked="checked"' : '')) . '>'; + print ''; + + $coldisplay++; + print 'disable_stock_change ? ' checked="checked"' : '')) . '">'; + print ''; + + $coldisplay++; + print ''; + print ''; + + $coldisplay++; + print ''; + print ''; +} else { + + $coldisplay++; + print ''; + print ''; + + $coldisplay++; + print ''; + print ''; + + $coldisplay++; + print ''; + print ''; + + $coldisplay++; + print ''; print ''; } -$coldisplay++; -print 'qty_frozen ? ' checked="checked"' : '')).'>'; -print ''; - -$coldisplay++; -print 'disable_stock_change ? ' checked="checked"' : '')).'">'; -print ''; - -$coldisplay++; -print ''; -print ''; - -$coldisplay++; -print ''; -print ''; - $coldisplay += $colspan; print ''; $coldisplay += $colspan; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index dff3a38ccd2..498002cc50c 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -38,6 +38,10 @@ if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } + +global $filtertype; +if(empty($filtertype)) $filtertype = 0; + print "\n"; @@ -62,22 +66,31 @@ print ''; // Qty print ''.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''.$langs->trans('Unit').''; -} +if($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print '' . $langs->trans('Unit') . ''; + } // 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')) . ''; + +} else { + + print '' . $form->textwithpicto($langs->trans('Unit'), '').''; + + if($conf->workstation->enabled) print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ''; +} // Cost print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''; + print ''; // No width to allow autodim print ''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 61b394a3b0f..dee6bdbde60 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -34,12 +34,17 @@ * $type, $text, $description, $line */ +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } +global $filtertype; +if(empty($filtertype)) $filtertype = 0; + global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs; @@ -100,29 +105,50 @@ $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; - $label = $tmpproduct->getLabelOfUnit('long'); - if ($label !== '') { - print $langs->trans($label); +if($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + $label = $tmpproduct->getLabelOfUnit('long'); + if ($label !== '') { + print $langs->trans($label); + } + print ''; } + + print ''; + $coldisplay++; + echo $line->qty_frozen ? yn($line->qty_frozen) : ''; print ''; + print ''; + $coldisplay++; + echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price + print ''; + + print ''; + $coldisplay++; + echo $line->efficiency; + print ''; +} else { + $product = new Product($object->db); + $res = $product->fetch($line->fk_product); + + //Unité + print ''; + $coldisplay++; + echo $product->duration_unit; + print ''; + + //Poste de travail + if($conf->workstation->enabled) { + $workstation = new Workstation($object->db); + $workstation->fetch($product->fk_default_workstation); + + print ''; + $coldisplay++; + echo $workstation->getNomUrl(); + print ''; + } } - -print ''; -$coldisplay++; -echo $line->qty_frozen ? yn($line->qty_frozen) : ''; -print ''; -print ''; -$coldisplay++; -echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price -print ''; - -print ''; -$coldisplay++; -echo $line->efficiency; -print ''; - $total_cost = 0; print ''; $coldisplay++; diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index 6211db86e72..f952be1100a 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -82,6 +82,8 @@ ProductsToProduce=Produits à produire UnitCost=Coût unitaire TotalCost=Coût total BOMTotalCost=Le coût de production de cette nomenclature basé sur chaque quantité et produit à consommer (utilise le prix de revient si défini, sinon le PMP si défini, sinon le meilleur prix d'achat) +BOMProductsList=Liste des composants +BOMServicesList=Liste des services GoOnTabProductionToProduceFirst=Vous devez avoir la production pour clôturer un Ordre de Fabrication (voir onglet '%s'). Mais vous pouvez l'annuler. ErrorAVirtualProductCantBeUsedIntoABomOrMo=Un kit ne peut pas être utilisé dans une Nomenclature ou un Ordre de fabrication. Workstation=Poste de travail From 6925dc2ae13430d3c7f5308a53d74cbe4f3c0df8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 6 Jul 2022 15:00:07 +0200 Subject: [PATCH 04/69] Edit unit bom line service --- htdocs/bom/bom_card.php | 16 ++++++++-------- htdocs/bom/class/bom.class.php | 1 + htdocs/bom/tpl/objectline_create.tpl.php | 9 ++++++--- htdocs/bom/tpl/objectline_edit.tpl.php | 19 +++++++++++-------- htdocs/bom/tpl/objectline_view.tpl.php | 11 ++++++++++- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ .../install/mysql/tables/llx_bom_bomline.sql | 1 + 7 files changed, 39 insertions(+), 20 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 759c313cd3c..d448551c95e 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -167,7 +167,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); - + $duration_unit = GETPOST('duration_unit','alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -191,6 +191,7 @@ if (empty($reshook)) { $bomline->qty_frozen = (int) $qty_frozen; $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; + $bomline->duration_unit = $duration_unit; // Rang to use $rangmax = $object->line_max(0); @@ -225,6 +226,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); + $duration_unit = GETPOST('duration_unit','alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -237,6 +239,7 @@ if (empty($reshook)) { $bomline->qty_frozen = (int) $qty_frozen; $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; + $bomline->duration_unit = $duration_unit; $result = $bomline->update($user); if ($result <= 0) { @@ -577,7 +580,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Form to add new line if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { if ($action != 'editline') { - // Add products/services form + // Add products form $parameters = array(); @@ -601,7 +604,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $filtertype = 1; - $res = $object->fetchLinesbytype(1); $object->calculateCosts(); @@ -609,7 +611,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); - print '
+ print ' @@ -633,11 +635,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Form to add new line if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { if ($action != 'editline') { - // Add products/services form - - + // Add services form $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index f1c5803311b..ae75c518990 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1299,6 +1299,7 @@ class BOMLine extends CommonObjectLine 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), 'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), + 'duration_unit' => array('type'=>'varchar(6)', 'label'=>'Unit', 'enabled'=>1, 'visible'=>1, 'position'=>120, 'notnull'=>-1,), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 82154dcb078..4a0fe79e4a1 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -29,6 +29,8 @@ * $forceall (0 by default, 1 for supplier invoices/orders) */ +require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"; + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error: this template page cannot be called directly as an URL"; @@ -47,6 +49,7 @@ if (!empty($object->element) && $object->element == 'contrat' && empty($conf->gl $filtertype = -1; } +$formproduct = new FormProduct($object->db); // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete @@ -159,12 +162,12 @@ if($filtertype != 1) { print ''; } else { $coldisplay++; - print ''; - print ' '; + print ''; + print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOST('duration_value', 'alpha') : 'h'), 0, 1); print ''; $coldisplay++; - print ''; + print ''; print ' '; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 7812c2fcc16..0790329c346 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -31,6 +31,9 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ +require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"; + + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; @@ -46,6 +49,8 @@ if (empty($forceall)) { if(empty($filtertype)) $filtertype = 0; +$formproduct = new FormProduct($object->db); + // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete @@ -135,20 +140,18 @@ if($filtertype != 1) { } else { $coldisplay++; - print ''; + print ''; + print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOST('duration_value', 'alpha') : 'h'), 0, 1); + print ''; + + $coldisplay++; + print ''; print ''; $coldisplay++; print ''; print ''; - $coldisplay++; - print ''; - print ''; - - $coldisplay++; - print ''; - print ''; } $coldisplay += $colspan; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index dee6bdbde60..c16360e429d 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -135,7 +135,16 @@ if($filtertype != 1) { //Unité print ''; $coldisplay++; - echo $product->duration_unit; + if ($line->qty > 1) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } elseif ($product->duration_value > 0) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + if(!empty($line->duration_unit)){ + print (isset($dur[$line->duration_unit]) ? " ".$langs->trans($dur[$line->duration_unit])." " : ''); + } else { + print (!empty($product->duration_unit) && isset($dur[$product->duration_unit]) ? " " . $langs->trans($dur[$product->duration_unit]) . " " : ''); + } print ''; //Poste de travail diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index c2cb299a63c..3c31af497e9 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -650,5 +650,7 @@ ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar ALTER TABLE llx_product ADD COLUMN fk_default_workstation integer DEFAULT NULL; +ALTER TABLE llx_bom_bomline ADD COLUMN duration_unit varchar(6) DEFAULT NULL; + diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index e7eae15fc15..c93484db92a 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -25,6 +25,7 @@ CREATE TABLE llx_bom_bomline( qty_frozen smallint DEFAULT 0, disable_stock_change smallint DEFAULT 0, efficiency double(24,8) NOT NULL DEFAULT 1, + duration_unit varchar(6) NULL, position integer NOT NULL DEFAULT 0 -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From dadff083a414012c8ffd04f5029c0ab5cb8cb959 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 6 Jul 2022 16:17:22 +0200 Subject: [PATCH 05/69] Change unit dynamic --- htdocs/bom/ajax/ajax.php | 79 ++++++++++++++++++++++++ htdocs/bom/class/bom.class.php | 10 +-- htdocs/bom/tpl/objectline_create.tpl.php | 19 ++++++ htdocs/bom/tpl/objectline_view.tpl.php | 4 +- 4 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 htdocs/bom/ajax/ajax.php diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php new file mode 100644 index 00000000000..d8ea9650b09 --- /dev/null +++ b/htdocs/bom/ajax/ajax.php @@ -0,0 +1,79 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/ticket/ajax/ajax.php + * \brief Ajax component for Ticket. + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +// Do not check anti CSRF attack test +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +// If there is no need to load and show top and left menu +if (!defined("NOLOGIN")) { + define("NOLOGIN", '1'); +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +include_once '../../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + +$action = GETPOST('action', 'aZ09'); +$idproduct = GETPOST('idproduct', 'int'); + + +/* + * View + */ + +top_httphead(); + +if ($action == 'getDurationUnitByProduct') { + + $product = new Product($db); + $res = $product->fetch($idproduct); + + if($res > 0){ + $return = $product->duration_unit; + } + + echo json_encode($return); + exit(); +} diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ae75c518990..9638778db43 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1140,17 +1140,17 @@ class BOM extends CommonObject } } } else { - if(!($conf->workstation->enabled)) { - $line->total_cost = price2num($line->qty * $tmpproduct->cost_price, 'MT'); - } else { - - if($tmpproduct->fk_default_workstation){ + if($conf->workstation->enabled){ + if($tmpproduct->fk_default_workstation) { $workstation = new Workstation($this->db); $workstation->fetch($tmpproduct->fk_default_workstation); $line->total_cost = price2num($line->qty * $workstation->thm_operator_estimated, 'MT'); } + } else { + $line->total_cost = price2num($line->qty * $tmpproduct->cost_price, 'MT'); } + $this->total_cost += $line->total_cost; } } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 4a0fe79e4a1..7a022c1172c 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -210,7 +210,26 @@ jQuery(document).ready(function() { if (editor) { editor.focus(); } } } + }); + + $('#idprod:nth-child(2)').change(function(){ + var idproduct = $(this).val(); + + console.log(idproduct); + $.ajax({ + url : "" + ,type: 'POST' + ,data: { + 'action': 'getDurationUnitByProduct' + ,'idproduct' : idproduct + } + }).done(function(data) { + var data = JSON.parse(data); + $('#duration_unit').val(data).change();; + }); + }); + }); diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index c16360e429d..540146b14fa 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -136,9 +136,9 @@ if($filtertype != 1) { print ''; $coldisplay++; if ($line->qty > 1) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + $dur = array("s"=>$langs->trans("Seconds"), "i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ($product->duration_value > 0) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + $dur = array("s"=>$langs->trans("Second"), "i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } if(!empty($line->duration_unit)){ print (isset($dur[$line->duration_unit]) ? " ".$langs->trans($dur[$line->duration_unit])." " : ''); From 503e2310ea6e74e6d95ae562c76c98af33656866 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 6 Jul 2022 16:51:50 +0200 Subject: [PATCH 06/69] WIP --- htdocs/bom/class/bom.class.php | 12 ++++++++++-- htdocs/bom/tpl/objectline_edit.tpl.php | 2 +- htdocs/bom/tpl/objectline_title.tpl.php | 11 ++++++++--- htdocs/langs/fr_FR/mrp.lang | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 9638778db43..3366ae1dda1 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1140,15 +1140,23 @@ class BOM extends CommonObject } } } else { + + if($line->duration_unit == 's') $qty = $line->qty / 3600; + if($line->duration_unit == 'i') $qty = $line->qty / 60; + if($line->duration_unit == 'd') $qty = $line->qty * 24; + if($line->duration_unit == 'w') $qty = $line->qty * 24 * 7; + if($line->duration_unit == 'm') $qty = $line->qty * 730.484; + if($line->duration_unit == 'y') $qty = $line->qty * 365 * 24; + if($conf->workstation->enabled){ if($tmpproduct->fk_default_workstation) { $workstation = new Workstation($this->db); $workstation->fetch($tmpproduct->fk_default_workstation); - $line->total_cost = price2num($line->qty * $workstation->thm_operator_estimated, 'MT'); + $line->total_cost = price2num($qty * $workstation->thm_operator_estimated, 'MT'); } } else { - $line->total_cost = price2num($line->qty * $tmpproduct->cost_price, 'MT'); + $line->total_cost = price2num($qty * $tmpproduct->cost_price, 'MT'); } $this->total_cost += $line->total_cost; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 0790329c346..b669c936412 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -141,7 +141,7 @@ if($filtertype != 1) { $coldisplay++; print ''; - print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOST('duration_value', 'alpha') : 'h'), 0, 1); + print $formproduct->selectMeasuringUnits("duration_unit", "time", ($line->duration_unit) ? $line->duration_unit : '', 0, 1); print ''; $coldisplay++; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 498002cc50c..d4cab0cb8e7 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -57,7 +57,7 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { // Product or sub-bom print ''.$langs->trans('Description'); -if (!empty($conf->global->BOM_SUB_BOM)) { +if (!empty($conf->global->BOM_SUB_BOM) && $filtertype != 1) { print '   '.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; } @@ -80,15 +80,20 @@ if($filtertype != 1) { // Efficiency print '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ''; + // Cost + print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''; + } else { print '' . $form->textwithpicto($langs->trans('Unit'), '').''; if($conf->workstation->enabled) print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ''; + + // Cost + print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).''; } -// Cost -print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''; + print ''; // No width to allow autodim diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index f952be1100a..845657408d8 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -82,6 +82,7 @@ ProductsToProduce=Produits à produire UnitCost=Coût unitaire TotalCost=Coût total BOMTotalCost=Le coût de production de cette nomenclature basé sur chaque quantité et produit à consommer (utilise le prix de revient si défini, sinon le PMP si défini, sinon le meilleur prix d'achat) +BOMTotalService=Si le module "Poste de travail" est activé, alors le calcul est "quantité (convertie en heures) x thm du poste de travail", sinon "quantité (convertie en heures) x prix de revient du service" BOMProductsList=Liste des composants BOMServicesList=Liste des services GoOnTabProductionToProduceFirst=Vous devez avoir la production pour clôturer un Ordre de Fabrication (voir onglet '%s'). Mais vous pouvez l'annuler. From 16415a1c92ec249c3ace39c28075aab00310feeb Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 6 Jul 2022 17:28:29 +0200 Subject: [PATCH 07/69] Clean Code --- htdocs/bom/ajax/ajax.php | 4 ++-- htdocs/bom/bom_card.php | 12 ++++++------ htdocs/bom/class/bom.class.php | 17 ++++++++++++----- htdocs/bom/tpl/objectline_create.tpl.php | 8 +++----- htdocs/bom/tpl/objectline_view.tpl.php | 11 ++++------- htdocs/product/card.php | 2 +- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index d8ea9650b09..ef99ab214d1 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/public/ticket/ajax/ajax.php - * \brief Ajax component for Ticket. + * \file htdocs/bom/ajax/ajax.php + * \brief Ajax component for BOM. */ if (!defined('NOTOKENRENEWAL')) { diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index d448551c95e..0700bad4c2a 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -546,16 +546,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea * Lines */ - if (!empty($object->table_element_line)) { - print load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); - - $res = $object->fetchLinesbytype(0); + //Products + $res = $object->fetchLinesbytypeproduct(0); $object->calculateCosts(); if($res > 0) { + print load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); + print ' @@ -602,9 +602,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } + //Services $filtertype = 1; - - $res = $object->fetchLinesbytype(1); + $res = $object->fetchLinesbytypeproduct(1); $object->calculateCosts(); if($res > 0) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 3366ae1dda1..15d16c4c9fa 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -401,11 +401,13 @@ class BOM extends CommonObject } /** - * Load object lines in memory from the database + * Load object lines in memory from the database by type of product * + * @param int $typeproduct 0 type product, 1 type service + * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetchLinesbytype($type = 0) + public function fetchLinesbytypeproduct($typeproduct = 0) { $this->lines = array(); @@ -421,7 +423,7 @@ class BOM extends CommonObject $sql .= " FROM ".$this->db->prefix().$objectline->table_element." as l"; $sql .= " LEFT JOIN ".$this->db->prefix()."product as p ON p.rowid = l.fk_product"; $sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id); - $sql .= " AND p.fk_product_type = ". $type; + $sql .= " AND p.fk_product_type = ". $typeproduct; if (isset($objectline->fields['position'])) { $sql .= $this->db->order('position', 'ASC'); } @@ -1141,6 +1143,7 @@ class BOM extends CommonObject } } else { + //Convert qty to hour if($line->duration_unit == 's') $qty = $line->qty / 3600; if($line->duration_unit == 'i') $qty = $line->qty / 60; if($line->duration_unit == 'd') $qty = $line->qty * 24; @@ -1151,9 +1154,13 @@ class BOM extends CommonObject if($conf->workstation->enabled){ if($tmpproduct->fk_default_workstation) { $workstation = new Workstation($this->db); - $workstation->fetch($tmpproduct->fk_default_workstation); + $res = $workstation->fetch($tmpproduct->fk_default_workstation); - $line->total_cost = price2num($qty * $workstation->thm_operator_estimated, 'MT'); + if($res > 0) $line->total_cost = price2num($qty * $workstation->thm_operator_estimated, 'MT'); + else { + $this->error = $workstation->error; + return -3; + } } } else { $line->total_cost = price2num($qty * $tmpproduct->cost_price, 'MT'); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 7a022c1172c..f2f660bc711 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -163,7 +163,7 @@ if($filtertype != 1) { } else { $coldisplay++; print ''; - print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOST('duration_value', 'alpha') : 'h'), 0, 1); + print $formproduct->selectMeasuringUnits("duration_unit", "time", 'h', 0, 1); print ''; $coldisplay++; @@ -196,8 +196,6 @@ jQuery(document).ready(function() { /* When changing predefined product, we reload list of supplier prices required for margin combo */ $("#idprod").change(function() { - console.log("#idprod change triggered"); - /* To set focus */ if (jQuery('#idprod').val() > 0) { @@ -212,11 +210,11 @@ jQuery(document).ready(function() { } }); + + //change unit selected if we change service selected $('#idprod:nth-child(2)').change(function(){ var idproduct = $(this).val(); - - console.log(idproduct); $.ajax({ url : "" ,type: 'POST' diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 540146b14fa..1699c968794 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -129,32 +129,29 @@ if($filtertype != 1) { echo $line->efficiency; print ''; } else { - $product = new Product($object->db); - $res = $product->fetch($line->fk_product); - //Unité print ''; $coldisplay++; if ($line->qty > 1) { $dur = array("s"=>$langs->trans("Seconds"), "i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ($product->duration_value > 0) { + } elseif ($tmpproduct->duration_value > 0) { $dur = array("s"=>$langs->trans("Second"), "i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } if(!empty($line->duration_unit)){ print (isset($dur[$line->duration_unit]) ? " ".$langs->trans($dur[$line->duration_unit])." " : ''); } else { - print (!empty($product->duration_unit) && isset($dur[$product->duration_unit]) ? " " . $langs->trans($dur[$product->duration_unit]) . " " : ''); + print (!empty($tmpproduct->duration_unit) && isset($dur[$tmpproduct->duration_unit]) ? " " . $langs->trans($dur[$tmpproduct->duration_unit]) . " " : ''); } print ''; //Poste de travail if($conf->workstation->enabled) { $workstation = new Workstation($object->db); - $workstation->fetch($product->fk_default_workstation); + $res = $workstation->fetch($tmpproduct->fk_default_workstation); print ''; $coldisplay++; - echo $workstation->getNomUrl(); + if($res > 0) echo $workstation->getNomUrl(); print ''; } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f9ac8da8d05..eb215839fb1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2496,7 +2496,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if($object->isService() && $conf->workstation->enabled) { $workstation = new Workstation($db); - $workstation->fetch($object->fk_default_workstation); + $res = $workstation->fetch($object->fk_default_workstation); print ''.$langs->trans("DefaultWorkstation").''; print (!empty($workstation->id) ? $workstation->getNomUrl(1) : ''); From 7c82fc5da6e1079c5c24372a719d525749cf4bf0 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 8 Jul 2022 10:04:16 +0200 Subject: [PATCH 08/69] WIP --- htdocs/bom/bom_card.php | 3 ++- htdocs/bom/class/bom.class.php | 3 ++- htdocs/bom/tpl/objectline_title.tpl.php | 2 +- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- htdocs/langs/fr_FR/mrp.lang | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0700bad4c2a..46105f2b2cb 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -620,12 +620,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea '; if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + $tagidfortablednd = 'tablelinesservice'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } print '
'; if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; + print '
'; } if (!empty($object->lines)) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 15d16c4c9fa..cb520579d74 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1144,8 +1144,9 @@ class BOM extends CommonObject } else { //Convert qty to hour - if($line->duration_unit == 's') $qty = $line->qty / 3600; + if($line->duration_unit == 's') $qty = $line->qty / 3600; if($line->duration_unit == 'i') $qty = $line->qty / 60; + if($line->duration_unit == 'h') $qty = $line->qty; if($line->duration_unit == 'd') $qty = $line->qty * 24; if($line->duration_unit == 'w') $qty = $line->qty * 24 * 7; if($line->duration_unit == 'm') $qty = $line->qty * 730.484; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index d4cab0cb8e7..317908a749e 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -64,7 +64,7 @@ if (!empty($conf->global->BOM_SUB_BOM) && $filtertype != 1) { print ''; // Qty -print ''; +print ''; if($filtertype != 1) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1699c968794..cef6b520264 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -65,7 +65,7 @@ if (empty($outputalsopricetotalwithtax)) { } // add html5 elements -$domData = ' data-element="'.$line->element.'"'; +$domData = ' data-element="'.$line->element.'service"'; $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index 845657408d8..fc2563b8518 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -82,7 +82,7 @@ ProductsToProduce=Produits à produire UnitCost=Coût unitaire TotalCost=Coût total BOMTotalCost=Le coût de production de cette nomenclature basé sur chaque quantité et produit à consommer (utilise le prix de revient si défini, sinon le PMP si défini, sinon le meilleur prix d'achat) -BOMTotalService=Si le module "Poste de travail" est activé, alors le calcul est "quantité (convertie en heures) x thm du poste de travail", sinon "quantité (convertie en heures) x prix de revient du service" +BOMTotalCostService=Si le module "Poste de travail" est activé, alors le calcul est "quantité (convertie en heures) x thm du poste de travail", sinon "quantité (convertie en heures) x prix de revient du service" BOMProductsList=Liste des composants BOMServicesList=Liste des services GoOnTabProductionToProduceFirst=Vous devez avoir la production pour clôturer un Ordre de Fabrication (voir onglet '%s'). Mais vous pouvez l'annuler. From d42d910c0820cc477d12ac5ec792936ae57bc5d1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 8 Jul 2022 16:02:31 +0200 Subject: [PATCH 09/69] FIX Retours --- htdocs/bom/bom_card.php | 4 +++- htdocs/bom/class/bom.class.php | 2 +- htdocs/bom/tpl/objectline_create.tpl.php | 7 ++++--- htdocs/bom/tpl/objectline_title.tpl.php | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 46105f2b2cb..d4dd367e95e 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -160,7 +160,7 @@ if (empty($reshook)) { $idprod = $bom_child->fk_product; } } else { - $idprod = (int) GETPOST('idprod', 'int'); + $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int')); } $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); @@ -205,6 +205,7 @@ if (empty($reshook)) { $action = ''; } else { unset($_POST['idprod']); + unset($_POST['idprodservice']); unset($_POST['qty']); unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); @@ -247,6 +248,7 @@ if (empty($reshook)) { $action = ''; } else { unset($_POST['idprod']); + unset($_POST['idprodservice']); unset($_POST['qty']); unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index cb520579d74..3f3d88aad36 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1157,7 +1157,7 @@ class BOM extends CommonObject $workstation = new Workstation($this->db); $res = $workstation->fetch($tmpproduct->fk_default_workstation); - if($res > 0) $line->total_cost = price2num($qty * $workstation->thm_operator_estimated, 'MT'); + if($res > 0) $line->total_cost = price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); else { $this->error = $workstation->error; return -3; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index f2f660bc711..3eea9235043 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -117,9 +117,10 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $statustoshow = -1; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer - $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); - } else { - $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); + $form->select_produits(GETPOST('idprod', 'int'), (($filtertype == 1) ? 'idprodservice' : 'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); + } + else { + $form->select_produits(GETPOST('idprod', 'int'), (($filtertype == 1) ? 'idprodservice' : 'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } echo ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 317908a749e..9ed44d8f503 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -87,7 +87,7 @@ if($filtertype != 1) { print ''; - if($conf->workstation->enabled) print ''; + if($conf->workstation->enabled) print ''; // Cost print ''; From 6564333e55ca335fec5ec58cbede492d93fed52b Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 12 Jul 2022 09:16:52 +0200 Subject: [PATCH 10/69] Change sjquery on select2 --- htdocs/bom/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 3eea9235043..55b14a0f650 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -214,7 +214,7 @@ jQuery(document).ready(function() { //change unit selected if we change service selected - $('#idprod:nth-child(2)').change(function(){ + $('#idprodservice').change(function(){ var idproduct = $(this).val(); $.ajax({ url : "" From 8a36e2e9d8a21c9499279d0ade31282f90c4583c Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 12 Jul 2022 09:21:51 +0200 Subject: [PATCH 11/69] =?UTF-8?q?M=C3=A0j=20column=20fk=5Ffedault=5Fworkst?= =?UTF-8?q?atio=20and=20duration=5Funit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index fa61ba725de..fb1ba0a8da2 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -55,3 +55,6 @@ ALTER TABLE llx_facture_fourn ADD COLUMN close_missing_amount double(24, 8) afte -- Allow users to make subscriptions of any amount during membership subscription ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER amount; + +ALTER TABLE llx_product ADD COLUMN fk_default_workstation integer DEFAULT NULL; +ALTER TABLE llx_bom_bomline ADD COLUMN duration_unit varchar(6) DEFAULT NULL; From c068eebc4361de2920005f2488c9512f235d36ce Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 12 Jul 2022 10:03:31 +0200 Subject: [PATCH 12/69] Add function "convertDurationtoHour" --- htdocs/bom/class/bom.class.php | 9 ++------- htdocs/core/lib/date.lib.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 1f3dd041aad..16c780a5751 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -24,6 +24,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -1128,13 +1129,7 @@ class BOM extends CommonObject } else { //Convert qty to hour - if($line->duration_unit == 's') $qty = $line->qty / 3600; - if($line->duration_unit == 'i') $qty = $line->qty / 60; - if($line->duration_unit == 'h') $qty = $line->qty; - if($line->duration_unit == 'd') $qty = $line->qty * 24; - if($line->duration_unit == 'w') $qty = $line->qty * 24 * 7; - if($line->duration_unit == 'm') $qty = $line->qty * 730.484; - if($line->duration_unit == 'y') $qty = $line->qty * 365 * 24; + $qty = convertDurationtoHour($line->qty, $line->duration_unit); if($conf->workstation->enabled){ if($tmpproduct->fk_default_workstation) { diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 558ba2aa322..98a17e062ee 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -318,6 +318,27 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l } +/** Convert duration to hour + * + * @param int $duration_value Duration value + * @param int $duration_unit Duration unit + * @return int $result + */ +function convertDurationtoHour($duration_value, $duration_unit) +{ + $result = 0; + + if($duration_unit == 's') $result = $duration_value / 3600; + if($duration_unit == 'i') $result = $duration_value / 60; + if($duration_unit == 'h') $result = $duration_value; + if($duration_unit == 'd') $result = $duration_value * 24; + if($duration_unit == 'w') $result = $duration_value * 24 * 7; + if($duration_unit == 'm') $result = $duration_value * 730.484; + if($duration_unit == 'y') $result = $duration_value * 365 * 24; + + return $result; +} + /** * Generate a SQL string to make a filter into a range (for second of date until last second of date). * This method allows to maje SQL request that will deal correctly the timezone of server. From a41dee9e06b3d2b74f27dc5e669c7eb90e46b1de Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 12 Jul 2022 08:09:45 +0000 Subject: [PATCH 13/69] Fixing style errors. --- htdocs/bom/ajax/ajax.php | 3 +-- htdocs/bom/bom_card.php | 11 ++++----- htdocs/bom/class/bom.class.php | 9 ++++---- htdocs/bom/tpl/objectline_create.tpl.php | 23 ++++++++----------- htdocs/bom/tpl/objectline_edit.tpl.php | 5 ++-- htdocs/bom/tpl/objectline_title.tpl.php | 14 +++++------ htdocs/bom/tpl/objectline_view.tpl.php | 10 ++++---- htdocs/core/lib/date.lib.php | 14 +++++------ htdocs/product/card.php | 6 ++--- .../product/class/html.formproduct.class.php | 1 - 10 files changed, 42 insertions(+), 54 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index ef99ab214d1..2ad12cc60a3 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -66,11 +66,10 @@ $idproduct = GETPOST('idproduct', 'int'); top_httphead(); if ($action == 'getDurationUnitByProduct') { - $product = new Product($db); $res = $product->fetch($idproduct); - if($res > 0){ + if ($res > 0) { $return = $product->duration_unit; } diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index d4dd367e95e..1abc33f9bce 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -167,7 +167,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $duration_unit = GETPOST('duration_unit','alphanohtml'); + $duration_unit = GETPOST('duration_unit', 'alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -227,7 +227,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $duration_unit = GETPOST('duration_unit','alphanohtml'); + $duration_unit = GETPOST('duration_unit', 'alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -549,13 +549,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ if (!empty($object->table_element_line)) { - //Products $res = $object->fetchLinesbytypeproduct(0); $object->calculateCosts(); - if($res > 0) { - + if ($res > 0) { print load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); print ' @@ -601,7 +599,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print "\n"; mrpCollapseBomManagement(); - } //Services @@ -609,7 +606,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetchLinesbytypeproduct(1); $object->calculateCosts(); - if($res > 0) { + if ($res > 0) { print load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 16c780a5751..c0eb5e802ea 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1098,7 +1098,7 @@ class BOM extends CommonObject $tmpproduct->pmp = 0; $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading - if($tmpproduct->type == $tmpproduct::TYPE_PRODUCT) { + if ($tmpproduct->type == $tmpproduct::TYPE_PRODUCT) { if (empty($line->fk_bom_child)) { if ($result < 0) { $this->error = $tmpproduct->error; @@ -1127,16 +1127,15 @@ class BOM extends CommonObject } } } else { - //Convert qty to hour $qty = convertDurationtoHour($line->qty, $line->duration_unit); - if($conf->workstation->enabled){ - if($tmpproduct->fk_default_workstation) { + if ($conf->workstation->enabled) { + if ($tmpproduct->fk_default_workstation) { $workstation = new Workstation($this->db); $res = $workstation->fetch($tmpproduct->fk_default_workstation); - if($res > 0) $line->total_cost = price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); + if ($res > 0) $line->total_cost = price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); else { $this->error = $workstation->error; return -3; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 55b14a0f650..ff257d6ab72 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -44,7 +44,7 @@ if (empty($forceall)) { $forceall = 0; } -if(empty($filtertype)) $filtertype = 0; +if (empty($filtertype)) $filtertype = 0; if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) { $filtertype = -1; } @@ -72,7 +72,7 @@ if ($nolinesbefore) { print ''; print ''; - if($filtertype != 1) { + if ($filtertype != 1) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; print ''; print ''; - } - else { + } else { print ''; - if($conf->workstation->enabled) print ''; + if ($conf->workstation->enabled) print ''; print ''; } @@ -106,10 +105,9 @@ print ''; -if($filtertype != 1) { +if ($filtertype != 1) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; -if($filtertype != 1) { +if ($filtertype != 1) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; - } $coldisplay += $colspan; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 9ed44d8f503..f93fb59fe0d 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -40,7 +40,7 @@ if (empty($object) || !is_object($object)) { } global $filtertype; -if(empty($filtertype)) $filtertype = 0; +if (empty($filtertype)) $filtertype = 0; print "\n"; @@ -66,28 +66,26 @@ print ''; // Qty print ''; -if($filtertype != 1) { +if ($filtertype != 1) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; } -// Qty frozen + // Qty frozen print ''; -// Disable stock change + // Disable stock change print ''; -// Efficiency + // Efficiency print ''; // Cost print ''; - } else { - print ''; - if($conf->workstation->enabled) print ''; + if ($conf->workstation->enabled) print ''; // Cost print ''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index cef6b520264..2c9758f2176 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -43,7 +43,7 @@ if (empty($object) || !is_object($object)) { } global $filtertype; -if(empty($filtertype)) $filtertype = 0; +if (empty($filtertype)) $filtertype = 0; global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs; @@ -105,7 +105,7 @@ $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; -if($filtertype != 1) { +if ($filtertype != 1) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; //Poste de travail - if($conf->workstation->enabled) { + if ($conf->workstation->enabled) { $workstation = new Workstation($object->db); $res = $workstation->fetch($tmpproduct->fk_default_workstation); print ''; } } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 98a17e062ee..3e52099a41b 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -328,13 +328,13 @@ function convertDurationtoHour($duration_value, $duration_unit) { $result = 0; - if($duration_unit == 's') $result = $duration_value / 3600; - if($duration_unit == 'i') $result = $duration_value / 60; - if($duration_unit == 'h') $result = $duration_value; - if($duration_unit == 'd') $result = $duration_value * 24; - if($duration_unit == 'w') $result = $duration_value * 24 * 7; - if($duration_unit == 'm') $result = $duration_value * 730.484; - if($duration_unit == 'y') $result = $duration_value * 365 * 24; + if ($duration_unit == 's') $result = $duration_value / 3600; + if ($duration_unit == 'i') $result = $duration_value / 60; + if ($duration_unit == 'h') $result = $duration_value; + if ($duration_unit == 'd') $result = $duration_value * 24; + if ($duration_unit == 'w') $result = $duration_value * 24 * 7; + if ($duration_unit == 'm') $result = $duration_value * 730.484; + if ($duration_unit == 'y') $result = $duration_value * 365 * 24; return $result; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 23fdd431696..b8796391e81 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1468,7 +1468,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } - if($type == 1 && $conf->workstation->enabled){ + if ($type == 1 && $conf->workstation->enabled) { // Default workstation print ''; } - if($object->isService() && $conf->workstation->enabled) { + if ($object->isService() && $conf->workstation->enabled) { $workstation = new Workstation($db); $res = $workstation->fetch($object->fk_default_workstation); diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index d6017877375..0ac039b55ec 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -434,7 +434,6 @@ class FormProduct $out .= ''; } foreach ($this->cache_workstations as $id => $arraytypes) { - $label = $arraytypes['label']; $out .= '
'.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).''.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').'' . $form->textwithpicto($langs->trans('Unit'), '').'' . $form->textwithpicto($langs->trans('Workstation'), '') . '' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).''.$langs->trans('Qty').''; print ''; @@ -82,10 +82,9 @@ if ($nolinesbefore) { print '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . '' . $form->textwithpicto($langs->trans('Unit'), '').'' . $form->textwithpicto($langs->trans('Workstation'), '') . '' . $form->textwithpicto($langs->trans('Workstation'), '') . '' . $form->textwithpicto($langs->trans('TotalCost'), '') . ''; // Predefined product/service if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - if($filtertype == 1){ + if ($filtertype == 1) { print $langs->trans("Service"); - } - elseif (!empty($conf->global->BOM_SUB_BOM)) { + } elseif (!empty($conf->global->BOM_SUB_BOM)) { print $langs->trans("Product"); } echo ''; @@ -118,8 +116,7 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer $form->select_produits(GETPOST('idprod', 'int'), (($filtertype == 1) ? 'idprodservice' : 'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); - } - else { + } else { $form->select_produits(GETPOST('idprod', 'int'), (($filtertype == 1) ? 'idprodservice' : 'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } @@ -137,7 +134,7 @@ $coldisplay++; print ''; print ''; @@ -213,11 +210,11 @@ jQuery(document).ready(function() { }); //change unit selected if we change service selected - + $('#idprodservice').change(function(){ var idproduct = $(this).val(); $.ajax({ - url : "" + url : "" ,type: 'POST' ,data: { 'action': 'getDurationUnitByProduct' diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index b669c936412..b803277f359 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -47,7 +47,7 @@ if (empty($forceall)) { $forceall = 0; } -if(empty($filtertype)) $filtertype = 0; +if (empty($filtertype)) $filtertype = 0; $formproduct = new FormProduct($object->db); @@ -115,7 +115,7 @@ if (($line->info_bits & 2) != 2) { } print ''; @@ -151,7 +151,6 @@ if($filtertype != 1) { $coldisplay++; print ''; print ''.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').'' . $langs->trans('Unit') . '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'' . $form->textwithpicto($langs->trans('Unit'), '').'' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . '' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).''; $label = $tmpproduct->getLabelOfUnit('long'); @@ -137,7 +137,7 @@ if($filtertype != 1) { } elseif ($tmpproduct->duration_value > 0) { $dur = array("s"=>$langs->trans("Second"), "i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } - if(!empty($line->duration_unit)){ + if (!empty($line->duration_unit)) { print (isset($dur[$line->duration_unit]) ? " ".$langs->trans($dur[$line->duration_unit])." " : ''); } else { print (!empty($tmpproduct->duration_unit) && isset($dur[$tmpproduct->duration_unit]) ? " " . $langs->trans($dur[$tmpproduct->duration_unit]) . " " : ''); @@ -145,13 +145,13 @@ if($filtertype != 1) { print ''; $coldisplay++; - if($res > 0) echo $workstation->getNomUrl(); + if ($res > 0) echo $workstation->getNomUrl(); print '
'.$langs->trans("DefaultWorkstation").''; print img_picto($langs->trans("DefaultWorkstation"), 'workstation', 'class="pictofixedwidth"'); @@ -2016,7 +2016,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { */ } - if($object->isService() && $conf->workstation->enabled) { + if ($object->isService() && $conf->workstation->enabled) { // Default workstation print '
'.$langs->trans("DefaultWorkstation").''; print img_picto($langs->trans("DefaultWorkstation"), 'workstation', 'class="pictofixedwidth"'); @@ -2505,7 +2505,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products form - - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; - - print "\n"; - - mrpCollapseBomManagement(); + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products form + + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print "\n"; + + mrpCollapseBomManagement(); + + //Services $filtertype = 1; $res = $object->fetchLinesbytypeproduct(1); $object->calculateCosts(); - if ($res > 0) { - print load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + print '
+ + + + + '; - print ' - - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - $tagidfortablednd = 'tablelinesservice'; - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add services form - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + $tagidfortablednd = 'tablelinesservice'; + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add services form + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + print "
\n"; } + $res = $object->fetchLines(); // Buttons for actions diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index db03f6bf0bd..e3aa0180cf5 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -444,7 +444,7 @@ class BOM extends CommonObject $i++; } - return 1; + return $num_rows; } else { $this->error = $this->db->lasterror(); $this->errors[] = $this->error; From 7f1a17bcc97a14b47c48ddfcf4677614b34332f7 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 20 Jul 2022 15:38:37 +0200 Subject: [PATCH 16/69] Change fk_unit service lines management --- htdocs/bom/ajax/ajax.php | 8 ++++---- htdocs/bom/bom_card.php | 10 ++++++---- htdocs/bom/class/bom.class.php | 5 +++-- htdocs/bom/tpl/objectline_create.tpl.php | 12 +++++++++--- htdocs/bom/tpl/objectline_edit.tpl.php | 2 +- htdocs/bom/tpl/objectline_view.tpl.php | 16 +++++++--------- htdocs/core/class/cunits.class.php | 7 ++++--- htdocs/core/lib/functions.lib.php | 6 +++++- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_bom_bomline.sql | 2 +- 10 files changed, 41 insertions(+), 29 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index 2ad12cc60a3..fac4fee6ef4 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -53,6 +53,7 @@ if (!defined('NOBROWSERNOTIF')) { include_once '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $action = GETPOST('action', 'aZ09'); @@ -69,10 +70,9 @@ if ($action == 'getDurationUnitByProduct') { $product = new Product($db); $res = $product->fetch($idproduct); - if ($res > 0) { - $return = $product->duration_unit; - } + $cUnit = new CUnits($db); + $fk_unit = $cUnit->getUnitFromCode($product->duration_unit, 'short_label','time'); - echo json_encode($return); + echo json_encode($fk_unit); exit(); } diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index ce9a284200b..026f055fb8c 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -167,7 +167,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $duration_unit = GETPOST('duration_unit', 'alphanohtml'); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -191,7 +191,7 @@ if (empty($reshook)) { $bomline->qty_frozen = (int) $qty_frozen; $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; - $bomline->duration_unit = $duration_unit; + $bomline->fk_unit = $fk_unit; // Rang to use $rangmax = $object->line_max(0); @@ -227,7 +227,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $duration_unit = GETPOST('duration_unit', 'alphanohtml'); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -240,7 +240,9 @@ if (empty($reshook)) { $bomline->qty_frozen = (int) $qty_frozen; $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; - $bomline->duration_unit = $duration_unit; + + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + $bomline->fk_unit = $fk_unit; $result = $bomline->update($user); if ($result <= 0) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e3aa0180cf5..f74a1d69263 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1128,7 +1128,8 @@ class BOM extends CommonObject } } else { //Convert qty to hour - $qty = convertDurationtoHour($line->qty, $line->duration_unit); + $unit = measuringUnitString($line->fk_unit); + $qty = convertDurationtoHour($line->qty, $unit); if ($conf->workstation->enabled) { if ($tmpproduct->fk_default_workstation) { @@ -1293,7 +1294,7 @@ class BOMLine extends CommonObjectLine 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), 'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), - 'duration_unit' => array('type'=>'varchar(6)', 'label'=>'Unit', 'enabled'=>1, 'visible'=>1, 'position'=>120, 'notnull'=>-1,), + 'fk_unit' => array('type'=>'integer', 'label'=>'Unit', 'enabled'=>1, 'visible'=>1, 'position'=>120, 'notnull'=>-1,), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index ff257d6ab72..f8fa20e1db4 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -160,8 +160,11 @@ if ($filtertype != 1) { print ''; } else { $coldisplay++; + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + $cUnit = new CUnits($this->db); + $fk_unit_default = $cUnit->getUnitFromCode('h', 'short_label','time'); print ''; - print $formproduct->selectMeasuringUnits("duration_unit", "time", 'h', 0, 1); + print $formproduct->selectMeasuringUnits("fk_unit", "time", $fk_unit_default, 0, 0); print ''; $coldisplay++; @@ -212,7 +215,8 @@ jQuery(document).ready(function() { //change unit selected if we change service selected $('#idprodservice').change(function(){ - var idproduct = $(this).val(); + var idproduct = $(this).val(); + $.ajax({ url : "" ,type: 'POST' @@ -221,8 +225,10 @@ jQuery(document).ready(function() { ,'idproduct' : idproduct } }).done(function(data) { + + console.log(data); var data = JSON.parse(data); - $('#duration_unit').val(data).change();; + $("#fk_unit").val(data).change(); }); }); diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index b803277f359..d7505207f4c 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -141,7 +141,7 @@ if ($filtertype != 1) { $coldisplay++; print ''; - print $formproduct->selectMeasuringUnits("duration_unit", "time", ($line->duration_unit) ? $line->duration_unit : '', 0, 1); + print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0); print ''; $coldisplay++; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 2c9758f2176..7c436d5721e 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -132,16 +132,14 @@ if ($filtertype != 1) { //Unité print ''; $coldisplay++; - if ($line->qty > 1) { - $dur = array("s"=>$langs->trans("Seconds"), "i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ($tmpproduct->duration_value > 0) { - $dur = array("s"=>$langs->trans("Second"), "i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); - } - if (!empty($line->duration_unit)) { - print (isset($dur[$line->duration_unit]) ? " ".$langs->trans($dur[$line->duration_unit])." " : ''); - } else { - print (!empty($tmpproduct->duration_unit) && isset($dur[$tmpproduct->duration_unit]) ? " " . $langs->trans($dur[$tmpproduct->duration_unit]) . " " : ''); + + if (!empty($line->fk_unit)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + $unit = new CUnits($this->db); + $unit->fetch($line->fk_unit); + print (isset($unit->label) ? " ".$langs->trans(ucwords($unit->label))." " : ''); } + print ''; //Poste de travail diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index dfc22fd37ec..9ad1f77e84a 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -420,15 +420,16 @@ class CUnits // extends CommonObject * Get unit from code * @param string $code code of unit * @param string $mode 0= id , short_label=Use short label as value, code=use code + * @param string $unit_type weight,size,surface,volume,qty,time... * @return int <0 if KO, Id of code if OK */ - public function getUnitFromCode($code, $mode = 'code') + public function getUnitFromCode($code, $mode = 'code', $unit_type='') { if ($mode == 'short_label') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid'); + return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid',0, ' AND unit_type = "'.$unit_type.'"'); } elseif ($mode == 'code') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid'); + return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid',0, ' AND unit_type = "'. $unit_type .'"'); } return $code; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 381280289ee..8f08d77c6fb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8504,10 +8504,11 @@ function dol_osencode($str) * @param string $fieldkey Field to search the key into * @param string $fieldid Field to get * @param int $entityfilter Filter by entity + * @param string $filters Filter on other fields * @return int <0 if KO, Id of code if OK * @see $langs->getLabelFromKey */ -function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0) +function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = array()) { global $cache_codes; @@ -8529,6 +8530,9 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = if (!empty($entityfilter)) { $sql .= " AND entity IN (".getEntity($tablename).")"; } + if ($filters) { + $sql .= $filters; + } $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index fb1ba0a8da2..051889a3dde 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -57,4 +57,4 @@ ALTER TABLE llx_facture_fourn ADD COLUMN close_missing_amount double(24, 8) afte ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER amount; ALTER TABLE llx_product ADD COLUMN fk_default_workstation integer DEFAULT NULL; -ALTER TABLE llx_bom_bomline ADD COLUMN duration_unit varchar(6) DEFAULT NULL; +ALTER TABLE llx_bom_bomline ADD COLUMN fk_unit integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index c93484db92a..eae1f6c6662 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -25,7 +25,7 @@ CREATE TABLE llx_bom_bomline( qty_frozen smallint DEFAULT 0, disable_stock_change smallint DEFAULT 0, efficiency double(24,8) NOT NULL DEFAULT 1, - duration_unit varchar(6) NULL, + fk_unit integer NULL, position integer NOT NULL DEFAULT 0 -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From 9ef883e7b007d9073868a64d32a7f14278f068f1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 20 Jul 2022 13:42:33 +0000 Subject: [PATCH 17/69] Fixing style errors. --- htdocs/bom/ajax/ajax.php | 2 +- htdocs/bom/tpl/objectline_create.tpl.php | 2 +- htdocs/core/class/cunits.class.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index fac4fee6ef4..2a57752edde 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -71,7 +71,7 @@ if ($action == 'getDurationUnitByProduct') { $res = $product->fetch($idproduct); $cUnit = new CUnits($db); - $fk_unit = $cUnit->getUnitFromCode($product->duration_unit, 'short_label','time'); + $fk_unit = $cUnit->getUnitFromCode($product->duration_unit, 'short_label', 'time'); echo json_encode($fk_unit); exit(); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index f8fa20e1db4..43982ed9a7d 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -162,7 +162,7 @@ if ($filtertype != 1) { $coldisplay++; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $cUnit = new CUnits($this->db); - $fk_unit_default = $cUnit->getUnitFromCode('h', 'short_label','time'); + $fk_unit_default = $cUnit->getUnitFromCode('h', 'short_label', 'time'); print ''; print $formproduct->selectMeasuringUnits("fk_unit", "time", $fk_unit_default, 0, 0); print ''; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 9ad1f77e84a..3104ccd347d 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -423,13 +423,13 @@ class CUnits // extends CommonObject * @param string $unit_type weight,size,surface,volume,qty,time... * @return int <0 if KO, Id of code if OK */ - public function getUnitFromCode($code, $mode = 'code', $unit_type='') + public function getUnitFromCode($code, $mode = 'code', $unit_type = '') { if ($mode == 'short_label') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid',0, ' AND unit_type = "'.$unit_type.'"'); + return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid', 0, ' AND unit_type = "'.$unit_type.'"'); } elseif ($mode == 'code') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid',0, ' AND unit_type = "'. $unit_type .'"'); + return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid', 0, ' AND unit_type = "'. $unit_type .'"'); } return $code; From e4ec999b455457098403cd19b2ca16d3fed88ac0 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 21 Jul 2022 14:33:50 +0200 Subject: [PATCH 18/69] Retour stickler --- htdocs/bom/tpl/objectline_edit.tpl.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index d7505207f4c..0ce88fa359c 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -138,7 +138,6 @@ if ($filtertype != 1) { print ''; print ''; } else { - $coldisplay++; print ''; print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0); From 420b2c1651283811f7665e4577ad5794c5adb6d2 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 17 Aug 2022 09:44:20 +0200 Subject: [PATCH 19/69] FIX : display labl in workstation select, no ref --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 0ac039b55ec..a21ff6348e6 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -191,7 +191,7 @@ class FormProduct return 0; // Cache already loaded and we do not want a list with information specific to a product } - $sql = "SELECT w.rowid, w.ref as label, w.type, w.nb_operators_required,w.thm_operator_estimated,w.thm_machine_estimated"; + $sql = "SELECT w.rowid, w.ref as ref, w.label as label, w.type, w.nb_operators_required,w.thm_operator_estimated,w.thm_machine_estimated"; $sql .= " FROM ".$this->db->prefix()."workstation_workstation as w"; $sql .= " WHERE 1 = 1"; if (!empty($fk_product) && $fk_product > 0) { From 9ec0c9963ac90f3404a8df0de0352a16119eb10e Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 17 Aug 2022 10:26:25 +0200 Subject: [PATCH 20/69] FIX : total cost line => bad convert --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ac73ab58475..c57a5816517 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1128,7 +1128,7 @@ class BOM extends CommonObject } } else { //Convert qty to hour - $unit = measuringUnitString($line->fk_unit); + $unit = measuringUnitString($line->fk_unit, '', '', 1); $qty = convertDurationtoHour($line->qty, $unit); if ($conf->workstation->enabled) { From 1a15582c49f790e75460d04e74aee241aa61f388 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 24 Aug 2022 09:43:48 +0000 Subject: [PATCH 21/69] Fixing style errors. --- htdocs/bom/bom_card.php | 154 ++++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index f1823e7a79a..e66462d8584 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -147,93 +147,93 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Add line - if ($action == 'addline' && $user->rights->bom->write) { - $langs->load('errors'); - $error = 0; +if ($action == 'addline' && $user->rights->bom->write) { + $langs->load('errors'); + $error = 0; - // Set if we used free entry or predefined product - $bom_child_id = (int) GETPOST('bom_id', 'int'); - if ($bom_child_id > 0) { - $bom_child = new BOM($db); - $res = $bom_child->fetch($bom_child_id); - if ($res) { - $idprod = $bom_child->fk_product; - } - } else { - $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int')); - } - - $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); - $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $fk_unit = GETPOST('fk_unit', 'alphanohtml'); - if ($qty == '') { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; - } - if (!($idprod > 0)) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors'); - $error++; - } - - if ($object->fk_product == $idprod) { - setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); - $error++; - } - - if (!$error) { - $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null); - - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - unset($_POST['idprod']); - unset($_POST['idprodservice']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); - - $object->fetchLines(); - - $object->calculateCosts(); - } + // Set if we used free entry or predefined product + $bom_child_id = (int) GETPOST('bom_id', 'int'); + if ($bom_child_id > 0) { + $bom_child = new BOM($db); + $res = $bom_child->fetch($bom_child_id); + if ($res) { + $idprod = $bom_child->fk_product; } + } else { + $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int')); } - // Update line - if ($action == 'updateline' && $user->rights->bom->write) { - $langs->load('errors'); - $error = 0; + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = price2num(GETPOST('efficiency', 'alpha')); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } + if (!($idprod > 0)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors'); + $error++; + } - // Set if we used free entry or predefined product - $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); - $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $fk_unit = GETPOST('fk_unit', 'alphanohtml'); + if ($object->fk_product == $idprod) { + setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); + $error++; + } - if ($qty == '') { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; + if (!$error) { + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null); + + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['idprodservice']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + + $object->fetchLines(); + + $object->calculateCosts(); } + } +} - if (!$error) { - $bomline = new BOMLine($db); - $bomline->fetch($lineid); + // Update line +if ($action == 'updateline' && $user->rights->bom->write) { + $langs->load('errors'); + $error = 0; - $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key); + // Set if we used free entry or predefined product + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = price2num(GETPOST('efficiency', 'alpha')); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - unset($_POST['idprod']); - unset($_POST['idprodservice']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } + + if (!$error) { + $bomline = new BOMLine($db); + $bomline->fetch($lineid); + + $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key); + + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['idprodservice']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); $object->fetchLines(); From f5d7f66ca06b6add32898630b937e7a5b45f8332 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 24 Aug 2022 11:53:25 +0200 Subject: [PATCH 22/69] Ajout gestion fk_unit --- htdocs/bom/bom_card.php | 5 +++-- htdocs/bom/class/bom.class.php | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index f1823e7a79a..eb75494e01c 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -183,7 +183,7 @@ if (empty($reshook)) { } if (!$error) { - $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null); + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -223,7 +223,7 @@ if (empty($reshook)) { $bomline = new BOMLine($db); $bomline->fetch($lineid); - $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key); + $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -234,6 +234,7 @@ if (empty($reshook)) { unset($_POST['qty']); unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); + } $object->fetchLines(); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 72aed7146a3..2b576fc0b5f 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -569,7 +569,7 @@ class BOM extends CommonObject * @param string $import_key Import Key * @return int <0 if KO, Id of created object if OK */ - public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null) + public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit='') { global $mysoc, $conf, $langs, $user; @@ -637,6 +637,7 @@ class BOM extends CommonObject $this->line->fk_bom_child = $fk_bom_child; $this->line->import_key = $import_key; $this->line->position = $rankToUse; + $this->line->fk_unit = $fk_unit; $result = $this->line->create($user); @@ -668,7 +669,7 @@ class BOM extends CommonObject * @param string $import_key Import Key * @return int <0 if KO, Id of updated BOM-Line if OK */ - public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null) + public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit) { global $mysoc, $conf, $langs, $user; @@ -738,6 +739,7 @@ class BOM extends CommonObject $this->line->efficiency = $efficiency; $this->line->import_key = $import_key; $this->line->position = $rankToUse; + $this->line->fk_unit = $fk_unit; $result = $this->line->update($user); From ab2b445b53ce807408fb293ce8af9573af1affee Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 24 Aug 2022 12:15:28 +0200 Subject: [PATCH 23/69] FIX accolade et gestion fk_unit --- htdocs/bom/bom_card.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index e66462d8584..3c188077237 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -183,7 +183,7 @@ if ($action == 'addline' && $user->rights->bom->write) { } if (!$error) { - $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null); + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -195,10 +195,11 @@ if ($action == 'addline' && $user->rights->bom->write) { unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - $object->fetchLines(); - - $object->calculateCosts(); } + + $object->fetchLines(); + + $object->calculateCosts(); } } @@ -223,7 +224,7 @@ if ($action == 'updateline' && $user->rights->bom->write) { $bomline = new BOMLine($db); $bomline->fetch($lineid); - $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key); + $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -235,10 +236,11 @@ if ($action == 'updateline' && $user->rights->bom->write) { unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - $object->fetchLines(); - - $object->calculateCosts(); } + + $object->fetchLines(); + + $object->calculateCosts(); } } @@ -619,6 +621,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } } } From 8f336b1e505eabd96f0667eac015dcca720b0244 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 24 Aug 2022 10:20:16 +0000 Subject: [PATCH 24/69] Fixing style errors. --- htdocs/bom/bom_card.php | 722 ++++++++++++++++----------------- htdocs/bom/class/bom.class.php | 2 +- 2 files changed, 361 insertions(+), 363 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 3c188077237..a80792705ee 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -147,328 +147,326 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Add line -if ($action == 'addline' && $user->rights->bom->write) { - $langs->load('errors'); - $error = 0; + if ($action == 'addline' && $user->rights->bom->write) { + $langs->load('errors'); + $error = 0; - // Set if we used free entry or predefined product - $bom_child_id = (int) GETPOST('bom_id', 'int'); - if ($bom_child_id > 0) { - $bom_child = new BOM($db); - $res = $bom_child->fetch($bom_child_id); - if ($res) { - $idprod = $bom_child->fk_product; - } - } else { - $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int')); - } - - $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); - $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $fk_unit = GETPOST('fk_unit', 'alphanohtml'); - if ($qty == '') { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; - } - if (!($idprod > 0)) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors'); - $error++; - } - - if ($object->fk_product == $idprod) { - setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); - $error++; - } - - if (!$error) { - $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit); - - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; + // Set if we used free entry or predefined product + $bom_child_id = (int) GETPOST('bom_id', 'int'); + if ($bom_child_id > 0) { + $bom_child = new BOM($db); + $res = $bom_child->fetch($bom_child_id); + if ($res) { + $idprod = $bom_child->fk_product; + } } else { - unset($_POST['idprod']); - unset($_POST['idprodservice']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); - + $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int')); } - $object->fetchLines(); + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = price2num(GETPOST('efficiency', 'alpha')); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } + if (!($idprod > 0)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors'); + $error++; + } - $object->calculateCosts(); + if ($object->fk_product == $idprod) { + setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); + $error++; + } + + if (!$error) { + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit); + + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['idprodservice']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } + + $object->fetchLines(); + + $object->calculateCosts(); + } } -} // Update line -if ($action == 'updateline' && $user->rights->bom->write) { - $langs->load('errors'); - $error = 0; + if ($action == 'updateline' && $user->rights->bom->write) { + $langs->load('errors'); + $error = 0; - // Set if we used free entry or predefined product - $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); - $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = price2num(GETPOST('efficiency', 'alpha')); - $fk_unit = GETPOST('fk_unit', 'alphanohtml'); - - if ($qty == '') { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; - } - - if (!$error) { - $bomline = new BOMLine($db); - $bomline->fetch($lineid); - - $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit); - - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - unset($_POST['idprod']); - unset($_POST['idprodservice']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); + // Set if we used free entry or predefined product + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = price2num(GETPOST('efficiency', 'alpha')); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; } - $object->fetchLines(); + if (!$error) { + $bomline = new BOMLine($db); + $bomline->fetch($lineid); - $object->calculateCosts(); - } -} + $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit); + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['idprodservice']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } + $object->fetchLines(); -/* - * View - */ - -$form = new Form($db); -$formfile = new FormFile($db); - - -$title = $langs->trans('BOM'); -$help_url ='EN:Module_BOM'; -llxHeader('', $title, $help_url); - -// Part to create -if ($action == 'create') { - print load_fiche_titre($langs->trans("NewBOM"), '', 'bom'); - - print '
'; - print ''; - print ''; - print ''; - - print dol_get_fiche_head(array(), ''); - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - - print '
'."\n"; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print '
'; -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print dol_get_fiche_head(); - - //$object->fields['keyfield']['disabled'] = 1; - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print '
'; -} - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $head = bomPrepareHead($object); - print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $object->calculateCosts(); + } } - // Confirmation of validation - if ($action == 'validate') { - // We check that object has a temporary ref - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { - $object->fetch_product(); - $numref = $object->getNextNumRef($object->product); - } else { - $numref = $object->ref; + + + /* + * View + */ + + $form = new Form($db); + $formfile = new FormFile($db); + + + $title = $langs->trans('BOM'); + $help_url ='EN:Module_BOM'; + llxHeader('', $title, $help_url); + + // Part to create + if ($action == 'create') { + print load_fiche_titre($langs->trans("NewBOM"), '', 'bom'); + + print '
'; + print ''; + print ''; + print ''; + + print dol_get_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("Create"); + + print '
'; + } + + // Part to edit record + if (($id || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print dol_get_fiche_head(); + + //$object->fields['keyfield']['disabled'] = 1; + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("Create"); + + print '
'; + } + + // Part to show record + if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $head = bomPrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } - $text = $langs->trans('ConfirmValidateBom', $numref); - /*if (! empty($conf->notification->enabled)) - { + // Confirmation of validation + if ($action == 'validate') { + // We check that object has a temporary ref + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') { + $object->fetch_product(); + $numref = $object->getNextNumRef($object->product); + } else { + $numref = $object->ref; + } + + $text = $langs->trans('ConfirmValidateBom', $numref); + /*if (! empty($conf->notification->enabled)) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); - }*/ + }*/ - $formquestion = array(); - if (!empty($conf->bom->enabled)) { - $langs->load("mrp"); - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( + $formquestion = array(); + if (!empty($conf->bom->enabled)) { + $langs->load("mrp"); + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); - } - - // Confirmation of closing - if ($action == 'close') { - $text = $langs->trans('ConfirmCloseBom', $object->ref); - /*if (! empty($conf->notification->enabled)) - { + // Confirmation of closing + if ($action == 'close') { + $text = $langs->trans('ConfirmCloseBom', $object->ref); + /*if (! empty($conf->notification->enabled)) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); - }*/ + }*/ - $formquestion = array(); - if (!empty($conf->bom->enabled)) { - $langs->load("mrp"); - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( + $formquestion = array(); + if (!empty($conf->bom->enabled)) { + $langs->load("mrp"); + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); - } + // Confirmation of reopen + if ($action == 'reopen') { + $text = $langs->trans('ConfirmReopenBom', $object->ref); + /*if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); + }*/ - // Confirmation of reopen - if ($action == 'reopen') { - $text = $langs->trans('ConfirmReopenBom', $object->ref); - /*if (! empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); - }*/ - - $formquestion = array(); - if (!empty($conf->bom->enabled)) { - $langs->load("mrp"); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( + $formquestion = array(); + if (!empty($conf->bom->enabled)) { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); - } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } + // Confirmation of action xxxx + if ($action == 'setdraft') { + $text = $langs->trans('ConfirmSetToDraft', $object->ref); - // Confirmation of action xxxx - if ($action == 'setdraft') { - $text = $langs->trans('ConfirmSetToDraft', $object->ref); + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); + } - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); - } + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; + // Print form confirm + print $formconfirm; - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (! empty($conf->project->enabled)) - { + $morehtmlref = '
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->project->enabled)) + { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) @@ -495,51 +493,51 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=''; } } - } - */ - $morehtmlref .= '
'; + } + */ + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; - print ''."\n"; + print '
'; + print '
'; + print '
'; + print '
'."\n"; - // Common attributes - $keyforbreak = 'duration'; - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - $object->calculateCosts(); - print ''; - print ''; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).'
'.$langs->trans("UnitCost").''.price($object->unit_cost).'
'; - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - - - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - //Products - $res = $object->fetchLinesbytypeproduct(0); + // Common attributes + $keyforbreak = 'duration'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; $object->calculateCosts(); + print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).''; + print ''.$langs->trans("UnitCost").''.price($object->unit_cost).''; - print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print '
+ print ''; + print ''; + print ''; + + print '
'; + + print dol_get_fiche_end(); + + + + /* + * Lines + */ + + if (!empty($object->table_element_line)) { + //Products + $res = $object->fetchLinesbytypeproduct(0); + $object->calculateCosts(); + + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); + + print ' @@ -547,79 +545,79 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea '; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form - - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } - } - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } - print "\n"; + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } - mrpCollapseBomManagement(); + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form - //Services - $filtertype = 1; - $res = $object->fetchLinesbytypeproduct(1); - $object->calculateCosts(); + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } - print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; - print '
+ print "
\n"; + + mrpCollapseBomManagement(); + + + //Services + $filtertype = 1; + $res = $object->fetchLinesbytypeproduct(1); + $object->calculateCosts(); + + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + + print '
'; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - $tagidfortablednd = 'tablelinesservice'; - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; - } + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + $tagidfortablednd = 'tablelinesservice'; + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add services form - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add services form + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); } } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 2b576fc0b5f..d5f3351770e 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -569,7 +569,7 @@ class BOM extends CommonObject * @param string $import_key Import Key * @return int <0 if KO, Id of created object if OK */ - public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit='') + public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit = '') { global $mysoc, $conf, $langs, $user; From c581024c8c39bf45e60fc503a373ced50099ba9b Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 3 Aug 2022 03:02:07 +0200 Subject: [PATCH 25/69] NEW: Public counters feature --- htdocs/adherents/admin/website.php | 9 +++++++++ htdocs/langs/en_US/members.lang | 1 + htdocs/public/members/new.php | 11 +++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 884c6e67be2..b4c40936bbf 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -58,6 +58,7 @@ if ($action == 'update') { $public = GETPOST('MEMBER_ENABLE_PUBLIC'); $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2); $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT'); + $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int'); $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09'); @@ -65,6 +66,7 @@ if ($action == 'update') { $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); @@ -216,6 +218,13 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1); print "\n"; + // SHow counter of validated members publicly + print '\n"; + // Jump to an online payment page print ''; print ''; print ''; + if($publiccounters) print ''; print ''; print "\n"; @@ -811,6 +816,8 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW } print ''; print ''; + $membercount = $objp->membercount>0? $objp->membercount: "–"; + if($publiccounters) print ''; print ''; print ""; $i++; From 0427cce9b262a2062a4e6904ea1dda1db796a9f5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 26 Aug 2022 19:23:51 +0000 Subject: [PATCH 26/69] Fixing style errors. --- htdocs/adherents/admin/website.php | 2 +- htdocs/public/members/new.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index b4c40936bbf..4ea40427de7 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -218,7 +218,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1); print "\n"; - // SHow counter of validated members publicly + // SHow counter of validated members publicly print ''; print ''; print ''; - if($publiccounters) print ''; + if ($publiccounters) print ''; print ''; print "\n"; @@ -817,7 +817,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''; print ''; $membercount = $objp->membercount>0? $objp->membercount: "–"; - if($publiccounters) print ''; + if ($publiccounters) print ''; print ''; print ""; $i++; From db7bb77d03ff51565856aec6dac8f5de99598726 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Sep 2022 10:31:56 +0200 Subject: [PATCH 27/69] Update bom_card.php --- htdocs/bom/bom_card.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 25b7a8730dd..2801b8e3d66 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -17,9 +17,9 @@ */ /** - * \file htdocs/bom/bom_card.php - * \ingroup bom - * \brief Page to create/edit/view bom + * \file htdocs/bom/bom_card.php + * \ingroup bom + * \brief Page to create/edit/view BOM */ // Load Dolibarr environment @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("mrp", "other")); +$langs->loadLangs(array('mrp', 'other')); // Get parameters $id = GETPOST('id', 'int'); @@ -335,7 +335,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } $text = $langs->trans('ConfirmValidateBom', $numref); - /*if (!empty($conf->notification->enabled)) + /*if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); @@ -363,7 +363,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation of closing if ($action == 'close') { $text = $langs->trans('ConfirmCloseBom', $object->ref); - /*if (!empty($conf->notification->enabled)) + /*if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); @@ -391,7 +391,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation of reopen if ($action == 'reopen') { $text = $langs->trans('ConfirmReopenBom', $object->ref); - /*if (!empty($conf->notification->enabled)) + /*if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); @@ -457,7 +457,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); // Project - if (!empty($conf->project->enabled)) + if (! empty($conf->project->enabled)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; @@ -477,7 +477,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (!empty($object->fk_project)) { + if (! empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); $morehtmlref.=$proj->getNomUrl(); From 444ba4bf46e2225bbe6952a30fea6b2a548f3fb1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 8 Sep 2022 11:40:40 +0200 Subject: [PATCH 28/69] FIX Returns --- htdocs/bom/ajax/ajax.php | 2 +- htdocs/bom/tpl/objectline_view.tpl.php | 4 +++- htdocs/core/class/cunits.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index 2a57752edde..444ce9beeb2 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -66,7 +66,7 @@ $idproduct = GETPOST('idproduct', 'int'); top_httphead(); -if ($action == 'getDurationUnitByProduct') { +if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) { $product = new Product($db); $res = $product->fetch($idproduct); diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 7c436d5721e..46c708f8c4e 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -65,7 +65,9 @@ if (empty($outputalsopricetotalwithtax)) { } // add html5 elements -$domData = ' data-element="'.$line->element.'service"'; +if($filtertype == 1) $domData = ' data-element="'.$line->element.'service"'; +else $domData = ' data-element="'.$line->element.'"'; + $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 3104ccd347d..102bbbda652 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -427,9 +427,9 @@ class CUnits // extends CommonObject { if ($mode == 'short_label') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid', 0, ' AND unit_type = "'.$unit_type.'"'); + return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid', 0, ' AND unit_type = "'.$this->db->escape($unit_type).'"'); } elseif ($mode == 'code') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid', 0, ' AND unit_type = "'. $unit_type .'"'); + return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid', 0, ' AND unit_type = "'. $this->db->escape($unit_type) .'"'); } return $code; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index afee28da2fd..2e819b8539d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8539,11 +8539,11 @@ function dol_osencode($str) * @param string $fieldkey Field to search the key into * @param string $fieldid Field to get * @param int $entityfilter Filter by entity - * @param string $filters Filter on other fields + * @param string $filters Filter on other fields * @return int <0 if KO, Id of code if OK * @see $langs->getLabelFromKey */ -function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = array()) +function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '') { global $cache_codes; From 8152e3f82a6cf09ba9b97481258b00e57d2628bb Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 8 Sep 2022 11:43:48 +0200 Subject: [PATCH 29/69] Clean code --- htdocs/bom/class/bom.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 64af253b1f2..78b7e78f91f 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -667,6 +667,7 @@ class BOM extends CommonObject * @param float $efficiency Efficiency in MO * @param int $position Position of BOM-Line in BOM-Lines * @param string $import_key Import Key + * @param int $fk_unit Unit of line * @return int <0 if KO, Id of updated BOM-Line if OK */ public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit) From d0429ad8a102bd248b6287fabf6c2737fd3f8422 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 8 Sep 2022 09:48:48 +0000 Subject: [PATCH 30/69] Fixing style errors. --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 46c708f8c4e..a3b9df0bdf0 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -65,7 +65,7 @@ if (empty($outputalsopricetotalwithtax)) { } // add html5 elements -if($filtertype == 1) $domData = ' data-element="'.$line->element.'service"'; +if ($filtertype == 1) $domData = ' data-element="'.$line->element.'service"'; else $domData = ' data-element="'.$line->element.'"'; $domData .= ' data-id="'.$line->id.'"'; From 1b5636ff66ce2dab7985b30af3e7b017edf2de03 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 8 Sep 2022 11:58:18 +0200 Subject: [PATCH 31/69] Fix stickler --- htdocs/bom/class/bom.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 78b7e78f91f..b61a65f95a2 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -667,10 +667,10 @@ class BOM extends CommonObject * @param float $efficiency Efficiency in MO * @param int $position Position of BOM-Line in BOM-Lines * @param string $import_key Import Key - * @param int $fk_unit Unit of line + * @param int $fk_unit Unit of line * @return int <0 if KO, Id of updated BOM-Line if OK */ - public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit) + public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit = 0) { global $mysoc, $conf, $langs, $user; @@ -740,7 +740,7 @@ class BOM extends CommonObject $this->line->efficiency = $efficiency; $this->line->import_key = $import_key; $this->line->position = $rankToUse; - $this->line->fk_unit = $fk_unit; + if(!empty($fk_unit)) $this->line->fk_unit = $fk_unit; $result = $this->line->update($user); From f22744210e6f2c7d12b0a413f9da01bd48dd794d Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 9 Sep 2022 11:31:06 +0200 Subject: [PATCH 32/69] Fix : missing column in etablishement sql --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 1 + htdocs/install/mysql/tables/llx_establishment.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 8121b94494d..5536e09ca42 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -149,3 +149,4 @@ UPDATE llx_c_effectif SET code='EF101-500', libelle='101 - 500' WHERE code='EF10 ALTER TABLE llx_rights_def ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; +ALTER TABLE llx_establishment ADD COLUMN label varchar(255) NOT NULL AFTER entity; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_establishment.sql b/htdocs/install/mysql/tables/llx_establishment.sql index 7159a53059c..1b0d2668cb0 100644 --- a/htdocs/install/mysql/tables/llx_establishment.sql +++ b/htdocs/install/mysql/tables/llx_establishment.sql @@ -22,6 +22,7 @@ CREATE TABLE llx_establishment ( rowid integer NOT NULL auto_increment PRIMARY KEY, entity integer NOT NULL DEFAULT 1, + label varchar(255) NOT NULL, ref varchar(30), name varchar(128), address varchar(255), From 857646ed364b9fc252343aa4d3fa78eec18d2fba Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:00:38 +0200 Subject: [PATCH 33/69] update code toward php8 compliance --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/api/class/api_documents.class.php | 2 +- htdocs/categories/class/api_categories.class.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index a76fa1945c2..36d268a06cf 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -480,7 +480,7 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Bookkeeping'; $objectlabel = 'Bookkeeping'; - $permissiontoread = $user->rights->societe->lire; + $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->rights->societe->supprimer; $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index ba94415782f..786c3914b92 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -395,7 +395,7 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Bookkeeping'; $objectlabel = 'Bookkeeping'; - $permissiontoread = $user->rights->societe->lire; + $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->rights->societe->supprimer; $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d4d652f3e74..2c7653c3bb3 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -272,7 +272,7 @@ class Documents extends DolibarrApi if ($modulepart == 'societe' || $modulepart == 'thirdparty') { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 76381c0d53d..e59ff070aec 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -315,7 +315,7 @@ class Categories extends DolibarrApi throw new RestException(401); } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) { + } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { throw new RestException(401); From 3f2faf466768471729ec95054b26a549b080aa64 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:02:48 +0200 Subject: [PATCH 34/69] update code toward php8 compliance --- htdocs/comm/index.php | 4 ++-- htdocs/contact/list.php | 2 +- htdocs/core/ajax/objectonoff.php | 2 +- htdocs/core/boxes/box_clients.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index ed6184e0cd4..01f3bba9eff 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -594,7 +594,7 @@ print '
'; /* * Last modified customers or prospects */ -if (isModEnabled("societe") && $user->rights->societe->lire) { +if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -700,7 +700,7 @@ if (isModEnabled("societe") && $user->rights->societe->lire) { /* * Last suppliers */ -if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->societe->lire) { +if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 1070c9e0b9d..c2b0120790b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -312,7 +312,7 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Contact'; $objectlabel = 'Contact'; - $permissiontoread = $user->rights->societe->lire; + $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->rights->societe->supprimer; $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index c66a49557d0..77cd3234cd8 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -67,7 +67,7 @@ if (!empty($user->socid)) { $socid = $user->socid; } -//$user->rights->societe->lire = 0;$user->rights->fournisseur->lire = 0; +//$user->hasRight('societe', 'lire') = 0;$user->rights->fournisseur->lire = 0; //restrictedArea($user, 'societe', $id); if (in_array($field, array('status'))) { diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 364b79932ef..cb934debef3 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -86,7 +86,7 @@ class box_clients extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); - if ($user->rights->societe->lire) { + if ($user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; From 4ccc79f253a93ce423d36ef99a66ff2189da3c63 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:04:37 +0200 Subject: [PATCH 35/69] update code toward php8 compliance --- htdocs/core/boxes/box_customers_outstanding_bill_reached.php | 2 +- htdocs/core/boxes/box_dolibarr_state_board.php | 4 ++-- htdocs/core/boxes/box_fournisseurs.php | 2 +- htdocs/core/boxes/box_goodcustomers.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php index 2bf5a2c0693..ec82f1a57e4 100644 --- a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -86,7 +86,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastOutstandingBillReached", $max)); - if ($user->rights->societe->lire) { + if ($user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index a60d5c20a93..0f63582370c 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -114,8 +114,8 @@ class box_dolibarr_state_board extends ModeleBoxes $conditions = array( 'users' => $user->hasRight('user', 'user', 'lire'), 'members' => isModEnabled('adherent') && $user->rights->adherent->lire, - 'customers' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), - 'prospects' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), + 'customers' => isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), + 'prospects' => isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), 'suppliers' => ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire) diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 59280aeec62..1c14ac0be4f 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -81,7 +81,7 @@ class box_fournisseurs extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); - if ($user->rights->societe->lire) { + if ($user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; $sql .= ", s.logo, s.email, s.entity"; diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 3341e08107d..90ffc82a5d8 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -69,7 +69,7 @@ class box_goodcustomers extends ModeleBoxes $this->enabled = 0; // not enabled by default. Very slow on large database } - $this->hidden = empty($user->rights->societe->lire); + $this->hidden = !$user->hasRight('societe', 'lire'); } /** @@ -90,7 +90,7 @@ class box_goodcustomers extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); - if ($user->rights->societe->lire) { + if ($user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; $sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; From e73b8983bf4f1c0b95614cd43e2fb8725e820010 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:07:00 +0200 Subject: [PATCH 36/69] update code toward php8 compliance --- htdocs/core/boxes/box_contacts.php | 2 +- htdocs/core/boxes/box_prospect.php | 2 +- htdocs/core/lib/security.lib.php | 4 ++-- htdocs/hrm/position_card.php | 2 +- htdocs/margin/index.php | 2 +- htdocs/margin/lib/margins.lib.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index f257d7db18d..f051fe5ade3 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max)); - if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { + if ($user->hasRight('societe', 'lire') && $user->rights->societe->contact->lire) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 205cf09419c..69e8432a879 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -86,7 +86,7 @@ class box_prospect extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max)); - if ($user->rights->societe->lire) { + if ($user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index ce6f9b38320..f4f1d1be5cd 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -831,7 +831,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl if ($user->socid != $objectid) { return false; } - } elseif (isModEnabled("societe") && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) { + } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && empty($user->rights->societe->client->voir))) { // If internal user: Check permission for internal users that are restricted on their objects $sql = "SELECT COUNT(sc.fk_soc) as nb"; $sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -857,7 +857,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.fk_soc = ".((int) $user->socid); - } elseif (isModEnabled("societe") && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) { + } elseif (isModEnabled("societe") && ($user->hasRight('societe', 'lire') && empty($user->rights->societe->client->voir))) { // If internal user: Check permission for internal users that are restricted on their objects $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; diff --git a/htdocs/hrm/position_card.php b/htdocs/hrm/position_card.php index 746e1265a0b..168756d9851 100644 --- a/htdocs/hrm/position_card.php +++ b/htdocs/hrm/position_card.php @@ -337,7 +337,7 @@ function displayPositionCard(&$object) // */ // $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; // $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; -// $genallowed = $user->rights->societe->lire; +// $genallowed = $user->hasRight('societe', 'lire'); // $delallowed = $user->rights->societe->creer; // // print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); diff --git a/htdocs/margin/index.php b/htdocs/margin/index.php index 8363cd331c4..79595d5a8ee 100644 --- a/htdocs/margin/index.php +++ b/htdocs/margin/index.php @@ -27,7 +27,7 @@ require '../main.inc.php'; if ($user->rights->produit->lire) { $page = 'productMargins'; -} elseif ($user->rights->societe->lire) { +} elseif ($user->hasRight('societe', 'lire')) { $page = 'customerMargins'; } else { $page = 'agentMargins'; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 802541b98ca..10e449026fa 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -71,7 +71,7 @@ function marges_prepare_head() $h++; } - if ($user->rights->societe->lire) { + if ($user->hasRight('societe', 'lire')) { $head[$h][0] = DOL_URL_ROOT."/margin/customerMargins.php"; $head[$h][1] = $langs->trans("CustomerMargins"); $head[$h][2] = 'customerMargins'; From b52bcf191fbc6be8f5baa73aee2158bc17527729 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:08:36 +0200 Subject: [PATCH 37/69] update code toward php8 compliance --- htdocs/societe/card.php | 4 ++-- htdocs/societe/index.php | 12 ++++++------ htdocs/societe/list.php | 2 +- htdocs/societe/paymentmodes.php | 2 +- htdocs/societe/website.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index bdc48872c03..ab3ce495872 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -137,7 +137,7 @@ if (!empty($canvas)) { } // Permissions -$permissiontoread = $user->rights->societe->lire; +$permissiontoread = $user->hasRight('societe', 'lire'); $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php @@ -3277,7 +3277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { */ $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed = $user->rights->societe->lire; + $genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 1d0bdfe39a1..e161cd8668c 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -124,10 +124,10 @@ $result = $db->query($sql); if ($result) { while ($objp = $db->fetch_object($result)) { $found = 0; - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; } - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { @@ -150,10 +150,10 @@ $thirdpartygraph .= '
'."\n"; } else { - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { $statstring = ""; $statstring .= ''; $statstring .= ""; } - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { $statstring .= ""; $statstring .= ''; $statstring .= ""; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ff6de888284..6ebd9e3336d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -383,7 +383,7 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Societe'; $objectlabel = 'ThirdParty'; - $permissiontoread = $user->rights->societe->lire; + $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->rights->societe->supprimer; $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 30b19e59d8b..fe5654a0d06 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -79,7 +79,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); // Permissions -$permissiontoread = $user->rights->societe->lire; +$permissiontoread = $user->hasRight('societe', 'lire'); $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php $permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write))); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 8de63dfeffc..17ebb6d7988 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -161,7 +161,7 @@ if (empty($reshook)) { // Mass actions $objectclass = 'WebsiteAccount'; $objectlabel = 'WebsiteAccount'; - $permissiontoread = $user->rights->societe->lire; + $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->rights->societe->supprimer; $uploaddir = $conf->societe->multidir_output[$object->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; From 1485e3bd7934ade1ad4629f12fa6967f21a3f35d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:10:33 +0200 Subject: [PATCH 38/69] update code toward php8 compliance --- .../societe/canvas/company/tpl/card_view.tpl.php | 2 +- .../canvas/individual/tpl/card_view.tpl.php | 2 +- htdocs/societe/class/api_thirdparties.class.php | 16 ++++++++-------- htdocs/ticket/list.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index d1ba18f82fd..48fd3374322 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -283,7 +283,7 @@ for ($i = 1; $i <= 4; $i++) { */ $filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; -$genallowed = $user->rights->societe->lire; +$genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 98979c917d4..5ae12a3c501 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -209,7 +209,7 @@ if ($this->control->tpl['action_delete']) { */ $filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; -$genallowed = $user->rights->societe->lire; +$genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index f197a1b7024..db85884c68d 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -132,7 +132,7 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -848,7 +848,7 @@ class Thirdparties extends DolibarrApi */ public function getOutStandingProposals($id, $mode = 'customer') { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -890,7 +890,7 @@ class Thirdparties extends DolibarrApi */ public function getOutStandingOrder($id, $mode = 'customer') { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -931,7 +931,7 @@ class Thirdparties extends DolibarrApi */ public function getOutStandingInvoices($id, $mode = 'customer') { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -972,7 +972,7 @@ class Thirdparties extends DolibarrApi */ public function getSalesRepresentatives($id, $mode = 0) { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -1015,7 +1015,7 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -1439,7 +1439,7 @@ class Thirdparties extends DolibarrApi */ public function getSocieteAccounts($id, $site = null) { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -1870,7 +1870,7 @@ class Thirdparties extends DolibarrApi { global $conf; - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login.'. No read permission on thirdparties.'); } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 80656681015..0551532b00f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -491,7 +491,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', ''); -if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { +if ($socid && !$projectid && !$project_ref && $user->hasRight('societe', 'lire')) { $socstat = new Societe($db); $res = $socstat->fetch($socid); if ($res > 0) { From a2b8dd446b79f69f8d67b72ead644c3f1a8caf91 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:13:02 +0200 Subject: [PATCH 39/69] update code toward php8 compliance --- htdocs/admin/mails_templates.php | 2 +- htdocs/barcode/printsheet.php | 2 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/lib/company.lib.php | 2 +- htdocs/societe/website.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 3d8d7f3db4f..86f8752d91f 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -186,7 +186,7 @@ if (isModEnabled('adherent') && !empty($user->rights->adherent->lire)) { if (isModEnabled('recruitment') && !empty($user->rights->recruitment->recruitmentjobposition->read)) { $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures')); } -if (isModEnabled("societe") && !empty($user->rights->societe->lire)) { +if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty')); } if (isModEnabled('project')) { diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 96caac1dbb4..373effecbe8 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -397,7 +397,7 @@ if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire) print ''; } -if (!empty($user->rights->societe->lire)) { +if ($user->hasRight('societe', 'lire')) { print ''; print '
'; print '
'; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 96bd34143c7..cb5a7f41f8f 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -104,7 +104,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh } } - if (isModEnabled('societe') && !empty($user->rights->societe->lire)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire')) { print '
'; print img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth inline-block"'); print $form->select_company($socid, 'search_socid', '', ' ', 0, 0, null, 0, 'minwidth100 maxwidth500'); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 9cadb431ec5..b4ae935677b 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -242,7 +242,7 @@ function societe_prepare_head(Societe $object) $h++; } - if (isModEnabled('website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) { + if (isModEnabled('website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && ($user->hasRight('societe', 'lire'))) { $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.urlencode($object->id); $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 17ebb6d7988..5dc25da93a5 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -250,7 +250,7 @@ print dol_get_fiche_end(); $newcardbutton = ''; if (isModEnabled('website')) { - if (!empty($user->rights->societe->lire)) { + if ($user->hasRight('societe', 'lire')) { $newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id)); } else { $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0); From c8a70ba221d922c9e52c00bc11441551349ccac2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:14:25 +0200 Subject: [PATCH 40/69] update code toward php8 compliance --- htdocs/comm/card.php | 2 +- htdocs/core/class/html.formcontract.class.php | 2 +- htdocs/core/class/html.formintervention.class.php | 2 +- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/core/lib/security.lib.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 67df6af0298..1eca4555e91 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -131,7 +131,7 @@ if ($id > 0 && empty($object->id)) { } } if ($object->id > 0) { - if (!($object->client > 0) || empty($user->rights->societe->lire)) { + if (!($object->client > 0) || !$user->hasRight('societe', 'lire')) { accessforbidden(); } } diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 6267c6ff390..c763bc1a04e 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -104,7 +104,7 @@ class FormContract while ($i < $num) { $obj = $this->db->fetch_object($resql); // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) { + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) { // Do nothing } else { $labeltoshow = dol_trunc($obj->ref, 18); diff --git a/htdocs/core/class/html.formintervention.class.php b/htdocs/core/class/html.formintervention.class.php index 107e9ba378a..751e77eafe1 100644 --- a/htdocs/core/class/html.formintervention.class.php +++ b/htdocs/core/class/html.formintervention.class.php @@ -99,7 +99,7 @@ class FormIntervention while ($i < $num) { $obj = $this->db->fetch_object($resql); // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) { + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) { // Do nothing } else { $labeltoshow = dol_trunc($obj->ref, 18); diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 4d34211ed17..d4c3b1aa21f 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -206,7 +206,7 @@ class FormProjets while ($i < $num) { $obj = $this->db->fetch_object($resql); // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) { + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) { // Do nothing } else { if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) { // We discard closed except if selected diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index f4f1d1be5cd..1c0d7d1aab1 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -421,7 +421,7 @@ function restrictedArea(User $user, $features, $objectid = 0, $tableandshare = ' } if ($feature == 'societe') { - if (empty($user->rights->societe->lire) && empty($user->rights->fournisseur->lire)) { + if (!$user->hasRight('societe', 'lire') && empty($user->rights->fournisseur->lire)) { $readok = 0; $nbko++; } From 236b86bdd3f0a968e8f3d88560212576c7178b76 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:18:31 +0200 Subject: [PATCH 41/69] update code toward php8 compliance --- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/contact/list.php | 4 ++-- htdocs/societe/card.php | 6 +++--- htdocs/societe/list.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 786c3914b92..e417f21832c 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -396,7 +396,7 @@ if (empty($reshook)) { $objectclass = 'Bookkeeping'; $objectlabel = 'Bookkeeping'; $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c2b0120790b..387fc2c06e6 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -313,7 +313,7 @@ if (empty($reshook)) { $objectclass = 'Contact'; $objectlabel = 'Contact'; $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -690,7 +690,7 @@ $arrayofmassactions = array( // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) { +if ($user->hasRight('societe', 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if ($user->rights->societe->creer) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ab3ce495872..4b612df0c00 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -139,7 +139,7 @@ if (!empty($canvas)) { // Permissions $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); +$permissiontodelete = $user->hasRight('societe', 'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0); $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -914,7 +914,7 @@ if (empty($reshook)) { } // Delete third party - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'supprimer')) { $object->fetch($socid); $object->oldcopy = clone $object; $result = $object->delete($socid, $user); @@ -3247,7 +3247,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); - if ($user->rights->societe->supprimer) { + if ($user->hasRight('societe', 'supprimer')) { $deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(); $buttonId = 'action-delete-no-ajax'; if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 6ebd9e3336d..680ab8aff82 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -384,7 +384,7 @@ if (empty($reshook)) { $objectclass = 'Societe'; $objectlabel = 'ThirdParty'; $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -898,7 +898,7 @@ if ($user->rights->societe->creer) { if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); } -if ($user->rights->societe->supprimer) { +if ($user->hasRight('societe', 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From 1b5465d7d0bc76747a906b91d67e623b1b12137d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 10 Sep 2022 11:19:54 +0200 Subject: [PATCH 42/69] update code toward php8 compliance --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/societe/canvas/company/tpl/card_view.tpl.php | 2 +- htdocs/societe/canvas/individual/tpl/card_view.tpl.php | 2 +- htdocs/societe/class/api_thirdparties.class.php | 2 +- htdocs/societe/website.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 36d268a06cf..71e80f703af 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -481,7 +481,7 @@ if (empty($reshook)) { $objectclass = 'Bookkeeping'; $objectlabel = 'Bookkeeping'; $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 48fd3374322..fb9a38ed442 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -263,7 +263,7 @@ for ($i = 1; $i <= 4; $i++) { ">trans("Modify"); ?> -rights->societe->supprimer) { ?> +hasRight('societe', 'supprimer')) { ?> use_javascript_ajax) { ?> trans('Delete'); ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 5ae12a3c501..369ef413fc1 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -190,7 +190,7 @@ if ($this->control->tpl['action_delete']) { ">trans("Modify"); ?> -rights->societe->supprimer) { ?> +hasRight('societe', 'supprimer')) { ?> use_javascript_ajax) { ?> trans('Delete'); ?> diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index db85884c68d..7fe72779c6c 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -527,7 +527,7 @@ class Thirdparties extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->societe->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'supprimer')) { throw new RestException(401); } $result = $this->company->fetch($id); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 5dc25da93a5..9ca58ab0bf4 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -162,7 +162,7 @@ if (empty($reshook)) { $objectclass = 'WebsiteAccount'; $objectlabel = 'WebsiteAccount'; $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $uploaddir = $conf->societe->multidir_output[$object->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } From 2acfa41b1661fda3e49083dc85fef49bdec6d350 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 11 Sep 2022 10:20:51 +0200 Subject: [PATCH 43/69] Update bom_card.php --- htdocs/bom/bom_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 2801b8e3d66..ddb45b6e0bd 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -335,7 +335,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } $text = $langs->trans('ConfirmValidateBom', $numref); - /*if (! empty($conf->notification->enabled)) + /*if (!empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); From 9e0a4988abf0a3839edc931f21a0e2eca4a0cb02 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 11 Sep 2022 10:53:39 +0200 Subject: [PATCH 44/69] Update job_agenda.php --- htdocs/hrm/job_agenda.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/hrm/job_agenda.php b/htdocs/hrm/job_agenda.php index b6ce99c9801..808ceea430f 100644 --- a/htdocs/hrm/job_agenda.php +++ b/htdocs/hrm/job_agenda.php @@ -20,24 +20,24 @@ */ /** - * \file job_agenda.php - * \ingroup hrm - * \brief Tab of events on Job + * \file htdocs/hrm/job_agenda.php + * \ingroup hrm + * \brief Tab of events on Job */ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("hrm", "other")); +$langs->loadLangs(array('hrm', 'other')); // Get parameters $id = GETPOST('id', 'int'); @@ -87,8 +87,9 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; } +// Permissions $permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); From c78c08bf1c139ebe797f5aa1ed64961dd13425cd Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 11 Sep 2022 11:20:54 +0200 Subject: [PATCH 45/69] Update position_document.php --- htdocs/hrm/position_document.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/hrm/position_document.php b/htdocs/hrm/position_document.php index c51f2204441..30f33453c03 100644 --- a/htdocs/hrm/position_document.php +++ b/htdocs/hrm/position_document.php @@ -20,9 +20,9 @@ */ /** - * \file position_document.php - * \ingroup hrm - * \brief Tab for documents linked to Position + * \file htdocs/hrm/position_document.php + * \ingroup hrm + * \brief Tab for documents linked to Position */ // Load Dolibarr environment @@ -39,13 +39,13 @@ require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php'; // Load translation files required by the page $langs->loadLangs(array("hrm", "companies", "other", "mails")); - +// Get parameters $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Get parameters +// Get parameters for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -79,8 +79,9 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->hrm->multidir_output[$object->entity ? $object->entity : $conf->entity]."/position/".get_exdir(0, 0, 0, 1, $object); } +// Permissions $permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); From 97018db06dd15dcb7a7b2729c27d636296cd3a13 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 11 Sep 2022 11:48:30 +0200 Subject: [PATCH 46/69] Update admin_hrm.php --- htdocs/hrm/admin/admin_hrm.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index 6763fb43f8e..dc8d20403a3 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -16,10 +16,12 @@ */ /** - * \file htdocs/hrm/admin/admin_hrm.php - * \ingroup HRM - * \brief HRM module setup page + * \file htdocs/hrm/admin/admin_hrm.php + * \ingroup HRM + * \brief HRM module setup page */ + +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -27,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); +// Get Parameters $action = GETPOST('action', 'aZ09'); // Other parameters HRM_* @@ -34,8 +37,9 @@ $list = array( // 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example ); +// Permissions $permissiontoread = $user->admin; -$permissiontoadd = $user->admin; +$permissiontoadd = $user->admin; // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); From e43a86521a79767ad5d85ae36ba6030200f11fc7 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 11 Sep 2022 11:50:37 +0200 Subject: [PATCH 47/69] Update admin_establishment.php --- htdocs/hrm/admin/admin_establishment.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index f28c0285e1f..00722526e9d 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -16,10 +16,12 @@ */ /** - * \file htdocs/hrm/admin/admin_establishment.php - * \ingroup HRM - * \brief HRM Establishment module setup page + * \file htdocs/hrm/admin/admin_establishment.php + * \ingroup HRM + * \brief HRM Establishment module setup page */ + +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; @@ -29,8 +31,9 @@ $langs->loadLangs(array('admin', 'hrm')); $error = 0; +// Permissions $permissiontoread = $user->admin; -$permissiontoadd = $user->admin; +$permissiontoadd = $user->admin; // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); From e4faf16c564b12899911275eee69b59f85fb865b Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 11 Sep 2022 21:53:25 +0200 Subject: [PATCH 48/69] scrutinizer: multiple attribute errors considered as boolean instead of string[] in if() --- htdocs/public/ticket/create_ticket.php | 4 ++-- htdocs/ticket/class/ticket.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index b4df70e3dd8..e982a4507b8 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -368,7 +368,7 @@ if (empty($reshook)) { } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); - if ($mailfile->error || $mailfile->errors) { + if ($mailfile->error || !empty($mailfile->errors)) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); } else { $result = $mailfile->sendfile(); @@ -409,7 +409,7 @@ if (empty($reshook)) { } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); - if ($mailfile->error || $mailfile->errors) { + if ($mailfile->error || !empty($mailfile->errors)) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); } else { $result = $mailfile->sendfile(); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5306b0c0141..df581d96fdc 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1654,7 +1654,7 @@ class Ticket extends CommonObject $sendtocc = ''; $deliveryreceipt = 0; $mailfile = new CMailFile($subject, $info_sendto['email'], $from, $tmpmessage, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0); - if ($mailfile->error || $mailfile->errors) { + if ($mailfile->error || !empty($mailfile->errors)) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); } else { $result = $mailfile->sendfile(); From 8742e457aa6c2eff9ea6911efb773c52ca38835c Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 11 Sep 2022 22:08:38 +0200 Subject: [PATCH 49/69] scrutinizer on ftp/index.php : type result compared with 'false' --- htdocs/ftp/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 857d41fc85b..74a459328f4 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -709,7 +709,7 @@ print '
'; if (!empty($conn_id)) { $disconnect = dol_ftp_close($conn_id); - if ($disconnect == false) { + if (!$disconnect) { setEventMessages($langs->trans("ErrorFTPNodisconnect"), null, 'errors'); } } From 0ac45a01ffd4dab83cf8b563763b4f8e056030ee Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 11 Sep 2022 22:21:52 +0200 Subject: [PATCH 50/69] scrutinizer on product/stock/stocktransfer/class/stocktransferline.class.php: unset a non-existent var --- .../stock/stocktransfer/class/stocktransferline.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index a5d49dcc3a7..14febad09d4 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -232,7 +232,6 @@ class StockTransferLine extends CommonObjectLine // Reset some properties unset($object->id); - unset($object->fk_user_creat); unset($object->import_key); From da10379090a5365bc63a1620192daa739595e252 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 11 Sep 2022 22:26:02 +0200 Subject: [PATCH 51/69] scrutinizer on product/stock/stocktransfer/class/stocktransferline.class.php: unset a non-existent var --- htdocs/product/stock/stocktransfer/class/stocktransfer.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index d0f27eb46f4..da21a95cdb7 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -140,6 +140,7 @@ class StockTransfer extends CommonObject public $note_private; public $date_creation; public $tms; + public $lead_time_for_warning; public $fk_user_creat; public $fk_user_modif; public $import_key; From 9cdcac7c1c773b51322cf5be19ba645a7ef529a3 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 11 Sep 2022 22:38:51 +0200 Subject: [PATCH 52/69] scrutinizer on product/stock/stocktransfer/class/stocktransfer.class.php: var ref_client undefined on object, so added it and added also ref_customer because ref_client is deprecated --- .../stocktransfer/class/stocktransfer.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index da21a95cdb7..a71098fc2bf 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -57,6 +57,19 @@ class StockTransfer extends CommonObject */ public $isextrafieldmanaged = 1; + /** + * @var string Customer ref + * @deprecated + * @see $ref_customer + */ + public $ref_client; + + /** + * @var string Customer ref + */ + public $ref_customer; + + /** * @var string String with name of icon for stocktransfer. Must be the part after the 'object_' into object_stocktransfer.png */ From f5adbf798365022c225f2ca706f5d0677c85dd47 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 11 Sep 2022 22:57:00 +0200 Subject: [PATCH 53/69] scrutinizer on core/modules/import/import_xlsx.modules.php : array $where not always defined --- htdocs/core/modules/import/import_xlsx.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 6d7c5bf82fd..6b2c02de197 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -876,11 +876,12 @@ class ImportXlsx extends ModeleImports if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) + $where = array(); + if (empty($lastinsertid)) { // No insert done yet for a parent table $sqlSelect = "SELECT ".$fname." FROM " . $tablename; $data = array_combine($listfields, $listvalues); - $where = array(); $filters = array(); foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; @@ -929,6 +930,7 @@ class ImportXlsx extends ModeleImports // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' $sqlSelect = "SELECT rowid FROM " . $tablename; + if (empty($keyfield)) { $keyfield = 'rowid'; } From 472602121d0ea84f232507e776519f794a3496fd Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 12 Sep 2022 09:57:58 +0200 Subject: [PATCH 54/69] Update note.php --- htdocs/fourn/commande/note.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index ee5c0335ce9..167c506b651 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -20,11 +20,12 @@ */ /** - * \file htdocs/fourn/commande/note.php - * \ingroup commande - * \brief Fiche note commande + * \file htdocs/fourn/commande/note.php + * \ingroup commande + * \brief page for notes on supplier orders */ + // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; @@ -36,6 +37,7 @@ if (isModEnabled('project')) { // Load translation files required by the page $langs->loadLangs(array("suppliers", "orders", "companies", "stocks")); +// Get Parameters $id = GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'); $ref = GETPOST('ref'); $action = GETPOST('action', 'aZ09'); @@ -45,12 +47,14 @@ if ($user->socid) { $socid = $user->socid; } +// Init Objects $hookmanager->initHooks(array('ordersuppliercardnote')); $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); $object->fetch($id, $ref); +// Permissions $permissionnote = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); // Used by the include of actions_setnotes.inc.php @@ -70,6 +74,7 @@ if (empty($reshook)) { /* * View */ + $title = $object->ref." - ".$langs->trans('Notes'); $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $title, $help_url); From 4d21d7664422299da1d351fd73bd8a5ba5880206 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:01:47 +0200 Subject: [PATCH 55/69] Update list.php --- htdocs/fourn/commande/list.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4b8c1cffc6d..b08396706d4 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -26,27 +26,30 @@ */ /** - * \file htdocs/fourn/commande/list.php - * \ingroup fournisseur - * \brief List of purchase orders + * \file htdocs/fourn/commande/list.php + * \ingroup fournisseur + * \brief List of purchase orders */ + // Load Dolibarr environment require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +// Load translation files required by the page $langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers', 'products')); +// Get Parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); @@ -54,6 +57,7 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist'; +// Search Criteria $search_date_order_startday = GETPOST('search_date_order_startday', 'int'); $search_date_order_startmonth = GETPOST('search_date_order_startmonth', 'int'); $search_date_order_startyear = GETPOST('search_date_order_startyear', 'int'); @@ -62,6 +66,7 @@ $search_date_order_endmonth = GETPOST('search_date_order_endmonth', 'int'); $search_date_order_endyear = GETPOST('search_date_order_endyear', 'int'); $search_date_order_start = dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear); // Use tzserver $search_date_order_end = dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear); + $search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int'); $search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int'); $search_date_delivery_startyear = GETPOST('search_date_delivery_startyear', 'int'); @@ -79,6 +84,7 @@ $search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int'); $search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int'); $search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver $search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear); + $search_date_approve_startday = GETPOST('search_date_approve_startday', 'int'); $search_date_approve_startmonth = GETPOST('search_date_approve_startmonth', 'int'); $search_date_approve_startyear = GETPOST('search_date_approve_startyear', 'int'); From 32ebee39ff6e38bd25fc13380d3a328f3f7f83b6 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:04:48 +0200 Subject: [PATCH 56/69] Update info.php --- htdocs/fourn/commande/info.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 017818e3e6b..698fead1a43 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -19,17 +19,18 @@ */ /** - * \file htdocs/fourn/commande/info.php - * \ingroup commande - * \brief Fiche commande + * \file htdocs/fourn/commande/info.php + * \ingroup commande + * \brief Info page for Purchase Order / Supplier Order */ + // Load Dolibarr environment require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -37,8 +38,9 @@ if (isModEnabled('project')) { // Load translation files required by the page $langs->loadLangs(array("suppliers", "orders", "companies", "stocks")); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +// Get Paramters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -79,6 +81,7 @@ if (empty($user->rights->fournisseur->commande->lire)) { accessforbidden(); } +// Init Hooks $hookmanager->initHooks(array('ordersuppliercardinfo')); From 0a7d535f342b0678f2570551bdc1b12f638048ac Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:08:04 +0200 Subject: [PATCH 57/69] Update index.php --- htdocs/fourn/commande/index.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 5fc4d46072e..dc30d1296f9 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Vinicius Nogueira - * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2019 Nicolas ZABOURI * * 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 @@ -20,16 +20,22 @@ */ /** - * \file htdocs/fourn/commande/index.php - * \ingroup commande fournisseur - * \brief Home page of supplier's orders area + * \file htdocs/fourn/commande/index.php + * \ingroup commande fournisseur + * \brief Home page of supplier's orders area */ + // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + + +// Load translation files required by the page +$langs->loadLangs(array("suppliers", "orders")); + // Security check $orderid = GETPOST('orderid'); @@ -43,8 +49,6 @@ $hookmanager = new HookManager($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('orderssuppliersindex')); -// Load translation files required by the page -$langs->loadLangs(array("suppliers", "orders")); /* From f47893bfd9c012cbca2f75f5f510cc8a0caa5686 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:12:27 +0200 Subject: [PATCH 58/69] Update card.php --- htdocs/fourn/commande/card.php | 38 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3a0568c8fbe..470525102cc 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -28,22 +28,24 @@ */ /** - * \file htdocs/fourn/commande/card.php - * \ingroup supplier, order - * \brief Card supplier order + * \file htdocs/fourn/commande/card.php + * \ingroup supplier, order + * \brief Card supplier order */ + // Load Dolibarr environment require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + if (isModEnabled('supplier_proposal')) { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; } @@ -60,29 +62,33 @@ if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } + +// Load translation files required by the page $langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'receptions', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch')); if (!empty($conf->incoterm->enabled)) { $langs->load('incoterm'); } + +// Get Parameters $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$socid = GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); -$cancel = GETPOST('cancel', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$origin = GETPOST('origin', 'alpha'); -$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility -$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; +$cancel = GETPOST('cancel', 'alpha'); +$lineid = GETPOST('lineid', 'int'); +$origin = GETPOST('origin', 'alpha'); +$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; -//PDF +// PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); From e1eb25ab457286f937ea26db5dd6117a35a9cf10 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:22:59 +0200 Subject: [PATCH 59/69] Update ChangeLog --- ChangeLog | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a87f3fbc2d..8b4c9cf871d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,14 +53,11 @@ NEW: Add column "Total HT" to products array on document creation card NEW: Add configuration for text color of button action NEW: Add entity filter in exports NEW: Show the event block on recurring invoices #20870 -NEW: Add filter "opportunity status" on statistics of projects. NEW: Add firstname, lastname and max number of attendees for module "Event Organization" NEW: Add margin info in proposal and order list NEW: Add massaction "Edit Extrafield" for Product NEW: Add more fields to detect duplicate during import of thirdparties NEW: Add option to foce delivery on email for purchase order receipt to yes -NEW: Add param border table for md theme -NEW: Add param color button action NEW: Add possibility to create contract from invoice NEW: Add possibility with constant MAIN_LOGIN_BADCHARUNAUTHORIZED to define bad character unauthorized into login name NEW: Add private and public notes on tax files. @@ -70,12 +67,10 @@ NEW: allow cut&paste as real numeric value to excel NEW: A public form to send a message and create a lead is available NEW: automatically set totally received status in reception NEW: Auto set invoice paid when adding credit not and remain to pay is 0 -NEW: Can change value of AWP during the inventory NEW: Can enter price with tax for predefined products on purchase objects NEW: Can filter on a thirdparty on product statistics NEW: Can removed doc templates from setup page of thirdparty NEW: Can use ! to make a search that exclude a string -NEW: Change in theme colors does not need to use the refresh button NEW: clean values and amount in FEC import NEW: const MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND for mailing mass action NEW: Contact filter project list @@ -94,25 +89,26 @@ NEW: JS inventory autocalc input NEW: language support for more emailing target selectors NEW: leave requests: add field into type dictionary to block request if balance is negative NEW: Mass action "Close shipments" -NEW: Module BOM - Add tabs for nets Bom -NEW: Module BOM - Add the possibility to add sub-BOMs to BOM +NEW: Module BOM - add tabs for nets Bom +NEW: Module BOM - add the possibility to add sub-BOMs to BOM NEW: Module Recruitment - Add a public page with list of all open job positions. NEW: Module Recruitment - Add a tab with list of application on the jobposition file. -NEW: More mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) NEW: Add option to move checkbox column as first column on Thirdparty list (only few screens) NEW: payment conditions enabling semi-automatic deposit creation (Issue #18439) NEW: possibility to consume multiple batch NEW: Reverse movement product consumption NEW: Send email to the supplier order contact NEW: add permission to report time on timesheet -NEW: Knowledge Management - Add status "Obsolete" to KM articles +NEW: Knowledge Management - add status "Obsolete" to KM articles NEW: MRP - split consumption line on MO -NEW: MRP - Display physical and virtual stock of the products when creating OF from a BOM -NEW: MRP - Display product ref in "Object link" product tab for BOM +NEW: MRP - display physical and virtual stock of the products when creating OF from a BOM +NEW: MRP - display product ref in "Object link" product tab for BOM +NEW: Projects - add filter "opportunity status" on statistics of projects. NEW: Proposals - option update prices on proposal cloning NEW: SEPA XML - option to place payment Type Info at Credit transfer Transaction level NEW: Stocks - stock filter in reassort lists NEW: Stocks - stock limit in stock export CSV +NEW: Stocks - Inventory - can change value of AWP during the inventory NEW: Supplier order - Show ref supplier of reception in linked object block NEW: support user_modif in order NEW: Surveys - Show number of votes into the label of tab "Results" of a survey @@ -122,6 +118,10 @@ NEW: TakePOS - show product reference NEW: TakePOS - add constant to hide categories NEW: TakePOS - add constant to show category description NEW: TakePOS - add constant to show only the products in stock +NEW: Themes - add param color button action +NEW: Themes - Change in theme colors does not need to use the refresh button +NEW: Themes - more mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) +NEW: Themes - MD - add param border table for md theme NEW: Third-Parties - Add rules "customer accountancy code" is mandatory to validate invoice NEW: Third-Parties - Can set the parent company during the creation of thirdparty (action=add of societe/card.php) NEW: Tickets - create Third-party with contact if not found on public ticket From 9dd96b2a03dcec22bc814581416daab41ab2aea9 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 12 Sep 2022 10:50:59 +0200 Subject: [PATCH 60/69] better fix --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index c70cb16af3c..1a4629d7445 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -149,7 +149,8 @@ UPDATE llx_c_effectif SET code='EF101-500', libelle='101 - 500' WHERE code='EF10 ALTER TABLE llx_rights_def ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; -ALTER TABLE llx_establishment ADD COLUMN label varchar(255) NOT NULL AFTER entity; +UPDATE llx_establishment SET name='' WHERE name IS NULL; +ALTER TABLE llx_establishment CHANGE name label varchar(255) NOT NULL; ALTER TABLE llx_don ADD UNIQUE INDEX idx_don_uk_ref (ref, entity); From dfb7c5ea48566138b4721269e514a61eb27a6af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 12 Sep 2022 14:50:55 +0200 Subject: [PATCH 61/69] clean aurore model --- .../doc/pdf_aurore.modules.php | 78 +++---------------- 1 file changed, 12 insertions(+), 66 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 8ca9a36b0f8..b1129bbb1ed 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -140,10 +140,10 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; $this->format = array($this->page_largeur, $this->page_hauteur); - $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; - $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; - $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; - $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; + $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); + $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); + $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); + $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->option_logo = 1; // Display logo $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION @@ -168,24 +168,18 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->postotalht = 174; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $this->posxtva = 101; - $this->posxup = 118; + $this->posxup = 112; $this->posxqty = 135; $this->posxunit = 151; } else { - $this->posxtva = 102; - $this->posxup = 126; + $this->posxup = 120; $this->posxqty = 145; $this->posxunit = 162; } - if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { - $this->posxup = $this->posxtva; - } - $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxpicture = $this->posxup - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) { // To work with US executive format $this->posxpicture -= 20; - $this->posxtva -= 20; $this->posxup -= 20; $this->posxqty -= 20; $this->posxunit -= 20; @@ -276,7 +270,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } } if (count($realpatharray) == 0) { - $this->posxpicture = $this->posxtva; + $this->posxpicture = $this->posxup; } if ($conf->supplier_proposal->dir_output) { @@ -358,7 +352,6 @@ class pdf_aurore extends ModelePDFSupplierProposal if (empty($this->atleastonediscount)) { $delta = ($this->postotalht - $this->posxdiscount); $this->posxpicture += $delta; - $this->posxtva += $delta; $this->posxup += $delta; $this->posxqty += $delta; $this->posxunit += $delta; @@ -460,7 +453,7 @@ class pdf_aurore extends ModelePDFSupplierProposal if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { $curX = $this->posxpicture - 1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $pdf->Image($realpatharray[$i], $curX + (($this->posxup - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually $posYAfterImage = $curY + $imglinesize['height']; } @@ -472,7 +465,7 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($posYAfterImage > 0) { $descWidth = $this->posxpicture - $curX; } else { - $descWidth = $this->posxtva - $curX; + $descWidth = $this->posxup - $curX; } pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); @@ -528,22 +521,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut - // VAT Rate - /* - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-3, 3, $vat_rate, 0, 'R'); - } - - // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxup, $curY); - if ($up_excl_tax > 0) - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); - */ - // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); @@ -805,7 +782,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $posy = $pdf->GetY() + 1; } - /* PHFAVRE + /* elseif ($object->availability_code || $object->availability) // Show availability conditions { $pdf->SetFont('','B', $default_font_size - 2); @@ -1138,22 +1115,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); - /* - if ($object->close_code == 'discount_vat') - { - $index++; - $pdf->SetFillColor(255,255,255); - - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); - - $resteapayer=0; - } - */ - $index++; $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); @@ -1226,16 +1187,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); - //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height); - if (empty($hidetop)) { - $pdf->SetXY($this->posxtva - 5, $tab_top + 1); - $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); - } - } - - $pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height); + $pdf->line($this->posxup + 1, $tab_top, $this->posxup + 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxup - 1, $tab_top + 1); $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); @@ -1349,12 +1301,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_fourn), 65), '', 'R'); } - /* PHFAVRE - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->delivery_date, "day", false, $outputlangs, true), '', 'R'); - */ if ($object->thirdparty->code_fournisseur) { $posy += 4; From 59e86f4a6ba6a58ae1e2c9a334e707b67a3cc846 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2022 15:16:38 +0200 Subject: [PATCH 62/69] NEW Make module WebservicesClient deprecated. Use module WebHook instead --- htdocs/core/modules/modWebServicesClient.class.php | 2 +- .../modulebuilder/template/core/modules/modMyModule.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index d44d48ef13a..f2b75119523 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -46,7 +46,7 @@ class modWebServicesClient extends DolibarrModules $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Enable the web service client to call external supplier web services"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; + $this->version = 'experimental_deprecated'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 973eb6ba915..169d764b80b 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -71,7 +71,7 @@ class modMyModule extends DolibarrModules $this->editor_name = 'Editor name'; $this->editor_url = 'https://www.example.com'; - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z' $this->version = '1.0'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; From 56c2b8b7758a031b0f5462a03b4088bb89031418 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 12 Sep 2022 15:12:36 +0200 Subject: [PATCH 63/69] Product: display TTC price on price card --- htdocs/product/price.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 787cc034f68..d6d64ecf347 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1193,7 +1193,11 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { print price($object->price).' '.$langs->trans($object->price_base_type); + if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_ttc)) { + print ' - ' . price($object->price_ttc).' '.$langs->trans('TTC') . ''; + } } + print ''; // Price minimum @@ -1202,7 +1206,11 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { print price($object->price_min).' '.$langs->trans($object->price_base_type); + if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_min_ttc)) { + print ' - ' . price($object->price_min_ttc).' '.$langs->trans('TTC') . ''; + } } + print ''; // Price by quantity From 3d88e8cc0ecf47a301c48ceeab7a28474640c828 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 12 Sep 2022 15:14:01 +0200 Subject: [PATCH 64/69] add tr ids --- htdocs/product/price.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index d6d64ecf347..f0bdf563546 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1188,7 +1188,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print ''; // Price - print '
'; // Price minimum - print ''; if ($num == 0) { - print ''; + print ''; } else { while ($obj = $db->fetch_object($resql)) { $user = new User($db); From 7485188b49562607504827bbe92bb504d1873ede Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Sep 2022 01:11:09 +0200 Subject: [PATCH 68/69] Update price.php --- htdocs/product/price.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index f0bdf563546..aa9a34336b0 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1188,7 +1188,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print ''; // Price - print ''; // Price minimum - print '
'; + print $langs->trans("MemberCountersArePublic"); + print ''; + print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (!empty($conf->global->MEMBER_COUNTERS_ARE_PUBLIC) ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1); + print "
'; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index e4ca610c44f..aebe3affdae 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -15,6 +15,7 @@ ErrorMemberIsAlreadyLinkedToThisThirdParty=Another member (name: %s, logi ErrorUserPermissionAllowsToLinksToItselfOnly=For security reasons, you must be granted permissions to edit all users to be able to link a member to a user that is not yours. SetLinkToUser=Link to a Dolibarr user SetLinkToThirdParty=Link to a Dolibarr third party +MemberCountersArePublic=Counters of valid members are public MembersCards=Generation of cards for members MembersList=List of members MembersListToValid=List of draft members (to be validated) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index c409703862c..531bfcfd152 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -753,10 +753,14 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW foreach ($measuringUnits->records as $lines) $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy"; + $publiccounters = $conf->global->MEMBER_COUNTERS_ARE_PUBLIC; + + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy, COUNT(a.rowid) AS membercount"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a"; + $sql .= " ON d.rowid = a.fk_adherent_type AND a.statut>0"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; - $sql .= " AND d.statut=1"; + $sql .= " AND d.statut=1 GROUP BY d.rowid"; $result = $db->query($sql); if ($result) { @@ -772,6 +776,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("Members").''.$langs->trans("NewSubscription").'
'.yn($objp->vote).''.$membercount.'
'; print $langs->trans("MemberCountersArePublic"); print ''; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 531bfcfd152..25ad932456a 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -776,7 +776,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("Members").''.$langs->trans("Members").''.$langs->trans("NewSubscription").'
'.yn($objp->vote).''.$membercount.''.$membercount.'
'.$langs->trans("St if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) { $thirdpartygraph .= '
'; $dataseries = array(); - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { $dataseries[] = array($langs->trans("Prospects"), round($third['prospect'])); } - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); } if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { @@ -173,12 +173,12 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + $thirdpartygraph .= $dolgraph->show(); $thirdpartygraph .= '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("SellingPrice").''; + print '
'.$langs->trans("SellingPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { @@ -1201,7 +1201,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '
'.$langs->trans("MinPrice").''; + print '
'.$langs->trans("MinPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { From 209bf00b69e3d734a7f7007f3c06f48531e790c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Sep 2022 00:11:00 +0200 Subject: [PATCH 65/69] Trans --- htdocs/commande/class/commande.class.php | 5 ++++- htdocs/langs/en_US/admin.lang | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 301bbe761be..8b0967c64b6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3662,7 +3662,10 @@ class Commande extends CommonOrder } elseif ($status == self::STATUS_SHIPMENTONPROCESS) { $labelStatus = $langs->transnoentitiesnoconv('StatusOrderSent').$billedtext; $labelStatusShort = $langs->transnoentitiesnoconv('StatusOrderSentShort').$billedtext; - $labelTooltip = $langs->transnoentitiesnoconv("StatusOrderSent").' - '.$langs->transnoentitiesnoconv("DateDeliveryPlanned").dol_print_date($this->date_livraison).$billedtext; + $labelTooltip = $langs->transnoentitiesnoconv("StatusOrderSent"); + if (!empty($this->delivery_date)) { + $labelTooltip .= ' - '.$langs->transnoentitiesnoconv("DateDeliveryPlanned").dol_print_date($this->delivery_date, 'day').$billedtext; + } $statusType = 'status4'; } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->transnoentitiesnoconv('StatusOrderToBill'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d3b2f251a6c..46af4f95355 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2310,4 +2310,6 @@ Images=Images MaxNumberOfImagesInGetPost=Max number of images allowed in a HTML field submitted in a form ScriptIsEmpty=The script is empty ShowHideTheNRequests=Show/hide the %s SQL request(s) -DefinedAPathForAntivirusCommandIntoSetup=Define a path for an antivirus program into %s \ No newline at end of file +DefinedAPathForAntivirusCommandIntoSetup=Define a path for an antivirus program into %s +TriggerCodes=Triggerable events +TriggerCodeInfo=Enter here the list of trigger codes that must generate a post of a web request \ No newline at end of file From f10338293513b75cecb02d97977945881ead18bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Sep 2022 00:16:38 +0200 Subject: [PATCH 66/69] Debug webhook --- .../triggers/interface_95_modWebhook_WebhookTriggers.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php b/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php index a8932934bd1..94b4b861e86 100644 --- a/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php +++ b/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php @@ -104,7 +104,7 @@ class InterfaceWebhookTriggers extends DolibarrTriggers $actionarray = explode(",", $tmpobject->trigger_codes); if (is_array($actionarray) && in_array($action, $actionarray)) { $jsonstr = '{"triggercode":'.json_encode($action).',"object":'.json_encode($object).'}'; - $response = getURLContent($tmpobject->url, 'POST', $jsonstr); + $response = getURLContent($tmpobject->url, 'POST', $jsonstr, 1, array(), array('http', 'https'), 0, -1); if (empty($response['curl_error_no']) && $response['http_code'] >= 200 && $response['http_code'] < 300) { $nbPosts ++; } else { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 46af4f95355..704d9ed238e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2312,4 +2312,4 @@ ScriptIsEmpty=The script is empty ShowHideTheNRequests=Show/hide the %s SQL request(s) DefinedAPathForAntivirusCommandIntoSetup=Define a path for an antivirus program into %s TriggerCodes=Triggerable events -TriggerCodeInfo=Enter here the list of trigger codes that must generate a post of a web request \ No newline at end of file +TriggerCodeInfo=Enter here the trigger code(s) that must generate a post of a web request (only external URL are allowed). You can enter several trigger codes separated by a comma. From 39b89143cc3ac63a7e7a67626187bfb7aadd9686 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Sep 2022 00:52:11 +0200 Subject: [PATCH 67/69] Fix colspan --- htdocs/holiday/month_report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index a3b8171cc62..735f8892129 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -335,7 +335,7 @@ print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', print '
'.$langs->trans('None').'
'.$langs->trans('None').'
'.$langs->trans("SellingPrice").''; + print '
'.$langs->trans("SellingPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { @@ -1201,7 +1201,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '
'.$langs->trans("MinPrice").''; + print '
'.$langs->trans("MinPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { From d911f13ca001ffa85ef831d843bf400a2e586659 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Sep 2022 01:40:37 +0200 Subject: [PATCH 69/69] Update ajax.php --- htdocs/bom/ajax/ajax.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index 444ce9beeb2..9a55c609252 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -33,20 +33,9 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} -// Do not check anti CSRF attack test if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } -// If there is no need to load and show top and left menu -if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); -} -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); }