diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 4be0b133143..9d8d13b2aec 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -265,7 +265,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; @@ -325,7 +325,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; @@ -625,7 +625,7 @@ if (empty($action) || $action == 'view') { else print $accountoshow; print ''; print "
| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | '; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { @@ -2067,7 +2067,7 @@ if ($action == 'create' && $usercancreate) if ($action == 'clone') { // Create an array for form $formquestion = array( - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)')) ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 72d45f2467c..be23895fe7f 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1296,7 +1296,7 @@ abstract class CommonDocGenerator { // Sort extrafields by rank uasort($fields, function ($a, $b) { - return ($a->rank > $b->rank) ? -1 : 1; + return ($a->rank > $b->rank) ? 1 : -1; }); // define some HTML content with style diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 9c023a05478..719e34c5df9 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -448,8 +448,9 @@ class DoliDBMysqli extends DoliDB 1215 => 'DB_ERROR_CANNOT_ADD_FOREIGN_KEY_CONSTRAINT', 1216 => 'DB_ERROR_NO_PARENT', 1217 => 'DB_ERROR_CHILD_EXISTS', - 1396 => 'DB_ERROR_USER_ALREADY_EXISTS', // When creating user already existing - 1451 => 'DB_ERROR_CHILD_EXISTS' + 1396 => 'DB_ERROR_USER_ALREADY_EXISTS', // When creating a user that already existing + 1451 => 'DB_ERROR_CHILD_EXISTS', + 1826 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ); if (isset($errorcode_map[$this->db->errno])) { diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index f849be78865..12fb15d3b2a 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -273,9 +273,10 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if ($offsetforchartofaccount > 0) { // Replace lines - // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401, 'PCG99-ABREGE','CAPIT', 'XXXXXX', '1', '0', '...', 1);' + // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401, 'PCG99-ABREGE', 'CAPIT', '1234', 1400, '...', 1);' // with - // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401 + 200100000, 'PCG99-ABREGE','CAPIT', 'XXXXXX', '1', '0', '...', 1);' + // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401 + 200100000, 'PCG99-ABREGE','CAPIT', '1234', 1400 + 200100000, '...', 1);' + // Note: string with 1234 instead of '1234' is also supported $newsql = preg_replace('/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims', 'VALUES (__ENTITY__, \1 + '.$offsetforchartofaccount.', \2, \3 + '.$offsetforchartofaccount, $newsql); $newsql = preg_replace('/([,\s])0 \+ '.$offsetforchartofaccount.'/ims', '\1 0', $newsql); //var_dump($newsql); diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index c06c4431562..81c62958418 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -351,17 +351,17 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt { $result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[2] = price2num($result[0] + $result[1], 'MT'); $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; $result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[2] = price2num($result[0] + $result[1] + $result[9] + $result[10], 'MT'); } else { $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; $result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[0] = price2num($result[2] - $result[1], 'MT'); $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; $result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[0] = price2num($result[2] - $result[1] - $result[9] - $result[10], 'MT'); } } diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 46d9b4d712e..54ab237c9b8 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -1102,6 +1102,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PY', 11701, NULL, 0, 'PY', 'Puducherry', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RJ', 11701, NULL, 0, 'RJ', 'Rajasthan', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SK', 11701, NULL, 0, 'SK', 'Sikkim', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TE', 11701, NULL, 0, 'TE', 'Telangana', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TN', 11701, NULL, 0, 'TN', 'Tamil Nadu', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TR', 11701, NULL, 0, 'TR', 'Tripura', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('UL', 11701, NULL, 0, 'UL', 'Uttarakhand', 1); @@ -1145,7 +1146,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SU', 11801, NULL, 0, 'SU', 'Sumatera Utara ', 1); -- Provinces Mexique (id country=154) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DIF', 15401, '', 0, 'DIF', 'Distrito Federal', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CMX', 15401, '', 0, 'CMX', 'Ciudad de México', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AGS', 15401, '', 0, 'AGS', 'Aguascalientes', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BCN', 15401, '', 0, 'BCN', 'Baja California Norte', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BCS', 15401, '', 0, 'BCS', 'Baja California Sur', 1); diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index e1a69a1facc..82a0f11e893 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -250,7 +250,10 @@ INSERT INTO llx_c_ticket_resolution (code, pos, label, active, use_default, desc DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__; -ALTER TABLE llx_extrafields MODIFY COLUMN printable integer DEFAULT 0; +-- VMYSQL4.1 ALTER TABLE llx_extrafields MODIFY COLUMN printable integer DEFAULT 0; +-- VPGSQL8.2 ALTER TABLE llx_extrafields ALTER COLUMN printable DROP DEFAULT; +-- VPGSQL8.2 ALTER TABLE llx_extrafields MODIFY COLUMN printable integer USING printable::integer; +-- VPGSQL8.2 ALTER TABLE llx_extrafields ALTER COLUMN printable SET DEFAULT 0; ALTER TABLE llx_extrafields ADD COLUMN printable integer DEFAULT 0; UPDATE llx_const SET name = 'INVOICE_USE_RETAINED_WARRANTY' WHERE name = 'INVOICE_USE_SITUATION_RETAINED_WARRANTY'; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index b04560dab32..7fea66e325e 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -808,7 +808,8 @@ class Products extends DolibarrApi foreach($product_fourn_list as $tmpobj) { $this->_cleanObjectDatas($tmpobj); } - //var_dump($product_fourn_list->db);exit; + + //var_dump($product_fourn_list->db);exit; $obj_ret[$obj->rowid] = $product_fourn_list; $i++; @@ -833,7 +834,7 @@ class Products extends DolibarrApi * @param string $ref Ref of element * @param string $ref_ext Ref ext of element * @param string $barcode Barcode of element - * @return array|mixed Data without useless information + * @return array|mixed Data without useless information * * @url GET {id}/purchase_prices * @@ -863,11 +864,17 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $product_fourn_list = array(); + if ($result) { $product_fourn = new ProductFournisseur($this->db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->product->id, '', '', 0, 0); } + foreach($product_fourn_list as $tmpobj) { + $this->_cleanObjectDatas($tmpobj); + } + return $this->_cleanObjectDatas($product_fourn_list); } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 1e0c147c82a..2c9de0fa62c 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -272,6 +272,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac { if (intval($time) > 0) { + $matches = array(); // Hours or minutes of duration if (preg_match("/([0-9]+)duration(hour|min)/", $key, $matches)) { @@ -294,6 +295,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac foreach ($timespent_duration as $key => $val) { $object->fetch($key); + $taskid = $object->id; if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); @@ -301,9 +303,9 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac $object->timespent_duration = $val; $object->timespent_fk_user = $usertoprocess->id; $object->timespent_note = GETPOST($key.'note'); - if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered + if (GETPOST($key."hour", 'int') != '' && GETPOST($key."hour", 'int') >= 0) // If hour was entered { - $object->timespent_datehour = dol_mktime(GETPOST($key."hour"), GETPOST($key."min"), 0, $monthofday, $dayofday, $yearofday); + $object->timespent_datehour = dol_mktime(GETPOST($key."hour", 'int'), GETPOST($key."min", 'int'), 0, $monthofday, $dayofday, $yearofday); $object->timespent_withhour = 1; } else diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 730e66eaab8..e3d6409ddd6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -725,6 +725,8 @@ class Societe extends CommonObject */ public function __construct($db) { + global $conf; + $this->db = $db; $this->client = 0; @@ -735,6 +737,13 @@ class Societe extends CommonObject $this->forme_juridique_code = 0; $this->tva_assuj = 1; $this->status = 1; + + if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { + $this->fields['address']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST; + $this->fields['zip']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST; + $this->fields['town']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST; + //$this->fields['fk_pays']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST; + } } |