| '.$langs->trans("MembersNature").' | '.$object->getmorphylib($object->morphy).' | '; + print '||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("MembersNature").' | '; + print $object->getmorphylib($object->morphy, 1); + print ' | '; print '||||||||||||||||||||||||||||||||||||||||||||
| '.$form->textwithpicto($langs->trans("SubscriptionRequired"), $langs->trans("SubscriptionRequiredDesc")).' | ';
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 1aafddfc693..a839f0573ab 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -35,6 +35,14 @@
// Load Dolibarr environment
require '../main.inc.php';
+/**
+ * @var Conf $conf
+ * @var DoliDB $db
+ * @var HookManager $hookmanager
+ * @var Societe $mysoc
+ * @var Translate $langs
+ * @var User $user
+ */
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -71,15 +79,6 @@ if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
}
-/**
- * @var Conf $conf
- * @var DoliDB $db
- * @var HookManager $hookmanager
- * @var Societe $mysoc
- * @var Translate $langs
- * @var User $user
- */
-
// Load translation files required by the page
$langs->loadLangs(array('companies', 'banks', 'commercial'));
@@ -831,17 +830,17 @@ if ($object->id > 0) {
$warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
}
$text = $langs->trans("CurrentOutstandingBill");
+
$link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
$icon = 'bill';
+ $boxstattmp = ' ';
+ $boxstattmp .= ''.img_object("", $icon).' '.$text.' ';
if ($link) {
- $boxstat .= '';
- }
- $boxstat .= ''; + $boxstattmp .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstattmp .= ' ';
- $boxstat .= ''.img_object("", $icon).' '.$text.' ';
- if ($link) {
- $boxstat .= '';
+ $boxstat .= dolButtonToOpenUrlInDialogPopup('popupoutstanding', $text, $boxstattmp, '/compta/recap-compta.php?socid='.$object->id, '', '');
+ } else {
+ $boxstat .= $boxstattmp;
}
$tmp = $object->getOutstandingBills('customer', 1);
@@ -852,21 +851,67 @@ if ($object->id > 0) {
$warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
}
$text = $langs->trans("CurrentOutstandingBillLate");
+
$link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
$icon = 'bill';
+ $boxstattmp = ''; - $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat .= ' ';
+ $boxstattmp .= ''.img_object("", $icon).' '.$text.' ';
if ($link) {
- $boxstat .= '';
- }
- $boxstat .= ''; + $boxstattmp .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstattmp .= ' ';
- $boxstat .= ''.img_object("", $icon).' '.$text.' ';
- if ($link) {
- $boxstat .= '';
+ $boxstat .= dolButtonToOpenUrlInDialogPopup('popupoutstanding', $text, $boxstattmp, '/compta/recap-compta.php?socid='.$object->id, '', '');
+ } else {
+ $boxstat .= $boxstattmp;
}
}
}
+ // Margins
+ if (isModEnabled('margin') && $user->hasRight('margin', 'liretous')) {
+ // Box margin
+ $sql = "SELECT ";
+ $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
+ $sql .= " sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // always positive
+ $sql .= " sum(d.total_ht - (".$db->ifsql('f.type = '.Facture::TYPE_CREDIT_NOTE, '-1', '1')." * (d.buy_price_ht * d.qty * (d.situation_percent / 100)))) as marge";
+ $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
+ $sql .= " ".MAIN_DB_PREFIX."facturedet as d";
+ $sql .= " WHERE f.fk_soc = ".((int) $id);
+ $sql .= " AND f.fk_statut > 0";
+ $sql .= " AND f.entity IN (".getEntity('invoice').")";
+ $sql .= " AND d.fk_facture = f.rowid";
+ $sql .= " AND d.buy_price_ht IS NOT NULL";
+ // We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report.
+ // We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredictable.
+ if (getDolGlobalInt('ForceBuyingPriceIfNull') == 2) {
+ $sql .= " AND d.buy_price_ht <> 0";
+ }
+
+ $marginTotal = 0;
+
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ if ($obj) {
+ $marginTotal = $obj->marge;
+ }
+ }
+
+ $text = $langs->transnoentitiesnoconv("Margins");
+
+ $link = DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$object->id;
+ $icon = 'margin';
+ $boxstattmp = ''; - $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat .= ' ';
+ $boxstattmp .= ''.img_object("", $icon).' '.$text.' ';
+ if ($link) {
+ $boxstat .= dolButtonToOpenUrlInDialogPopup('popupmargin', $text, $boxstattmp, '/margin/tabs/thirdpartyMargins.php?socid='.$object->id, '', '');
+ } else {
+ $boxstat .= $boxstattmp;
+ }
+ }
+
+
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);
if (empty($reshook)) {
@@ -880,6 +925,7 @@ if ($object->id > 0) {
print $boxstat;
+
/*
* Latest proposals
*/
diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php
index d379313ef11..f688fe68817 100644
--- a/htdocs/compta/recap-compta.php
+++ b/htdocs/compta/recap-compta.php
@@ -27,10 +27,6 @@
// Load Dolibarr environment
require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
-
/**
* @var Conf $conf
* @var DoliDB $db
@@ -38,12 +34,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
* @var Translate $langs
* @var User $user
*/
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
// Load translation files required by the page
-$langs->load("companies");
-if (isModEnabled('invoice')) {
- $langs->load("bills");
-}
+$langs->loadLangs(array("companies", "bills"));
+
+$action = GETPOST('action');
+$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
$id = GETPOST('id') ? GETPOSTINT('id') : GETPOSTINT('socid');
@@ -124,12 +123,17 @@ if ($id > 0) {
if ($id > 0) {
$param .= '&socid='.$id;
}
+ if ($dol_openinpopup) {
+ $param .= '&dol_openinpopup='.urlencode($dol_openinpopup);
+ }
- $head = societe_prepare_head($object);
+ if (empty($dol_openinpopup)) {
+ $head = societe_prepare_head($object);
- print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company');
- dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1);
- print dol_get_fiche_end();
+ print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company');
+ dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1);
+ print dol_get_fiche_end();
+ }
if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
// Invoice list
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 896b4a70f45..1c16ec8f89a 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7823,10 +7823,12 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
$cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur);
}
}
- $output = $cursymbolbefore . $output . $end . ($cursymbolafter ? ' ' : '') . $cursymbolafter;
if ($form) {
$output = preg_replace('/\s/', ' ', $output);
+ $output = $cursymbolbefore . $output . $end . ($cursymbolafter ? ' '.$cursymbolafter.'' : '');
$output = preg_replace('/\'/', ''', $output);
+ } else {
+ $output = $cursymbolbefore . $output . $end . ($cursymbolafter ? ' '.$cursymbolafter : '');
}
return $output;
diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php
index 7bde887ad78..119c2cdab99 100644
--- a/htdocs/core/modules/modMargin.class.php
+++ b/htdocs/core/modules/modMargin.class.php
@@ -88,7 +88,6 @@ class modMargin extends DolibarrModules
// New pages on tabs
$this->tabs = array(
'product:+margin:Margins:margins:$user->hasRight("margins","liretous"):/margin/tabs/productMargins.php?id=__ID__',
- 'thirdparty:+margin:Margins:margins:empty($user->socid) && $user->hasRight("margins","liretous") && ($object->client > 0):/margin/tabs/thirdpartyMargins.php?socid=__ID__'
);
diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php
index 15b010ddc9a..c4826b2a6c8 100644
--- a/htdocs/margin/tabs/thirdpartyMargins.php
+++ b/htdocs/margin/tabs/thirdpartyMargins.php
@@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$langs->loadLangs(array("companies", "bills", "products", "margins"));
$action = GETPOST('action');
+$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
// Security check
$socid = GETPOSTINT('socid');
@@ -131,6 +132,7 @@ if (empty($search_invoice_date_start) && empty($search_invoice_date_end) && !GET
}
}
+
/*
* View
*/
@@ -149,6 +151,9 @@ $param = "&socid=".$socid;
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.((int) $limit);
}
+if ($dol_openinpopup) {
+ $param .= '&dol_openinpopup='.urlencode($dol_openinpopup);
+}
if ($search_invoice_date_start) {
$param .= '&search_invoice_date_start_day='.dol_print_date($search_invoice_date_start, '%d').'&search_invoice_date_start_month='.dol_print_date($search_invoice_date_start, '%m').'&search_invoice_date_start_year='.dol_print_date($search_invoice_date_start, '%Y');
}
@@ -164,78 +169,79 @@ if ($socid > 0) {
$object = new Societe($db);
$object->fetch($socid);
- // Show tabs
+ if (empty($dol_openinpopup)) {
+ // Show tabs
- $head = societe_prepare_head($object);
+ $head = societe_prepare_head($object);
- print dol_get_fiche_head($head, 'margin', $langs->trans("ThirdParty"), -1, 'company');
+ print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company');
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
- dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
+ dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
- print ''; + $boxstattmp .= ''.price($marginTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstattmp .= ' ';
+ print ' ';
- print '';
- print ' ';
- print '';
-
- print dol_get_fiche_end();
-
- print '
'; } - // Total Margin - print ' '.$langs->trans("TotalMargin").' | ';
- print ''; // set by jquery (see below)
- print ' | '.$langs->trans("MarginRate").' | ';
- print ''; // set by jquery (see below)
- print ' | '.$langs->trans("MarkRate").' | ';
- print ''; // set by jquery (see below)
- print ' | '; - - // TODO Remove the DISTINCT - $sql = "SELECT DISTINCT s.nom, s.rowid as socid, s.code_client,"; + $sql = "SELECT s.nom, s.rowid as socid, s.code_client,"; $sql .= " f.rowid as facid, f.ref, f.total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive @@ -263,6 +269,7 @@ if ($socid > 0) { } $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type"; + // TODO: calculate total to display then restore pagination $sql .= $db->order($sortfield, $sortorder); @@ -277,6 +284,7 @@ if ($socid > 0) { print ' | ||||||||||||||||||||||||||||||||||||||