diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php
index 5c9f7ad48ed..0dec55630d3 100644
--- a/htdocs/accountancy/tpl/export_journal.tpl.php
+++ b/htdocs/accountancy/tpl/export_journal.tpl.php
@@ -35,7 +35,7 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d');
header('Content-Type: text/csv');
-if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger
+if ($this->getFormatCode($formatexportset) == "fec" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger
{
// FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle
if (empty($search_date_end))
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index a42888aad27..66c4c1358cb 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -53,7 +53,7 @@ class Setup extends DolibarrApi
* @param int $limit Number of items per page
* @param int $page Page number {@min 0}
* @param int $active Payment type is active or not {@min 0} {@max 1}
- * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')"
+ * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')"
*
* @url GET dictionary/ordering_methods
*
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 5a5a2c5628d..0428f5e1dba 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -239,11 +239,20 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
!empty($user->rights->contrat->lire) ||
!empty($user->rights->ficheinter->lire)
),
- 'module'=>'propal|commande|supplier_order|contrat|ficheinter'
+ 'module'=>'propal|commande|supplier_order|supplier_proposal|contrat|ficheinter'
);
+
+ $onlysupplierorder = ! empty($user->rights->fournisseur->commande->lire) &&
+ empty($user->rights->propal->lire) &&
+ empty($user->rights->commande->lire) &&
+ empty($user->rights->supplier_order->lire) &&
+ empty($user->rights->supplier_proposal->lire) &&
+ empty($user->rights->contrat->lire) &&
+ empty($user->rights->ficheinter->lire);
+
$menu_arr[] = array(
'name' => 'Commercial',
- 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=',
+ 'link' => ($onlysupplierorder ? '/fourn/commande/index.php?mainmenu=commercial&leftmenu=' : '/comm/index.php?mainmenu=commercial&leftmenu='),
'title' => "Commercial",
'level' => 0,
'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal),
diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql
index 9db7c2f382d..179fdf80dcc 100644
--- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql
+++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql
@@ -206,7 +206,9 @@ ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_co
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid);
-ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT;
+-- VMYSQL4.3 ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT;
+-- VPGSQL8.2 ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint;
+
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL;
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index dd9e3b1ed95..c5d1d7837e9 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -4978,16 +4978,16 @@ function migrate_users_socialnetworks()
$db->begin();
print '
| ';
$sql = 'SELECT rowid, socialnetworks';
- $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE ';
- $sql .= ' skype IS NOT NULL OR skype !=""';
- $sql .= ' OR twitter IS NOT NULL OR twitter !=""';
- $sql .= ' OR facebook IS NOT NULL OR facebook!=""';
- $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""';
- $sql .= ' OR instagram IS NOT NULL OR instagram!=""';
- $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""';
- $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""';
- $sql .= ' OR youtube IS NOT NULL OR youtube!=""';
- $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""';
+ $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE';
+ $sql .= " skype IS NOT NULL OR skype <> ''";
+ $sql .= " OR twitter IS NOT NULL OR twitter <> ''";
+ $sql .= " OR facebook IS NOT NULL OR facebook <> ''";
+ $sql .= " OR linkedin IS NOT NULL OR linkedin <> ''";
+ $sql .= " OR instagram IS NOT NULL OR instagram <> ''";
+ $sql .= " OR snapchat IS NOT NULL OR snapchat <> ''";
+ $sql .= " OR googleplus IS NOT NULL OR googleplus <> ''";
+ $sql .= " OR youtube IS NOT NULL OR youtube <> ''";
+ $sql .= " OR whatsapp IS NOT NULL OR whatsapp <> ''";
//print $sql;
$resql = $db->query($sql);
if ($resql) {
diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php
index b30d1463b50..340d9dea02a 100644
--- a/htdocs/loan/class/loan.class.php
+++ b/htdocs/loan/class/loan.class.php
@@ -556,7 +556,7 @@ class Loan extends CommonObject
$table = 'payment_loan';
$field = 'fk_loan';
- $sql = 'SELECT sum(amount) as amount';
+ $sql = 'SELECT sum(amount_capital) as amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.$table;
$sql .= ' WHERE '.$field.' = '.$this->id;
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index ce1c8fdaf17..10e091e1244 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -607,18 +607,29 @@ class Project extends CommonObject
{
$sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$ids.") AND ms.type_mouvement = 1";
}
+ elseif ($type == 'loan')
+ {
+ $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').")";
+ }
else
{
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")";
}
- if ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
+ if($dates > 0 && $type == 'loan'){
+ $sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)";
+ }
+ elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
{
if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date;
if (empty($datefieldname)) return 'Error this object has no date field defined';
$sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)";
}
- if ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
+
+ if($datee > 0 && $type == 'loan'){
+ $sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)";
+ }
+ elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
{
if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date;
if (empty($datefieldname)) return 'Error this object has no date field defined';
@@ -1211,7 +1222,7 @@ class Project extends CommonObject
* Return array of projects a user has permission on, is affected to, or all projects
*
* @param User $user User object
- * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts
+ * @param int $mode 0=All project I have permission on (assigned to me or public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts
* @param int $list 0=Return array, 1=Return string list
* @param int $socid 0=No filter on third party, id of third party
* @param string $filter additionnal filter on project (statut, ref, ...)
@@ -1224,9 +1235,17 @@ class Project extends CommonObject
$sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref";
$sql.= " FROM " . MAIN_DB_PREFIX . "projet as p";
- if ($mode == 0 || $mode == 1)
+ if ($mode == 0)
{
- $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec";
+ $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id = p.rowid";
+ }
+ elseif ($mode == 1)
+ {
+ $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec";
+ }
+ elseif ($mode == 2)
+ {
+ // No filter. Use this if user has permission to see all project
}
$sql.= " WHERE p.entity IN (".getEntity('project').")";
// Internal users must see project he is contact to even if project linked to a third party he can't see.
@@ -1251,13 +1270,12 @@ class Project extends CommonObject
if ($mode == 0)
{
- $sql.= " AND ec.element_id = p.rowid";
$sql.= " AND ( p.public = 1";
$sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")";
$sql.= " AND ec.fk_socpeople = ".$user->id.")";
$sql.= " )";
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
$sql.= " AND ec.element_id = p.rowid";
$sql.= " AND (";
@@ -1265,7 +1283,7 @@ class Project extends CommonObject
$sql.= " AND ec.fk_socpeople = ".$user->id.")";
$sql.= " )";
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
// No filter. Use this if user has permission to see all project
}
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 8ae94aa536b..8588807e869 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -49,6 +49,7 @@ if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/exp
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
+if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php';
if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
@@ -650,6 +651,31 @@ foreach ($listofreferent as $key => $value)
$total_ht_by_line = price2num($tmp['amount'], 'MT');
}
}
+ elseif ($key == 'loan'){
+ if((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)){
+ // Get total loan
+ $total_ht_by_line = -$element->capital;
+ }
+ else{
+ // Get loan schedule according to date filter
+ $total_ht_by_line = 0;
+ $loanScheduleStatic = new LoanSchedule($element->db);
+ $loanScheduleStatic->fetchAll($element->id);
+ if(!empty($loanScheduleStatic->lines)){
+ foreach($loanScheduleStatic->lines as $loanSchedule){
+ /**
+ * @var $loanSchedule LoanSchedule
+ */
+ if( ($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined
+ || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now()
+ || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
+ ){
+ $total_ht_by_line = -$loanSchedule->amount_capital;
+ }
+ }
+ }
+ }
+ }
else $total_ht_by_line = $element->total_ht;
// Define $total_ttc_by_line
@@ -661,6 +687,9 @@ foreach ($listofreferent as $key => $value)
$defaultvat = get_default_tva($mysoc, $mysoc);
$total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT');
}
+ elseif ($key == 'loan'){
+ $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr
+ }
else $total_ttc_by_line = $element->total_ttc;
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
@@ -837,11 +866,13 @@ foreach ($listofreferent as $key => $value)
// Amount HT
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ' | '.$langs->trans("AmountHT").' | ';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Amount").' | ';
- if (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").' | ';
+ if ($key == 'loan') print ''.$langs->trans("LoanCapital").' | ';
+ elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").' | ';
else print ' | ';
// Amount TTC
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountTTC").' | ';
- if (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").' | ';
+ if ($key == 'loan') print ''.$langs->trans("RemainderToPay").' | ';
+ elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").' | ';
else print ' | ';
// Status
if (in_array($tablename, array('projet_task'))) print ''.$langs->trans("ProgressDeclared").' | ';
@@ -936,6 +967,10 @@ foreach ($listofreferent as $key => $value)
print $element->getNomUrl(1, 'withproject', 'time');
print ' - '.dol_trunc($element->label, 48);
}
+ elseif ($key == 'loan'){
+ print $element->getNomUrl(1);
+ print ' - '.dol_trunc($element->label, 48);
+ }
else print $element->getNomUrl(1);
$element_doc = $element->element;
@@ -985,6 +1020,10 @@ foreach ($listofreferent as $key => $value)
if (empty($date)) $date = $element->datev;
}
}
+ elseif ($key == 'loan'){
+ $date = $element->datestart;
+ }
+
print '';
if ($tablename == 'actioncomm')
{
@@ -1067,6 +1106,7 @@ foreach ($listofreferent as $key => $value)
$othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled"));
}
}
+ elseif ($key == 'loan') $total_ht_by_line = $element->capital;
else
{
$total_ht_by_line = $element->total_ht;
@@ -1114,6 +1154,7 @@ foreach ($listofreferent as $key => $value)
$othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled"));
}
}
+ elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment();
else
{
$total_ttc_by_line = $element->total_ttc;
@@ -1223,7 +1264,8 @@ foreach ($listofreferent as $key => $value)
print ' | ';
if (empty($value['disableamount']))
{
- if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht);
+ if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc);
+ elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht);
}
print ' | ';
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).' | ';
@@ -1231,7 +1273,8 @@ foreach ($listofreferent as $key => $value)
print '';
if (empty($value['disableamount']))
{
- if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc);
+ if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc);
+ elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc);
}
print ' | ';
print ' | ';
diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php
index 26758f52ab0..62070e3b31e 100644
--- a/htdocs/user/perms.php
+++ b/htdocs/user/perms.php
@@ -89,9 +89,13 @@ if (empty($reshook)) {
if ($action == 'addrights' && $caneditperms) {
$edituser = new User($db);
$edituser->fetch($object->id);
- $edituser->addrights($rights, $module, '', $entity);
+ $result = $edituser->addrights($rights, $module, '', $entity);
+ if ($result < 0)
+ {
+ setEventMessages($edituser->error, $edituser->errors, 'errors');
+ }
- // Si on a touche a ses propres droits, on recharge
+ // If we are changing our own permissions, we reload
if ($object->id == $user->id) {
$user->clearrights();
$user->getrights();
@@ -105,9 +109,13 @@ if (empty($reshook)) {
if ($action == 'delrights' && $caneditperms) {
$edituser = new User($db);
$edituser->fetch($object->id);
- $edituser->delrights($rights, $module, '', $entity);
+ $result = $edituser->delrights($rights, $module, '', $entity);
+ if ($result < 0)
+ {
+ setEventMessages($edituser->error, $edituser->errors, 'errors');
+ }
- // Si on a touche a ses propres droits, on recharge
+ // If we are changing our own permissions, we reload
if ($object->id == $user->id) {
$user->clearrights();
$user->getrights();