diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c685645c504..f4cb62f0a13 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -16,6 +16,7 @@ jobs: if: false # The next uses the git API because there is no clone yet. + # It sets the variable steps.changed-php.outputs.all_changed_files for other steps # This is faster for a big repo. - name: Get all changed php files (if PR) id: changed-php diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95f2b455877..17c31a96e6b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -125,7 +125,7 @@ repos: # Only for translations with specialised exceptions # -D contains predefined conversion dictionaries # -L is to ignore some words - id: codespell + id: codespell-lang-en_US files: ^htdocs/langs/en_US/.*$ args: - -D diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 6f7d2e081ca..c488758008e 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -50,8 +50,7 @@ class Bookmark extends CommonObject public $picto = 'bookmark'; /** - * Last error code on a local method - * @var int Error number + * @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */ public $errno; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 0276aefc19f..54cd804d72e 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -159,7 +159,7 @@ if (empty($reshook)) { } $fk_accountancy_journal = GETPOSTINT('fk_accountancy_journal'); if ($fk_accountancy_journal <= 0) { - $object->fk_accountancy_journal = ''; + $object->fk_accountancy_journal = 0; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } @@ -272,7 +272,7 @@ if (empty($reshook)) { } $fk_accountancy_journal = GETPOSTINT('fk_accountancy_journal'); if ($fk_accountancy_journal <= 0) { - $object->fk_accountancy_journal = ''; + $object->fk_accountancy_journal = 0; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index eb3a17ffebf..5db1a837a01 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -134,19 +134,19 @@ if (empty($reshook)) { // Ajout entrepot if ($action == 'add' && $user->hasRight('stock', 'creer')) { - $object->ref = (string) GETPOST("ref", "alpha"); - $object->fk_parent = (int) GETPOST("fk_parent", "int"); - $object->fk_project = GETPOST('projectid', 'int'); - $object->label = (string) GETPOST("libelle", "alpha"); - $object->description = (string) GETPOST("desc", "alpha"); - $object->statut = GETPOST("statut", "int"); - $object->lieu = (string) GETPOST("lieu", "alpha"); - $object->address = (string) GETPOST("address", "alpha"); - $object->zip = (string) GETPOST("zipcode", "alpha"); - $object->town = (string) GETPOST("town", "alpha"); - $object->country_id = GETPOST("country_id"); - $object->phone = (string) GETPOST("phone", "alpha"); - $object->fax = (string) GETPOST("fax", "alpha"); + $object->ref = (string) GETPOST("ref", "alpha"); + $object->fk_parent = GETPOSTINT("fk_parent"); + $object->fk_project = GETPOSTINT('projectid'); + $object->label = (string) GETPOST("libelle", "alpha"); + $object->description = (string) GETPOST("desc", "alpha"); + $object->statut = GETPOSTINT("statut"); + $object->lieu = (string) GETPOST("lieu", "alpha"); + $object->address = (string) GETPOST("address", "alpha"); + $object->zip = (string) GETPOST("zipcode", "alpha"); + $object->town = (string) GETPOST("town", "alpha"); + $object->country_id = GETPOSTINT("country_id"); + $object->phone = (string) GETPOST("phone", "alpha"); + $object->fax = (string) GETPOST("fax", "alpha"); if (!empty($object->label)) { // Fill array 'array_options' with data from add form diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index a7a44ed2861..74ab3a085de 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -207,23 +207,23 @@ if (empty($reshook)) { $db->begin(); - $object->ref = GETPOST('ref', 'alphanohtml'); - $object->fk_project = GETPOST('fk_project', 'int'); - $object->title = GETPOST('title', 'alphanohtml'); - $object->socid = GETPOST('socid', 'int'); - $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is - $object->public = GETPOST('public', 'alphanohtml'); - $object->opp_amount = price2num(GETPOST('opp_amount', 'alphanohtml')); - $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml')); - $object->date_c = dol_now(); - $object->date_start = $date_start; - $object->date_end = $date_end; - $object->date_start_event = $date_start_event; - $object->date_end_event = $date_end_event; - $object->location = $location; - $object->statut = $status; - $object->opp_status = $opp_status; - $object->opp_percent = $opp_percent; + $object->ref = GETPOST('ref', 'alphanohtml'); + $object->fk_project = GETPOSTINT('fk_project'); + $object->title = GETPOST('title', 'alphanohtml'); + $object->socid = GETPOST('socid', 'int'); + $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is + $object->public = GETPOST('public', 'alphanohtml'); + $object->opp_amount = GETPOSTFLOAT('opp_amount'); + $object->budget_amount = GETPOSTFLOAT('budget_amount'); + $object->date_c = dol_now(); + $object->date_start = $date_start; + $object->date_end = $date_end; + $object->date_start_event = $date_start_event; + $object->date_end_event = $date_end_event; + $object->location = $location; + $object->statut = $status; + $object->opp_status = $opp_status; + $object->opp_percent = $opp_percent; $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index aea5abea6d9..46e41cb5680 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -283,16 +283,23 @@ class ProductCombination /** * Retrieves all product combinations by the product parent row id * - * @param int $fk_product_parent Rowid of parent product - * @return int|ProductCombination[] Return integer <0 KO + * @param int $fk_product_parent Rowid of parent product + * @param bool $sort_by_ref Sort result by product child reference + * @return int|ProductCombination[] Return integer <0 KO */ - public function fetchAllByFkProductParent($fk_product_parent) + public function fetchAllByFkProductParent($fk_product_parent, $sort_by_ref = false) { global $conf; - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_ref_ext, variation_weight"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_attribute_combination"; - $sql.= " WHERE fk_product_parent = ".((int) $fk_product_parent)." AND entity IN (".getEntity('product').")"; + $sql = "SELECT pac.rowid, pac.fk_product_parent, pac.fk_product_child, pac.variation_price, pac.variation_price_percentage, pac.variation_ref_ext, pac.variation_weight"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_attribute_combination AS pac"; + if ($sort_by_ref) { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = pac.fk_product_child"; + } + $sql.= " WHERE pac.fk_product_parent = ".((int) $fk_product_parent)." AND pac.entity IN (".getEntity('product').")"; + if ($sort_by_ref) { + $sql.= $this->db->order('p.ref', 'ASC'); + } $query = $this->db->query($sql); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 1ebbd5652a5..61f8822836c 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -341,7 +341,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( // Reload variants -$productCombinations = $prodcomb->fetchAllByFkProductParent($object->id); +$productCombinations = $prodcomb->fetchAllByFkProductParent($object->id, true); if ($action === 'confirm_deletecombination') { if ($prodcomb->fetch($valueid) > 0) {