diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 49e5beaa19d..07cd885698e 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1070,7 +1070,7 @@ if ($action == 'create') $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); print ' '; - $urloption = '?action=create'; + $urloption = '?action=create&donotclearsession=1'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; // update task list @@ -1503,7 +1503,7 @@ if ($id > 0) { print ''; - $urloption = '?action=create'; // we use create not edit for more flexibility + $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; // update task list diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index f20197df4dd..0bb38aeaa38 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -149,6 +150,9 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql .= ", s.code_client"; + $sql .= ", s.email"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -193,6 +197,9 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; print $companystatic->getNomUrl(1, 'customer', 16); print ''; print ''.price($obj->total_ht).''; @@ -233,6 +240,9 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -276,6 +286,8 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; print ''.price($obj->total_ht).''; @@ -315,6 +327,9 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql .= ", s.code_client"; + $sql .= ", s.email"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -358,6 +373,8 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; + $companystatic->email = $obj->email; + $companystatic->entity = $obj->entity; print $companystatic->getNomUrl(1, 'customer', 16); print ''; if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { @@ -404,6 +421,8 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande- $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql .= ", s.code_client"; $sql .= ", s.code_fournisseur"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -447,6 +466,8 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande- $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { @@ -496,6 +517,9 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; $sql .= ", s.code_client"; + $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 2, 3)"; @@ -532,6 +556,9 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; $companystatic->canvas = $objp->canvas; + $companystatic->code_compta = $objp->code_compta; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; print ''; print ''.$companystatic->getNomUrl(1, 'customer', 48).''; print ''; @@ -560,6 +587,8 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; $sql .= ", s.code_fournisseur"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.fournisseur = 1"; @@ -591,6 +620,8 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; $companystatic->canvas = $objp->canvas; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; print ''; print ''.$companystatic->getNomUrl(1, 'supplier', 44).''; print ''.dol_print_date($db->jdate($objp->dm), 'day').''; @@ -628,7 +659,7 @@ if ($user->rights->agenda->myactions->read) /* - * Last contracts + * Latest contracts */ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT { @@ -636,7 +667,9 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; $sql .= ", s.code_client"; - $sql .= " c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; + $sql .= ", s.entity"; + $sql .= ", s.email"; + $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; @@ -673,6 +706,8 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; $companystatic->canvas = $objp->canvas; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; print $companystatic->getNomUrl(1, 'customer', 44); print ''."\n"; print "".$staticcontrat->LibStatut($obj->statut, 3)."\n"; @@ -697,6 +732,8 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; @@ -760,6 +797,8 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print $companystatic->getNomUrl(1, 'customer', 44); print ''; print ''; @@ -802,6 +841,8 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; $sql .= ", s.code_client"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -864,6 +905,8 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print $companystatic->getNomUrl(1, 'customer', 44); print ''; print ''; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index ac019de8088..af18b834edf 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -77,7 +77,22 @@ if ($user->socid > 0) { accessforbidden(); } -$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; +// Define $arrayofentities if multientity is set. +$arrayofentities = array(); +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + $arrayofentities = $mc->getEntitiesList(); +} + +$entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity)); +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity) && ! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + $entity = '0,'.join(',', array_keys($arrayofentities)); + } +} +if (empty($entity)) $entity = $conf->entity; + +$error = 0; + /* @@ -108,42 +123,42 @@ if (($action == "searchfiles" || $action == "dl")) { $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; // Customer invoices - $sql = "SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql = "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; $sql .= " UNION ALL"; // Vendor invoices - $sql .= " SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; $sql .= " UNION ALL"; // Expense reports - $sql .= " SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; $sql .= " UNION ALL"; // Donations - $sql .= " SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; $sql .= " UNION ALL"; // Paiements of salaries - $sql .= " SELECT t.rowid as id, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; $sql .= " UNION ALL"; // Social contributions - $sql .= " SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE date_creation between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -228,6 +243,7 @@ if (($action == "searchfiles" || $action == "dl")) { { $nofile = array(); $nofile['id'] = $objd->id; + $nofile['entity'] = $objd->entity; $nofile['date'] = $db->idate($objd->date); $nofile['paid'] = $objd->paid; $nofile['amount_ht'] = $objd->total_ht; @@ -248,6 +264,7 @@ if (($action == "searchfiles" || $action == "dl")) { foreach ($files as $key => $file) { $file['id'] = $objd->id; + $file['entity'] = $objd->entity; $file['date'] = $db->idate($objd->date); $file['paid'] = $objd->paid; $file['amount_ht'] = $objd->total_ht; @@ -314,6 +331,10 @@ if ($result && $action == "dl" && !$error) dol_mkdir($dirfortmpfile); $log = $langs->transnoentitiesnoconv("Type"); + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.$langs->transnoentitiesnoconv("Entity"); + } $log .= ','.$langs->transnoentitiesnoconv("Date"); $log .= ','.$langs->transnoentitiesnoconv("Ref"); $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); @@ -342,6 +363,10 @@ if ($result && $action == "dl" && !$error) } $log .= $file['item']; + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]); + } $log .= ','.dol_print_date($file['date'], 'dayrfc'); $log .= ','.$file['ref']; $log .= ','.$file['amount_ht']; @@ -383,11 +408,13 @@ $form = new Form($db); $userstatic = new User($db); $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); +$help_url = ''; llxHeader('', $title, $help_url); $h = 0; -$head[$h][0] = $_SERVER["PHP_SELF"].$varlink; +$head = array(); +$head[$h][0] = $_SERVER["PHP_SELF"]; $head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][2] = 'AccountancyFiles'; @@ -400,13 +427,18 @@ print ''; print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; -// Export is for current company only ! +// Export is for current company only if (!empty($conf->multicompany->enabled) && is_object($mc)) { + $mc->getInfo($conf->entity); print '('.$langs->trans("Entity").' : '; - $mc->dao->getEntities(); - $mc->dao->fetch($conf->entity); - print $mc->dao->label; + print ""; + if (! empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); + } else { + print $mc->label; + } + print ""; print ")\n"; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 7ca62b67ab8..906ef09ac6b 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -286,11 +286,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) else print $langs->trans("NotDefined"); print ""; print "".$ref.""; - if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){ + if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { if($obj->family == 'invoice'){ $mc->getInfo($obj->entity); print "".$mc->label.""; - }else print ""; + } + else { + print ""; + } } print "".$refcomp.""; if ($obj->total_ttc < 0) { print ''.price(abs($total_ttc))." "; }; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5038079085b..139cd6c77ff 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -101,6 +101,9 @@ $usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global- $object = new Facture($db); $extrafields = new ExtraFields($db); +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + // Load object if ($id > 0 || !empty($ref)) { if ($action != 'add') { @@ -138,6 +141,7 @@ $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isd + /* * Actions */ diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index fb2a3edfd9c..c1e0657257c 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -97,6 +97,8 @@ if (empty($reshook)) $totalpayment = 0; $multicurrency_totalpayment = 0; $atleastonepaymentnotnull = 0; + $formquestion = array(); + $i = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date $tmpinvoice = new Facture($db); @@ -216,7 +218,7 @@ if (empty($reshook)) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $db->begin(); @@ -262,8 +264,10 @@ if (empty($reshook)) $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_paiement = GETPOST('num_paiement', 'alpha'); - $paiement->note = GETPOST('comment', 'alpha'); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility if (!$error) { diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index feb7564cdaf..38ff4d3ce77 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -95,7 +95,7 @@ class box_clients extends ModeleBoxes $sql.= ", s.code_compta_fournisseur"; $sql.= ", s.logo"; $sql.= ", s.email"; - $sql.= ", s.datec, s.tms, s.status"; + $sql.= ", s.datec, s.tms, s.status, s.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 3)"; @@ -127,6 +127,7 @@ class box_clients extends ModeleBoxes $thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->logo = $objp->logo; $thirdpartystatic->email = $objp->email; + $thirdpartystatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => '', diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 5f26351affe..2021589cbe0 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2006 Destailleur Laurent * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2019 Frederic France + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -86,7 +87,7 @@ class box_fournisseurs extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; $sql.= " s.code_fournisseur, s.email as semail,"; - $sql.= " s.logo"; + $sql.= " s.logo, s.code_compta_fournisseur, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; @@ -112,6 +113,8 @@ class box_fournisseurs extends ModeleBoxes $thirdpartytmp->email = $objp->semail; $thirdpartytmp->code_client = $objp->code_client; $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => '', diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 0bc6d801e41..9fffc92963f 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -96,7 +96,7 @@ class box_project extends ModeleBoxes $projectsListId=''; if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql.= " AND p.fk_statut = 1"; // Only open projects @@ -117,6 +117,7 @@ class box_project extends ModeleBoxes $projectstatic->ref = $objp->ref; $projectstatic->title = $objp->title; $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', @@ -152,6 +153,7 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); $i++; } @@ -166,22 +168,26 @@ class box_project extends ModeleBoxes // Add the sum à the bottom of the boxes $this->info_box_contents[$i][] = array( - 'td' => '', + 'td' => 'class="liste_total"', 'text' => $langs->trans("Total")." ".$textHead, 'text' => " ", ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right" ', + 'td' => 'class="right liste_total" ', 'text' => round($num, 0)." ".$langs->trans("Projects"), ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right" ', + 'td' => 'class="right liste_total" ', 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), ); $this->info_box_contents[$i][] = array( - 'td' => '', + 'td' => 'class="liste_total"', 'text' => " ", ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); } /** diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 3cbd9f45514..19e70f7b0b4 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2019 Frederic France + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -84,7 +85,7 @@ class box_propales extends ModeleBoxes if ($user->rights->propale->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.email,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; @@ -122,6 +123,7 @@ class box_propales extends ModeleBoxes $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; $societestatic->email = $objp->email; + $societestatic->entity = $objp->entity; $late = ''; if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index aa1aed52822..bba38bddb30 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -144,7 +144,10 @@ class CMailFile } } - $this->subject = $subject; + // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + + $this->subject = $subject; $this->addr_to = $to; $this->addr_from = $from; $this->msg = $msg; @@ -267,9 +270,6 @@ class CMailFile } } - // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - // We set all data according to choosed sending method. // We also set a value for ->msgid if ($this->sendmode == 'mail') diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b5c9920a6a8..e1e7d97f821 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2479,7 +2479,7 @@ class Form $opt .= ($objp->rowid == $selected) ? ' selected' : ''; if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) { - $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"'; + $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqup="'.$objp->price_by_qty_unitprice.'" data-pbqbase="'.$objp->price_by_qty_price_base_type.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"'; } if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index ef76f426e4b..23d606510dc 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -107,6 +107,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen } } }); + $("input#search_'.$htmlname.'").autocomplete({ source: function( request, response ) { $.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){ diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b60c48da09c..6fd135af821 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -541,6 +541,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) else if (npRate == "np_markRate") price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); } + $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; @@ -552,26 +553,26 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* JQuery for product free or predefined select */ jQuery(document).ready(function() { - jQuery("#price_ht").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { - jQuery("#price_ttc").val(''); - jQuery("#multicurrency_subprice").val(''); - } + jQuery("#price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { + jQuery("#price_ttc").val(''); + jQuery("#multicurrency_subprice").val(''); + } }); jQuery("#price_ttc").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { - jQuery("#price_ht").val(''); - jQuery("#multicurrency_subprice").val(''); - } + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#multicurrency_subprice").val(''); + } }); jQuery("#multicurrency_subprice").keyup(function(event) { - // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { - jQuery("#price_ht").val(''); - jQuery("#price_ttc").val(''); - } + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } }); $("#prod_entry_mode_free").on( "click", function() { @@ -630,15 +631,24 @@ if (!empty($usemargins) && $user->rights->margins->creer) if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier)) { ?> - // Get the HT price for the product and display it - console.log("Load price without tax and set it into #price_ht"); - $.post('/product/ajax/products.php?action=fetch', - { 'id': $(this).val(), 'socid' : socid; ?> }, - function(data) { jQuery("#price_ht").val(data.price_ht); }, - 'json' - ); + var pbq = parseInt($('option:selected', this).attr('data-pbq')); + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0) + { + console.log("We are in a price per qty context, we do not call ajax/product"); + } else { + // Get the HT price for the product and display it + console.log("Load price without tax and set it into #price_ht for id="+$(this).val()+" socid=socid; ?>"); + $.post('/product/ajax/products.php?action=fetch', + { 'id': $(this).val(), 'socid': socid; ?> }, + function(data) { + jQuery("#price_ht").val(data.price_ht); + }, + 'json' + ); + } rights->margins->creer) { $langs->load('stocks'); @@ -744,15 +754,20 @@ if (!empty($usemargins) && $user->rights->margins->creer) } ?> - /* To process customer price per quantity */ + /* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); + var pbqup = parseInt($('option:selected', this).attr('data-pbqup')); + var pbqbase = $('option:selected', this).attr('data-pbqbase'); var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); - if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined") + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0) { - console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); + var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */ + + console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty upht = "+pbqupht+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); jQuery("#pbq").val(pbq); + jQuery("#price_ht").val(pbqupht); if (jQuery("#qty").val() < pbqqty) { jQuery("#qty").val(pbqqty); @@ -809,7 +824,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").val('').hide(); - jQuery("#price_ht").val(''); jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index e0a679d1321..b93b239ef72 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -297,9 +297,13 @@ if (empty($reshook)) $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; - $paiement->paiementid = $_POST['paiementid']; - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; + $paiement->paiementid = GETPOST('paiementid', 'int'); + + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility + if (!$error) { $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 9b96d5bef54..fd9a823c420 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -367,7 +367,7 @@ UsePercentageVariations=Use percentage variations PercentageVariation=Percentage variation ErrorDeletingGeneratedProducts=There was an error while trying to delete existing product variants NbOfDifferentValues=No. of different values -NbProducts=No. of products +NbProducts=Number of products ParentProduct=Parent product HideChildProducts=Hide variant products ShowChildProducts=Show variant products diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index d2fd807a706..d8d113941db 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -39,8 +39,8 @@ ShowProject=Show project ShowTask=Show task SetProject=Set project NoProject=No project defined or owned -NbOfProjects=No. of projects -NbOfTasks=No. of tasks +NbOfProjects=Number of projects +NbOfTasks=Number of tasks TimeSpent=Time spent TimeSpentByYou=Time spent by you TimeSpentByUser=Time spent by user diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index f0206175d0d..6ae3f0cac28 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -238,7 +238,10 @@ $max = 15; $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; $sql .= ", s.code_client"; $sql .= ", s.code_fournisseur"; +$sql .= ", s.code_compta_fournisseur"; +$sql .= ", s.code_compta"; $sql .= ", s.logo"; +$sql .= ", s.entity"; $sql .= ", s.canvas, s.tms as date_modification, s.status as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -285,6 +288,9 @@ if ($result) $thirdparty_static->code_fournisseur = $objp->code_fournisseur; $thirdparty_static->canvas = $objp->canvas; $thirdparty_static->email = $objp->email; + $thirdparty_static->entity = $objp->entity; + $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdparty_static->code_compta = $objp->code_compta; print ''; // Name diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 47a116c7fdf..e480d68eca4 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2018 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 @@ -390,6 +391,7 @@ if ($resql) else dol_print_error($db); $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; +$sql.= " s.entity,"; $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; @@ -1026,6 +1028,7 @@ while ($i < min($num, $limit)) $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; $companystatic->fk_parent = $obj->fk_parent; + $companystatic->entity = $obj->entity; print '