From f4e63bb0462fde1cc339f1ebd81d61ba6af211b9 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 10:52:22 +0100 Subject: [PATCH 01/10] NEW: ref in product customer price: add fields in database --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_product_customer_price.sql | 3 ++- htdocs/install/mysql/tables/llx_product_customer_price_log.sql | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index a73ca40d86f..0a3b9379cbf 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -423,6 +423,9 @@ ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL; ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code); +ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); +ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); + -- MIGRATION TO DO AFTER RENAMING AN OBJECT -- drop constraint diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.sql b/htdocs/install/mysql/tables/llx_product_customer_price.sql index 7cd481c3c75..f0d5edf9c2f 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price.sql @@ -27,7 +27,8 @@ create table llx_product_customer_price datec datetime, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_product integer NOT NULL, - fk_soc integer NOT NULL, + fk_soc integer NOT NULL, + ref_customer varchar(30), price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql index 4d79353e884..29906fe7ff2 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql @@ -26,7 +26,8 @@ create table llx_product_customer_price_log entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, fk_product integer NOT NULL, - fk_soc integer DEFAULT 0 NOT NULL, + fk_soc integer DEFAULT 0 NOT NULL, + ref_customer varchar(30), price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, From 721e931ba7119817694b77f36bd3388430f239c2 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 11:04:06 +0100 Subject: [PATCH 02/10] NEW: ref in product customer price: add field in CRUD class --- .../class/productcustomerprice.class.php | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 25a3c5cd836..49386e8a379 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -54,7 +54,12 @@ class Productcustomerprice extends CommonObject /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; + + /** + * @var string Customer reference + */ + public $ref_customer; public $price; public $price_ttc; @@ -107,7 +112,9 @@ class Productcustomerprice extends CommonObject if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); if (isset($this->fk_soc)) - $this->fk_soc = trim($this->fk_soc); + $this->fk_soc = trim($this->fk_soc); + if (isset($this->ref_customer)) + $this->ref_customer = trim($this->ref_customer); if (isset($this->price)) $this->price = trim($this->price); if (isset($this->price_ttc)) @@ -171,6 +178,7 @@ class Productcustomerprice extends CommonObject $sql .= "datec,"; $sql .= "fk_product,"; $sql .= "fk_soc,"; + $sql .= 'ref_customer,'; $sql .= "price,"; $sql .= "price_ttc,"; $sql .= "price_min,"; @@ -190,6 +198,7 @@ class Productcustomerprice extends CommonObject $sql .= " '".$this->db->idate(dol_now())."',"; $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").","; $sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").","; + $sql .= " ".(!isset($this->ref_customer) ? 'NULL' : "'".$this->db->escape($this->ref_customer)."'").","; $sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").","; $sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").","; $sql .= " ".(empty($this->price_min) ? '0' : "'".$this->db->escape($this->price_min)."'").","; @@ -257,6 +266,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.tms,"; $sql .= " t.fk_product,"; $sql .= " t.fk_soc,"; + $sql .= " t.ref_customer,"; $sql .= " t.price,"; $sql .= " t.price_ttc,"; $sql .= " t.price_min,"; @@ -286,6 +296,7 @@ class Productcustomerprice extends CommonObject $this->tms = $this->db->jdate($obj->tms); $this->fk_product = $obj->fk_product; $this->fk_soc = $obj->fk_soc; + $this->ref_customer = $obj->ref_customer; $this->price = $obj->price; $this->price_ttc = $obj->price_ttc; $this->price_min = $obj->price_min; @@ -334,6 +345,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.tms,"; $sql .= " t.fk_product,"; $sql .= " t.fk_soc,"; + $sql .= " t.ref_customer,"; $sql .= " t.price,"; $sql .= " t.price_ttc,"; $sql .= " t.price_min,"; @@ -393,6 +405,7 @@ class Productcustomerprice extends CommonObject $line->tms = $this->db->jdate($obj->tms); $line->fk_product = $obj->fk_product; $line->fk_soc = $obj->fk_soc; + $line->ref_customer = $obj->ref_customer; $line->price = $obj->price; $line->price_ttc = $obj->price_ttc; $line->price_min = $obj->price_min; @@ -447,6 +460,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.datec,"; $sql .= " t.fk_product,"; $sql .= " t.fk_soc,"; + $sql .= " t.ref_customer,"; $sql .= " t.price,"; $sql .= " t.price_ttc,"; $sql .= " t.price_min,"; @@ -502,6 +516,7 @@ class Productcustomerprice extends CommonObject $line->tms = $this->db->jdate($obj->tms); $line->fk_product = $obj->fk_product; $line->fk_soc = $obj->fk_soc; + $line->ref_customer = $obj->ref_customer; $line->price = $obj->price; $line->price_ttc = $obj->price_ttc; $line->price_min = $obj->price_min; @@ -549,7 +564,9 @@ class Productcustomerprice extends CommonObject if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); if (isset($this->fk_soc)) - $this->fk_soc = trim($this->fk_soc); + $this->fk_soc = trim($this->fk_soc); + if (isset($this->ref_customer)) + $this->ref_customer = trim($this->ref_customer); if (isset($this->price)) $this->price = trim($this->price); if (isset($this->price_ttc)) @@ -615,6 +632,7 @@ class Productcustomerprice extends CommonObject $sql .= "datec,"; $sql .= "fk_product,"; $sql .= "fk_soc,"; + $sql .= "ref_customer,"; $sql .= "price,"; $sql .= "price_ttc,"; $sql .= "price_min,"; @@ -637,6 +655,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.datec,"; $sql .= " t.fk_product,"; $sql .= " t.fk_soc,"; + $sql .= " t.ref_customer,"; $sql .= " t.price,"; $sql .= " t.price_ttc,"; $sql .= " t.price_min,"; @@ -671,6 +690,7 @@ class Productcustomerprice extends CommonObject $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").","; + $sql .= " ref_customer=".(isset($this->ref_customer) ? $this->ref_customer : "null").","; $sql .= " price=".(isset($this->price) ? $this->price : "null").","; $sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").","; $sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").","; @@ -790,6 +810,7 @@ class Productcustomerprice extends CommonObject // If line do not exits then create it $prodsocpricenew = new Productcustomerprice($this->db); $prodsocpricenew->fk_soc = $obj->rowid; + $prodsocpricenew->ref_customer = $obj->ref_customer; $prodsocpricenew->fk_product = $this->fk_product; $prodsocpricenew->price = $this->price; $prodsocpricenew->price_min = $this->price_min; @@ -924,6 +945,7 @@ class Productcustomerprice extends CommonObject $this->tms = ''; $this->fk_product = ''; $this->fk_soc = ''; + $this->ref_customer = ''; $this->price = ''; $this->price_ttc = ''; $this->price_min = ''; @@ -962,6 +984,11 @@ class PriceByCustomerLine */ public $fk_product; + /** + * @var string Customer reference + */ + public $ref_customer; + /** * @var int Thirdparty ID */ From 6a3150028c74851ce256bb8fc8546cac1e2530e9 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 11:47:01 +0100 Subject: [PATCH 03/10] NEW: ref in product customer price: fix price update SQL --- htdocs/product/class/productcustomerprice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 49386e8a379..c18d09614e6 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -690,7 +690,7 @@ class Productcustomerprice extends CommonObject $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").","; - $sql .= " ref_customer=".(isset($this->ref_customer) ? $this->ref_customer : "null").","; + $sql .= " ref_customer=".(isset($this->ref_customer) ? "'" . $this->db->escape($this->ref_customer) . "'" : "null").","; $sql .= " price=".(isset($this->price) ? $this->price : "null").","; $sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").","; $sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").","; From c2518e92fbb26ce077cb33500965b6cc77528ea8 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 11:50:04 +0100 Subject: [PATCH 04/10] NEW: ref in product customer price: add field in views --- htdocs/product/price.php | 9 ++++++--- htdocs/societe/price.php | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 8d10535ae31..2444fe6468d 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1854,6 +1854,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''.$langs->trans("ThirdParty").''; + print ''.$langs->trans('RefCustomer').''; print ''.$langs->trans("AppliedPricesFrom").''; print ''.$langs->trans("PriceBase").''; print ''.$langs->trans("DefaultTaxRate").''; @@ -1901,6 +1902,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print "".$staticsoc->getNomUrl(1).""; + print '' . $line->ref_customer . ''; print "".dol_print_date($line->datec, "dayhour").""; print ''.$langs->trans($line->price_base_type).""; print ''; @@ -1969,7 +1971,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if (count($prodcustprice->lines) > 0 || $search_soc) { - $colspan = 8; + $colspan = 9; //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; print ''; @@ -1985,6 +1987,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''.$langs->trans("ThirdParty").''; + print '' . $langs->trans('RefCustomer') . ''; print ''.$langs->trans("AppliedPricesFrom").''; print ''.$langs->trans("PriceBase").''; print ''.$langs->trans("DefaultTaxRate").''; @@ -2023,8 +2026,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $total_ttc = $resultarray[2]; print ''; - print "".$langs->trans("Default").""; - print ""; + print '' . $langs->trans('Default') . ''; print ''.$langs->trans($object->price_base_type).""; print ''; @@ -2102,6 +2104,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print "".$staticsoc->getNomUrl(1).""; + print '' . $line->ref_customer . ''; print "".dol_print_date($line->datec, "dayhour").""; print ''.$langs->trans($line->price_base_type).""; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 8a65b56b2bf..2275ab251f7 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -461,6 +461,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''.$langs->trans("Product").''; + print '' . $langs->trans('RefCustomer') . ''; print ''.$langs->trans("AppliedPricesFrom").''; print ''.$langs->trans("PriceBase").''; print ''.$langs->trans("VAT").''; @@ -478,6 +479,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $staticprod->fetch($line->fk_product); print "".$staticprod->getNomUrl(1).""; + print '' . $line->ref_customer . ''; print "".dol_print_date($line->datec, "dayhour").""; print ''.$langs->trans($line->price_base_type).""; @@ -547,6 +549,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print '' . $langs->trans("Ref") . ''; print '' . $langs->trans("Product") . ''; + print '' . $langs->trans('RefCustomer') . ''; print ''.$langs->trans("AppliedPricesFrom").''; print ''.$langs->trans("PriceBase").''; print ''.$langs->trans("VAT").''; @@ -563,7 +566,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; - print ' '; + print ' '; print ''; print ''; print ' '; @@ -586,6 +589,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "".$staticprod->getNomUrl(1).""; print "" . $staticprod->label .""; + print '' . $line->ref_customer .''; print "".dol_print_date($line->datec, "dayhour").""; print ''.$langs->trans($line->price_base_type).""; @@ -623,7 +627,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "\n"; } } else { - $colspan = 9; + $colspan = 10; if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1; print ''.$langs->trans('None').''; } From 496c31d63ab611e5b67278643823326d0b0f5258 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 12:18:24 +0100 Subject: [PATCH 05/10] NEW: ref in product customer price: add field in forms and form handlers --- htdocs/product/price.php | 10 ++++++++++ htdocs/societe/price.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2444fe6468d..a150402cfde 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -499,6 +499,7 @@ if (empty($reshook)) // add price by customer $prodcustprice->fk_soc = GETPOST('socid', 'int'); + $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); $prodcustprice->fk_product = $object->id; $prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); @@ -600,6 +601,7 @@ if (empty($reshook)) $prodcustprice->fetch(GETPOST('lineid', 'int')); // update price by customer + $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); $prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); @@ -1662,6 +1664,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''; + // Ref. Customer + print '' . $langs->trans('RefCustomer') . ''; + print ''; + // VAT print ''.$langs->trans("DefaultTaxRate").''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); @@ -1748,6 +1754,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "".$staticsoc->getNomUrl(1).""; print ''; + // Ref. Customer + print '' . $langs->trans('RefCustomer') . ''; + print ''; + // VAT print ''.$langs->trans("DefaultTaxRate").''; print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly, $object->type, false, 1); diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 2275ab251f7..6d1d08b17b5 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -88,6 +88,7 @@ if (empty($reshook)) // add price by customer $prodcustprice->fk_soc = $socid; + $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); $prodcustprice->fk_product = GETPOST('prodid', 'int'); $prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); @@ -162,6 +163,7 @@ if (empty($reshook)) $update_child_soc = GETPOST('updatechildprice'); // update price by customer + $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); $prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); @@ -294,6 +296,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; + // Ref. Customer + print '' . $langs->trans('RefCustomer') . ''; + print ''; + // VAT print ''.$langs->trans("VATRate").''; print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1); @@ -372,6 +378,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "".$staticprod->getNomUrl(1).""; print ''; + // Ref. Customer + print '' . $langs->trans('RefCustomer') . ''; + print ''; + // VAT print ''.$langs->trans("VATRate").''; print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); From bb850ad0d083e8cc76eeb997acd29dc8779cab31 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 13:05:07 +0100 Subject: [PATCH 06/10] NEW: ref in product customer price: add ref in PDFs + hidden conf to choose refs to show --- htdocs/core/lib/pdf.lib.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0ff40659daa..9889e3ff220 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1237,6 +1237,10 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } else { include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $prodser = new Product($db); + + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + } } if ($idprod) @@ -1364,6 +1368,32 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } } else { $ref_prodserv = $prodser->ref; // Show local ref only + + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + $productCustomerPriceStatic = new Productcustomerprice($db); + $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid); + + $nbCustomerPrices = $productCustomerPriceStatic->fetch_all('', '', 1, 0, $filter); + + if ($nbCustomerPrices > 0) { + $productCustomerPrice = $productCustomerPriceStatic->lines[0]; + + if (! empty($productCustomerPrice->ref_customer)) { + switch($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) { + case 1: + $ref_prodserv = $productCustomerPrice->ref_customer; + break; + + case 2: + $ref_prodserv = $productCustomerPrice->ref_customer . ' (' . $outputlangs->transnoentitiesnoconv('InternalRef') . ' ' . $ref_prodserv . ')'; + break; + + default: + $ref_prodserv = $ref_prodserv . ' (' . $outputlangs->transnoentitiesnoconv('RefCustomer') . ' ' . $productCustomerPrice->ref_customer . ')'; + } + } + } + } } if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - "; From 79ba133a07d5f691fac0ef00f94af5559ac233aa Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 26 Oct 2020 13:05:26 +0100 Subject: [PATCH 07/10] NEW: ref in product customer price: fix missing language key --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1096b9857f1..84d399ddde2 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -646,6 +646,7 @@ SupplierPreview=Vendor preview ShowCustomerPreview=Show customer preview ShowSupplierPreview=Show vendor preview RefCustomer=Ref. customer +InternalRef=Internal ref. Currency=Currency InfoAdmin=Information for administrators Undo=Undo From 541dab57371e5b8517bc77f527262bc777b178ea Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 26 Oct 2020 13:40:05 +0000 Subject: [PATCH 08/10] Fixing style errors. --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 9889e3ff220..6d0b3023964 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1379,7 +1379,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $productCustomerPrice = $productCustomerPriceStatic->lines[0]; if (! empty($productCustomerPrice->ref_customer)) { - switch($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) { + switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) { case 1: $ref_prodserv = $productCustomerPrice->ref_customer; break; From ca2ed2ef74d94d7808154ee8e41cf0f4ec290891 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Wed, 28 Oct 2020 11:04:15 +0100 Subject: [PATCH 09/10] NEW: ref in product customer price: look for products with customer ref --- htdocs/core/class/html.form.class.php | 10 +++++++--- htdocs/core/lib/ajax.lib.php | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bf52ff5871a..59f98e626a9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2137,8 +2137,8 @@ class Form if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { $sql .= ', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,'; - $sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; - $selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; + $sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx, pcp.ref_customer as custref'; + $selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custref"; } // Units if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -2235,6 +2235,7 @@ class Form if ($i > 0) $sql .= " AND "; $sql .= "(p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'"; if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) $sql .= " OR pcp.ref_customer LIKE '".$this->db->escape($prefix.$crit)."%'"; if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) { $sql .= " OR p.description LIKE '".$this->db->escape($prefix.$crit)."%'"; @@ -2422,6 +2423,7 @@ class Form $outkey = $objp->rowid; $outref = $objp->ref; + $outrefcust = empty($objp->custref) ? '' : $objp->custref; $outlabel = $objp->label; $outdesc = $objp->description; $outbarcode = $objp->barcode; @@ -2487,11 +2489,13 @@ class Form } $opt .= '>'; $opt .= $objp->ref; + if (! empty($objp->custref)) $opt.= ' (' . $objp->custref . ')'; if ($outbarcode) $opt .= ' ('.$outbarcode.')'; $opt .= ' - '.dol_trunc($label, $maxlengtharticle); if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $opt .= ' ('.getCountry($outorigin, 1).')'; $objRef = $objp->ref; + if (! empty($objp->custref)) $objRef .= ' (' . $objp->custref . ')'; if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $objRef, 1); $outval .= $objRef; if ($outbarcode) $outval .= ' ('.$outbarcode.')'; @@ -2655,7 +2659,7 @@ class Form } $opt .= "\n"; - $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); + $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq, 'ref_customer'=>$outrefcust); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 10fa477600a..0c7a8ecc312 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -134,7 +134,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen } return { label: label, value: item.value, id: item.key, disabled: item.disabled, update: update, textarea: textarea, - pbq: item.pbq, type: item.type, qty: item.qty, discount: item.discount, pricebasetype: item.pricebasetype, price_ht: item.price_ht, price_ttc: item.price_ttc } + pbq: item.pbq, type: item.type, qty: item.qty, discount: item.discount, pricebasetype: item.pricebasetype, price_ht: item.price_ht, price_ttc: item.price_ttc, ref_customer: item.ref_customer } })); } else console.error("Error: Ajax url '.$url.($urloption ? '?'.$urloption : '').' has returned an empty page. Should be an empty json array."); @@ -152,6 +152,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen $("#'.$htmlname.'").attr("data-pbqbase", ui.item.pricebasetype); $("#'.$htmlname.'").attr("data-pbqqty", ui.item.qty); $("#'.$htmlname.'").attr("data-pbqpercent", ui.item.discount); + $("#'.$htmlname.'").attr("data-ref-customer", ui.item.ref_customer); $("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value // Disable an element From 759dd379d305c20f16cb632623a60b0c6fddbf87 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 12 Jan 2021 14:43:09 +0100 Subject: [PATCH 10/10] NEW: customer price customer ref: push back to v14 --- .../install/mysql/migration/12.0.0-13.0.0.sql | 4 - .../mysql/migration/12.0.0-13.0.0.sql.orig | 568 ++++++++++++++++++ .../install/mysql/migration/13.0.0-14.0.0.sql | 5 + 3 files changed, 573 insertions(+), 4 deletions(-) create mode 100644 htdocs/install/mysql/migration/12.0.0-13.0.0.sql.orig diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 6ba87f9fd25..26ec6377cc3 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -444,10 +444,6 @@ INSERT INTO llx_c_product_nature (code, label, active) VALUES (1, 'Finished', 1) ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL; ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code); - -ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); -ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); - -- MIGRATION TO DO AFTER RENAMING AN OBJECT -- drop constraint diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql.orig b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql.orig new file mode 100644 index 00000000000..e9798083ea6 --- /dev/null +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql.orig @@ -0,0 +1,568 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 13.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + + +-- Missing in v12 or lower + +ALTER TABLE llx_payment_salary MODIFY COLUMN ref varchar(30) NULL; +ALTER TABLE llx_payment_various MODIFY COLUMN ref varchar(30) NULL; + +ALTER TABLE llx_prelevement_bons ADD COLUMN type varchar(16) DEFAULT 'debit-order'; + +ALTER TABLE llx_prelevement_facture CHANGE COLUMN fk_facture_foun fk_facture_fourn integer NULL; + +ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture (fk_facture); +ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture_fourn (fk_facture_fourn); + +ALTER TABLE llx_document_model MODIFY COLUMN type varchar(64); + +ALTER TABLE llx_bom_bom MODIFY COLUMN duration double(24,8); + +ALTER TABLE llx_bom_bom_extrafields ADD INDEX idx_bom_bom_extrafields_fk_object (fk_object); + +create table llx_mrp_mo_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_mrp_mo_extrafields DROP INDEX idx_fk_object; + +ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_mrp_mo_fk_object(fk_object); + + +-- For v13 +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (111,11, '0','0','No Sales Tax',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (112,11, '4','0','Sales Tax 4%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (113,11, '6','0','Sales Tax 6%',1); + +ALTER TABLE llx_bom_bom ADD COLUMN bomtype integer DEFAULT 0; + +UPDATE llx_emailcollector_emailcollector SET ref = 'Collect_Ticket_Requests' WHERE ref = 'Collect_Ticket_Requets'; +UPDATE llx_emailcollector_emailcollector SET ref = 'Collect_Responses_In' WHERE ref = 'Collect_Responses'; + + +UPDATE llx_document_model set nom = 'standard' where nom = 'Standard' and type ='stock'; +UPDATE llx_document_model set nom = 'stdmovement', type = 'movement' where nom = 'StdMouvement' and type ='mouvement'; + + +UPDATE llx_const SET value = 0 WHERE name = 'FACTURE_TVAOPTION' and value = 'franchise'; +UPDATE llx_const SET value = 1 WHERE name = 'FACTURE_TVAOPTION' and value <> 'franchise' AND value <> '0' AND value <> '1'; + +ALTER TABLE llx_commande MODIFY COLUMN date_livraison DATETIME; + +ALTER TABLE llx_website ADD COLUMN position integer DEFAULT 0; + +ALTER TABLE llx_establishment ADD COLUMN ref varchar(30); +ALTER TABLE llx_establishment ADD COLUMN label varchar(128); +UPDATE llx_establishment SET ref = rowid WHERE ref IS NULL; +ALTER TABLE llx_establishment MODIFY COLUMN ref varchar(30) NOT NULL; +ALTER TABLE llx_establishment MODIFY COLUMN label varchar(128); + +INSERT INTO llx_const (name, entity, value, type, visible) VALUES ('PRODUCT_PRICE_BASE_TYPE', 0, 'HT', 'string', 0); + +ALTER TABLE llx_subscription MODIFY COLUMN datef DATETIME; + +ALTER TABLE llx_loan_schedule ADD column fk_payment_loan INTEGER; + + +ALTER TABLE llx_user DROP COLUMN jabberid; +ALTER TABLE llx_user DROP COLUMN skype; +ALTER TABLE llx_user DROP COLUMN twitter; +ALTER TABLE llx_user DROP COLUMN facebook; +ALTER TABLE llx_user DROP COLUMN linkedin; +ALTER TABLE llx_user DROP COLUMN instagram; +ALTER TABLE llx_user DROP COLUMN snapchat; +ALTER TABLE llx_user DROP COLUMN googleplus; +ALTER TABLE llx_user DROP COLUMN youtube; +ALTER TABLE llx_user DROP COLUMN whatsapp; + +ALTER TABLE llx_user ADD COLUMN datelastpassvalidation datetime; +ALTER TABLE llx_user ADD COLUMN datestartvalidity datetime; +ALTER TABLE llx_user ADD COLUMN dateendvalidity datetime; + +ALTER TABLE llx_user ADD COLUMN idpers1 varchar(128); +ALTER TABLE llx_user ADD COLUMN idpers2 varchar(128); +ALTER TABLE llx_user ADD COLUMN idpers3 varchar(128); + + +-- Intracomm Report +CREATE TABLE llx_c_transport_mode ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + code varchar(3) NOT NULL, + label varchar(255) NOT NULL, + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; + +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('MAR', 'Transport maritime (y compris camions ou wagons sur bateau)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('TRA', 'Transport par chemin de fer (y compris camions sur wagon)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('ROU', 'Transport par route', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('AIR', 'Transport par air', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('POS', 'Envois postaux', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('OLE', 'Installations de transport fixe (olĂ©oduc)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('NAV', 'Transport par navigation intĂ©rieure', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('PRO', 'Propulsion propre', 1); + +ALTER TABLE llx_facture ADD COLUMN fk_transport_mode integer after location_incoterms; +ALTER TABLE llx_facture_fourn ADD COLUMN fk_transport_mode integer after location_incoterms; + +ALTER TABLE llx_societe ADD COLUMN transport_mode tinyint after cond_reglement; +ALTER TABLE llx_societe ADD COLUMN transport_mode_supplier tinyint after cond_reglement_supplier; + +CREATE TABLE llx_intracommreport +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + + ref varchar(30) NOT NULL, -- report reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id + type_declaration varchar(32), + periods varchar(32), + mode varchar(32), + content_xml text, + type_export varchar(10), + datec datetime, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +)ENGINE=innodb; + +ALTER TABLE llx_c_incoterms ADD COLUMN label varchar(100) NULL; + +CREATE TABLE llx_recruitment_recruitmentjobposition( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity INTEGER DEFAULT 1 NOT NULL, + label varchar(255) NOT NULL, + qty integer DEFAULT 1 NOT NULL, + fk_soc integer, + fk_project integer, + fk_user_recruiter integer, + fk_user_supervisor integer, + fk_establishment integer, + date_planned date, + remuneration_suggested varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_recruitment_recruitmentjobposition ADD INDEX idx_recruitment_recruitmentjobposition_rowid (rowid); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD INDEX idx_recruitment_recruitmentjobposition_ref (ref); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD INDEX idx_recruitment_recruitmentjobposition_fk_soc (fk_soc); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD INDEX idx_recruitment_recruitmentjobposition_fk_project (fk_project); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD CONSTRAINT llx_recruitment_recruitmentjobposition_fk_user_recruiter FOREIGN KEY (fk_user_recruiter) REFERENCES llx_user(rowid); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD CONSTRAINT llx_recruitment_recruitmentjobposition_fk_user_supervisor FOREIGN KEY (fk_user_supervisor) REFERENCES llx_user(rowid); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD CONSTRAINT llx_recruitment_recruitmentjobposition_fk_establishment FOREIGN KEY (fk_establishment) REFERENCES llx_establishment(rowid); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD CONSTRAINT llx_recruitment_recruitmentjobposition_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD INDEX idx_recruitment_recruitmentjobposition_status (status); + +ALTER TABLE llx_recruitment_recruitmentjobposition ADD COLUMN email_recruiter varchar(255); +ALTER TABLE llx_recruitment_recruitmentjobposition ADD COLUMN entity INTEGER DEFAULT 1 NOT NULL; +ALTER TABLE llx_recruitment_recruitmentjobposition ADD COLUMN remuneration_suggested varchar(255); + +create table llx_recruitment_recruitmentjobposition_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_recruitment_recruitmentjobposition_extrafields ADD INDEX idx_recruitmentjobposition_fk_object(fk_object); + + + +CREATE TABLE llx_recruitment_recruitmentcandidature( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer NOT NULL DEFAULT 1, + fk_recruitmentjobposition INTEGER NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL, + firstname varchar(128), + lastname varchar(128), + email varchar(255), + phone varchar(64), + date_birth date, + remuneration_requested integer, + remuneration_proposed integer, + email_msgid varchar(255), + fk_recruitment_origin INTEGER NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN entity integer NOT NULL DEFAULT 1; +ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN email_msgid varchar(255); +ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN fk_recruitment_origin INTEGER NULL; +ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN date_birth date; + +ALTER TABLE llx_recruitment_recruitmentcandidature ADD INDEX idx_recruitment_recruitmentcandidature_rowid (rowid); +ALTER TABLE llx_recruitment_recruitmentcandidature ADD INDEX idx_recruitment_recruitmentcandidature_ref (ref); +ALTER TABLE llx_recruitment_recruitmentcandidature ADD CONSTRAINT llx_recruitment_recruitmentcandidature_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_recruitment_recruitmentcandidature ADD INDEX idx_recruitment_recruitmentcandidature_status (status); + +create table llx_recruitment_recruitmentcandidature_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_recruitment_recruitmentcandidature_extrafields ADD INDEX idx_recruitmentcandidature_fk_object(fk_object); + +ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitmentcandidature_email_msgid(email_msgid); + + +ALTER TABLE llx_product_attribute ADD COLUMN ref_ext VARCHAR(255) after ref; +ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; + + +CREATE TABLE llx_product_attribute_combination_price_level +( + rowid INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, + fk_product_attribute_combination INTEGER DEFAULT 1 NOT NULL, + fk_price_level INTEGER DEFAULT 1 NOT NULL, + variation_price DOUBLE(24,8) NOT NULL, + variation_price_percentage INTEGER NULL +)ENGINE=innodb; + +ALTER TABLE llx_product_attribute_combination_price_level ADD UNIQUE( fk_product_attribute_combination, fk_price_level); + + + +-- Add dictionary for prospect level and action commercial on contacts (Using this is not recommanded) + +create table llx_c_prospectcontactlevel +( + code varchar(12) PRIMARY KEY, + label varchar(30), + sortorder smallint, + active smallint DEFAULT 1 NOT NULL, + module varchar(32) NULL +) ENGINE=innodb; +insert into llx_c_prospectcontactlevel (code,label,sortorder) values ('PL_NONE', 'None', 1); +insert into llx_c_prospectcontactlevel (code,label,sortorder) values ('PL_LOW', 'Low', 2); +insert into llx_c_prospectcontactlevel (code,label,sortorder) values ('PL_MEDIUM', 'Medium', 3); +insert into llx_c_prospectcontactlevel (code,label,sortorder) values ('PL_HIGH', 'High', 4); + +create table llx_c_stcommcontact +( + id integer PRIMARY KEY, + code varchar(12) NOT NULL, + libelle varchar(30), + picto varchar(128), + active tinyint default 1 NOT NULL +)ENGINE=innodb; +ALTER TABLE llx_c_stcommcontact ADD UNIQUE INDEX uk_c_stcommcontact(code); + +insert into llx_c_stcommcontact (id,code,libelle) values (-1, 'ST_NO', 'Do not contact'); +insert into llx_c_stcommcontact (id,code,libelle) values ( 0, 'ST_NEVER', 'Never contacted'); +insert into llx_c_stcommcontact (id,code,libelle) values ( 1, 'ST_TODO', 'To contact'); +insert into llx_c_stcommcontact (id,code,libelle) values ( 2, 'ST_PEND', 'Contact in progress'); +insert into llx_c_stcommcontact (id,code,libelle) values ( 3, 'ST_DONE', 'Contacted'); + +ALTER TABLE llx_socpeople ADD COLUMN fk_prospectcontactlevel varchar(12) AFTER priv; +ALTER TABLE llx_socpeople ADD COLUMN fk_stcommcontact integer DEFAULT 0 NOT NULL AFTER fk_prospectcontactlevel; + +create table llx_c_recruitment_origin +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + label varchar(64) NOT NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + + +ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitmentcandidature_email_msgid(email_msgid); + + +ALTER TABLE llx_product MODIFY COLUMN seuil_stock_alerte float; +ALTER TABLE llx_product MODIFY COLUMN desiredstock float; + +ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float; +ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float; + +ALTER TABLE llx_product ADD COLUMN fk_state integer DEFAULT NULL; + +ALTER TABLE llx_projet ADD COLUMN email_msgid varchar(255); +ALTER TABLE llx_ticket ADD COLUMN email_msgid varchar(255); +ALTER TABLE llx_actioncomm ADD COLUMN reply_to varchar(255); + +ALTER TABLE llx_paiement ADD pos_change DOUBLE(24,8) DEFAULT 0 AFTER fk_export_compta; + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_CREATE','Contact address created','Executed when a contact is created','contact',50); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_SENTBYMAIL','Mails sent from third party card','Executed when you send email from contact adress card','contact',51); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_DELETE','Contact address deleted','Executed when a contact is deleted','contact',52); + +ALTER TABLE llx_opensurvey_sondage CHANGE COLUMN tms tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; +ALTER TABLE llx_ecm_directories CHANGE COLUMN date_m tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; +ALTER TABLE llx_ecm_files CHANGE COLUMN date_m tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; + +INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'recruitment','recruitmentcandidature_send','',0,null,null,'(AnswerCandidature)' ,100,'$conf->recruitment->enabled',1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourCandidature)__', '__(Hello)__ __CANDIDATE_FULLNAME__,

\n\n__(YourCandidatureAnswer)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 0); + +ALTER TABLE llx_c_action_trigger MODIFY COLUMN code varchar(64) NOT NULL; + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_CREATE','Job created','Executed when a job is created','recruitment',7500); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_MODIFY','Job modified','Executed when a job is modified','recruitment',7502); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_SENTBYMAIL','Mails sent from job record','Executed when you send email from job record','recruitment',7504); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_DELETE','Job deleted','Executed when a job is deleted','recruitment',7506); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_CREATE','Candidature created','Executed when a candidature is created','recruitment',7510); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_MODIFY','Candidature modified','Executed when a candidature is modified','recruitment',7512); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_SENTBYMAIL','Mails sent from candidature record','Executed when you send email from candidature record','recruitment',7514); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_DELETE','Candidature deleted','Executed when a candidature is deleted','recruitment',7516); + +ALTER TABLE llx_actioncomm_reminder ADD COLUMN entity integer NOT NULL DEFAULT 1; +ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_actioncomm integer NOT NULL; +ALTER TABLE llx_actioncomm_reminder ADD COLUMN fk_email_template integer; +ALTER TABLE llx_actioncomm_reminder ADD COLUMN lasterror varchar(128) NULL; + +ALTER TABLE llx_actioncomm_reminder DROP INDEX uk_actioncomm_reminder_unique; +ALTER TABLE llx_actioncomm_reminder ADD UNIQUE uk_actioncomm_reminder_unique (fk_user, typeremind, offsetvalue, offsetunit, fk_actioncomm); + +ALTER TABLE llx_actioncomm_reminder ADD INDEX idx_actioncomm_reminder_status (status); + + +ALTER TABLE llx_inventorydet ADD UNIQUE uk_inventorydet(fk_inventory, fk_warehouse, fk_product, batch); + +ALTER TABLE llx_commandedet ADD COLUMN ref_ext varchar(255) AFTER label; +ALTER TABLE llx_facturedet ADD COLUMN ref_ext varchar(255) AFTER multicurrency_total_ttc; + +ALTER TABLE llx_c_ticket_category ADD COLUMN fk_parent integer DEFAULT 0 NOT NULL; +ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL; + +ALTER TABLE llx_c_ticket_severity CHANGE color color VARCHAR(10) NULL; + +ALTER TABLE llx_expensereport ADD COLUMN fk_user_creat integer NULL; + +ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL; + +ALTER TABLE llx_paiement ADD COLUMN ref_ext varchar(255) AFTER ref; + +ALTER TABLE llx_bank ADD COLUMN origin_id integer; +ALTER TABLE llx_bank ADD COLUMN origin_type varchar(64) NULL; +ALTER TABLE llx_bank ADD COLUMN import_key varchar(14); + +ALTER TABLE llx_menu MODIFY COLUMN enabled text; + +CREATE TABLE llx_ecm_files_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_ecm_files_extrafields ADD INDEX idx_ecm_files_extrafields (fk_object); +ALTER TABLE llx_ecm_files ADD COLUMN note_private text AFTER fk_user_m; +ALTER TABLE llx_ecm_files ADD COLUMN note_public text AFTER note_private; + +CREATE TABLE llx_ecm_directories_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object); +ALTER TABLE llx_ecm_directories ADD COLUMN note_private text AFTER fk_user_m; +ALTER TABLE llx_ecm_directories ADD COLUMN note_public text AFTER note_private; + +ALTER TABLE llx_website_page ADD COLUMN allowed_in_frames integer DEFAULT 0; +ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255); +ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255); + +DELETE FROM llx_const WHERE name in ('MAIN_INCLUDE_ZERO_VAT_IN_REPORTS'); + +UPDATE llx_projet_task_time SET tms = null WHERE tms = 0; +ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; + +ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime; + + +DELETE FROM llx_user_rights WHERE fk_id IN (SELECT id FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous'); +DELETE FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous'; +UPDATE llx_rights_def set perms = 'readall' WHERE perms = 'read_all' and module = 'holiday'; + +CREATE TABLE llx_c_product_nature ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code tinyint NOT NULL, + label varchar(100), + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code, active); + +INSERT INTO llx_c_product_nature (code, label, active) VALUES (0, 'RowMaterial', 1); +INSERT INTO llx_c_product_nature (code, label, active) VALUES (1, 'Finished', 1); + +ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL; +ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code); + +<<<<<<< HEAD + +ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); +ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); + +======= +>>>>>>> a93227ac2f04c80c76b517215d1d422168607fb1 +-- MIGRATION TO DO AFTER RENAMING AN OBJECT + +-- drop constraint +ALTER TABLE llx_livraison DROP FOREIGN KEY fk_livraison_fk_soc; +ALTER TABLE llx_livraison DROP FOREIGN KEY fk_livraison_fk_user_author; +ALTER TABLE llx_livraison DROP FOREIGN KEY fk_livraison_fk_user_valid; + +-- rename Table +ALTER TABLE llx_livraison RENAME TO llx_delivery; +ALTER TABLE llx_livraison_extrafields RENAME TO llx_delivery_extrafields; +ALTER TABLE llx_livraisondet RENAME TO llx_deliverydet; +ALTER TABLE llx_livraisondet_extrafields RENAME TO llx_deliverydet_extrafields; + +-- rename index +ALTER TABLE llx_delivery DROP INDEX idx_livraison_uk_ref; +ALTER TABLE llx_delivery ADD UNIQUE INDEX idx_delivery_uk_ref (ref, entity); +ALTER TABLE llx_delivery DROP INDEX idx_livraison_fk_soc; +ALTER TABLE llx_delivery ADD INDEX idx_delivery_fk_soc (fk_soc); +ALTER TABLE llx_delivery DROP INDEX idx_livraison_fk_user_author; +ALTER TABLE llx_delivery ADD INDEX idx_delivery_fk_user_author (fk_user_author); +ALTER TABLE llx_delivery DROP INDEX idx_livraison_fk_user_valid; +ALTER TABLE llx_delivery ADD INDEX idx_delivery_fk_user_valid (fk_user_valid); + +-- drop constraint +ALTER TABLE llx_delivery DROP FOREIGN KEY fk_livraison_fk_soc; +ALTER TABLE llx_delivery DROP FOREIGN KEY fk_livraison_fk_user_author; +ALTER TABLE llx_delivery DROP FOREIGN KEY fk_livraison_fk_user_valid; + +-- add constraint +ALTER TABLE llx_delivery ADD CONSTRAINT fk_delivery_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); +ALTER TABLE llx_delivery ADD CONSTRAINT fk_delivery_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); +ALTER TABLE llx_delivery ADD CONSTRAINT fk_delivery_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); + +ALTER TABLE llx_deliverydet DROP FOREIGN KEY fk_livraisondet_fk_livraison; +ALTER TABLE llx_deliverydet DROP INDEX idx_livraisondet_fk_expedition; +ALTER TABLE llx_deliverydet CHANGE COLUMN fk_livraison fk_delivery integer; +ALTER TABLE llx_deliverydet ADD INDEX idx_deliverydet_fk_delivery (fk_delivery); +ALTER TABLE llx_deliverydet ADD CONSTRAINT fk_deliverydet_fk_delivery FOREIGN KEY (fk_delivery) REFERENCES llx_delivery (rowid); + +UPDATE llx_extrafields SET elementtype = 'delivery' WHERE elementtype = 'livraison'; +UPDATE llx_extrafields SET elementtype = 'deliverydet' WHERE elementtype = 'livraisondet'; + +-- update llx_ecm_files +UPDATE llx_ecm_files SET src_object_type = 'delivery' WHERE src_object_type = 'livraison'; + +-- update llx_links +UPDATE llx_links SET objecttype = 'delivery' WHERE objecttype = 'livraison'; + +-- update llx_document_model +UPDATE llx_document_model SET type = 'delivery' WHERE type = 'livraison'; + +-- update llx_object_lang +UPDATE llx_object_lang SET type_object = 'delivery' WHERE type_object = 'livraison'; + +-- update llx_c_type_contact +UPDATE llx_c_type_contact SET element = 'delivery' WHERE element = 'livraison'; + +-- update llx_c_email_template +UPDATE llx_c_email_template SET type_template = 'delivery' WHERE type_template = 'livraison'; + +-- update llx_element_element +UPDATE llx_element_element SET sourcetype = 'delivery' WHERE sourcetype = 'livraison'; +UPDATE llx_element_element SET targettype = 'delivery' WHERE targettype = 'livraison'; + +-- update llx_actioncomm +UPDATE llx_actioncomm SET element_type = 'delivery' WHERE element_type = 'livraison'; + +-- update llx_const +UPDATE llx_const set name = 'DELIVERY_ADDON_NUMBER' WHERE name = 'LIVRAISON_ADDON_NUMBER'; +UPDATE llx_const set value = 'mod_delivery_jade' WHERE value = 'mod_livraison_jade' AND name = 'DELIVERY_ADDON_NUMBER'; +UPDATE llx_const set value = 'mod_delivery_saphir' WHERE value = 'mod_livraison_saphir' AND name = 'DELIVERY_ADDON_NUMBER'; + +-- update llx_rights_def +UPDATE llx_rights_def set perms = 'delivery' WHERE perms = 'livraison' and module = 'expedition'; +UPDATE llx_rights_def set perms = 'delivery_advance' WHERE perms = 'livraison_advance' and module = 'expedition'; + + +ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_commande (fk_commande); +ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_product (fk_product); + + +CREATE TABLE llx_zapier_hook( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + url varchar(255), + event varchar(255), + module varchar(128), + action varchar(128), + status integer, + date_creation datetime NOT NULL, + fk_user integer NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + import_key varchar(14) +) ENGINE=innodb; + + +CREATE TABLE llx_session( + session_id varchar(50) PRIMARY KEY, + session_variable text, + last_accessed datetime NOT NULL, + fk_user integer NOT NULL, + remote_ip varchar(64) NULL, + user_agent varchar(128) NULL +) ENGINE=innodb; + +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'github', 'Github', 'https://github.com/{socialid}', 'fa-github', 1); + +-- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_funnel_of_prospection.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_funnel_of_prospection.php' AND entity = 1); +-- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_customers_outstanding_bill_reached.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_customers_outstanding_bill_reached.php' AND entity = 1); +-- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_scheduled_jobs.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_scheduled_jobs.php' AND entity = 1); + +ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); + +ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL; + diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 7b9cb8c9ef8..edd44b86a55 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -43,3 +43,8 @@ ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL; ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL; ALTER TABLE llx_facture MODIFY COLUMN date_valid DATETIME NULL DEFAULT NULL; + + +ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); +ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); +