';
diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php
index a23d5bdc2c2..434fab6f373 100644
--- a/htdocs/compta/facture/class/facturestats.class.php
+++ b/htdocs/compta/facture/class/facturestats.class.php
@@ -84,8 +84,8 @@ class FactureStats extends Stats
$this->where.=" AND f.fk_soc = ".$this->socid;
}
if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid;
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2)";
- else $this->where.= " AND f.type IN (0,1,2,3)";
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2,5)";
+ else $this->where.= " AND f.type IN (0,1,2,3,5)";
}
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 5442203a348..8e4ddc2a3eb 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -464,7 +464,7 @@ if ($search_month > 0)
if ($search_year > 0 && empty($search_day))
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
else if ($search_year > 0 && ! empty($search_day))
- $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $serch_year))."'";
+ $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
else
$sql.= " AND date_format(f.datef, '%m') = '".$search_month."'";
}
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 2661391d58a..758c0803a10 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -1303,6 +1303,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
global $param;
+ dol_include_once('/comm/action/class/actioncomm.class.php');
+
// Check parameters
if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('','BadParameter');
@@ -1351,6 +1353,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
}
+ //TODO check how ot work with new table actioncomm_resources and multiple contact affectation
if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id;
// Condition on actioncode
if (! empty($actioncode))
@@ -1387,6 +1390,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
{
$obj = $db->fetch_object($resql);
+ $contactaction = new ActionComm($db);
+ $contactaction->id=$obj->id;
+ $result = $contactaction->fetchResources();
+ if ($result<0) {
+ dol_print_error($db);
+ setEventMessage("company.lib::show_actions_done Error fetch ressource",'errors');
+ }
+
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
//if ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
$tododone='';
@@ -1408,6 +1419,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
'userphoto'=>$obj->user_photo,
'contact_id'=>$obj->fk_contact,
+ 'socpeopleassigned' => $contactaction->socpeopleassigned,
'lastname'=>$obj->lastname,
'firstname'=>$obj->firstname,
'fk_element'=>$obj->fk_element,
@@ -1561,7 +1573,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder);
$out.=getTitleFieldOfList('');
- $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], 'a.fk_contact', '', $param, '', $sortfield, $sortorder);
+ $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder);
$out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch ');
$out.='';
@@ -1715,10 +1727,28 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$contactstatic->firstname=$histo[$key]['firstname'];
$contactstatic->id=$histo[$key]['contact_id'];
$out.='
'.$contactstatic->getNomUrl(1,'',10).' | ';
- }
- else
- {
- $out.='
| ';
+ } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
+ $out .= '
';
+ foreach ( $histo[$key]['socpeopleassigned'] as $cid => $Tab ) {
+ $contact = new Contact($db);
+ $result = $contact->fetch($cid);
+
+ if ($result < 0)
+ dol_print_error($db, $contact->error);
+
+ if ($result > 0) {
+ $out .= $contact->getNomUrl(1);
+ if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
+ if (! empty($contact->phone_pro))
+ $out .= '(' . dol_print_phone($contact->phone_pro) . ')';
+ }
+ $out .= '';
+ }
+ }
+ $out .= ' | ';
+ }
+ else {
+ $out.='
| ';
}
// Status
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 100c1a3d47f..512a4158ef0 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5177,7 +5177,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
}
// Si (vendeur en France et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle
- if (! empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->isACompany())
+ if (! empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->isACompany())
{
return get_product_vat_for_country($idprod,$thirdparty_seller,$idprodfournprice);
}
diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php
index 94eff1911e7..e6c51e2217d 100644
--- a/htdocs/margin/tabs/productMargins.php
+++ b/htdocs/margin/tabs/productMargins.php
@@ -138,9 +138,9 @@ if ($id > 0 || ! empty($ref))
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,";
$sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive
- $sql.= " sum(d.qty) as qty,";
- $sql.= " sum(d.qty * d.buy_price_ht) as buying_price,"; // always positive
- $sql.= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // always positive
+ $sql.= " IF(f.type = 2, -1, 1) * sum(d.qty) as qty,"; // not always positive in case of Credit note
+ $sql.= " IF(f.type = 2, -1, 1) * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note
+ $sql.= " IF(f.type = 2, -1, 1) * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";