';
- $sql = "SELECT p.rowid as id, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
+ $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
$sql .= ", cls.code as opp_status_code";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
$sql .= " WHERE p.fk_soc = ".$object->id;
+ $sql .= " AND p.entity IN (".getEntity('project').")";
$sql .= " ORDER BY p.dateo DESC";
$result=$db->query($sql);
@@ -799,7 +801,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin
print '';
// Opp status
print '| ';
- if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code);
+ if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code);
print ' | ';
// Opp percent
print '';
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 58fc5b78c9f..f96d9667606 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -239,7 +239,7 @@ class modProduct extends DolibarrModules
'pr.date_price'=>"product");
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product';
+ $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
$this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
}
diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php
index f4df5f3c5f8..7ebf701d3d5 100644
--- a/htdocs/fichinter/stats/index.php
+++ b/htdocs/fichinter/stats/index.php
@@ -30,7 +30,7 @@ $WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
$mode='customer';
-if ($mode == 'customer' && ! $user->rights->ficheinter->lire) accessforbidden();
+if (! $user->rights->ficheinter->lire) accessforbidden();
$userid=GETPOST('userid','int');
$socid=GETPOST('socid','int');
@@ -50,7 +50,7 @@ $endyear=$year;
$object_status=GETPOST('object_status');
// Load translation files required by the page
-$langs->loadLangs(array("interventions","suppliers","companies","other"));
+$langs->loadLangs(array('interventions', 'companies', 'other', 'suppliers'));
/*
@@ -60,11 +60,8 @@ $langs->loadLangs(array("interventions","suppliers","companies","other"));
$form=new Form($db);
$objectstatic=new FichInter($db);
-if ($mode == 'customer')
-{
- $title=$langs->trans("InterventionStatistics");
- $dir=$conf->ficheinter->dir_temp;
-}
+$title=$langs->trans("InterventionStatistics");
+$dir=$conf->ficheinter->dir_temp;
llxHeader('', $title);
@@ -77,19 +74,18 @@ if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_sta
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
-//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png';
- if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png';
+ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filenamenb = $dir.'/interventionsnbinyear-'.$year.'.png';
- if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png';
+ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png';
}
$px1 = new DolGraph();
@@ -121,20 +117,17 @@ if (! $mesg)
// Build graphic amount of object
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
-//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png';
- if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png';
- if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png';
+ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filenameamount = $dir.'/interventionsamountinyear-'.$year.'.png';
- if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png';
- if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$year.'.png';
+ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png';
}
$px2 = new DolGraph();
@@ -169,14 +162,12 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png';
- if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png';
- if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$user->id.'-'.$year.'.png';
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png';
}
else
{
$filename_avg = $dir.'/interventionsaverage-'.$year.'.png';
- if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png';
- if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$year.'.png';
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png';
}
$px3 = new DolGraph();
@@ -219,13 +210,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
$h=0;
$head = array();
-$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode;
+$head[$h][0] = DOL_URL_ROOT . '/fichinter/stats/index.php';
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
-if ($mode == 'customer') $type='order_stats';
-if ($mode == 'supplier') $type='supplier_order_stats';
+$type = 'fichinter_stats';
complete_head_from_modules($conf,$langs,null,$head,$h,$type);
@@ -244,9 +234,8 @@ print '';
print ' | '.$langs->trans("Filter").' | ';
// Company
print '| '.$langs->trans("ThirdParty").' | ';
- if ($mode == 'customer') $filter='s.client in (1,2,3)';
- if ($mode == 'supplier') $filter='s.fournisseur = 1';
- print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
+ $filter = 's.client in (1,2,3)';
+ print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"');
print ' | ';
// User
print '| '.$langs->trans("CreatedBy").' | ';
@@ -288,7 +277,8 @@ foreach ($data as $val)
{
$year = $val['year'];
while (! empty($year) && $oldyear > $year+1)
- { // If we have empty year
+ {
+ // If we have empty year
$oldyear--;
print ' | ';
diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php
index 8ce4b7a0c0b..55362ac4218 100644
--- a/htdocs/margin/tabs/thirdpartyMargins.php
+++ b/htdocs/margin/tabs/thirdpartyMargins.php
@@ -203,6 +203,11 @@ if ($socid > 0)
$marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ;
$markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ;
+ $sign = '';
+ if ($objp->type == Facture::TYPE_CREDIT_NOTE){
+ $sign = '-';
+ }
+
print ' ';
print '| ';
$invoicestatic->id=$objp->facid;
@@ -213,11 +218,11 @@ if ($socid > 0)
print dol_print_date($db->jdate($objp->datef),'day')." | ";
print "".price($objp->selling_price, null, null, null, null, $rounding)." | \n";
print "".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)." | \n";
- print "".price($objp->marge, null, null, null, null, $rounding)." | \n";
+ print "".$sign.price($objp->marge, null, null, null, null, $rounding)." | \n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
- print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")." | \n";
+ print "".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")." | \n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
- print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")." | \n";
+ print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")." | \n";
print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).' | ';
print " \n";
$i++;
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 87d82ffe03d..a96939f082c 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -600,7 +600,7 @@ if (! empty($arrayfields['p.public']['checked']))
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '';
- print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100');
+ print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100');
print ' | ';
}
if (! empty($arrayfields['p.opp_amount']['checked']))
@@ -809,7 +809,7 @@ while ($i < min($num,$limit))
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '';
- if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code);
+ if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code);
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php
index 31f860dbf9b..ff8799d4f1c 100644
--- a/htdocs/projet/tasks.php
+++ b/htdocs/projet/tasks.php
@@ -477,7 +477,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print '| '.$langs->trans("AffectedTo").' | ';
$contactsofproject=(! empty($object->id)?$object->getListContactId('internal'):'');
- if (count($contactsofproject))
+ if (is_array($contactsofproject) && count($contactsofproject))
{
print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300');
}
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 4221e35706a..4a4612a1d79 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -948,6 +948,24 @@ class Societe extends CommonObject
// We don't check when update called during a create because verify was already done.
// For a merge, we suppose source data is clean and a customer code of a deleted thirdparty must be accepted into a target thirdparty with empty code without duplicate error
$result = $this->verify();
+
+ // If there is only one error and error is ErrorBadCustomerCodeSyntax and we don't change customer code, we allow the update
+ // So we can update record that were using and old numbering rule.
+ if (is_array($this->errors))
+ {
+ if (in_array('ErrorBadCustomerCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_client == $this->code_client)
+ {
+ if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message
+ }
+ if (in_array('ErrorBadSupplierCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_fournisseur == $this->code_fournisseur)
+ {
+ if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message
+ }
+ if (empty($this->errors)) // If there is no more error, we can make like if there is no error at all
+ {
+ $result = 0;
+ }
+ }
}
if ($result >= 0)
@@ -1509,7 +1527,7 @@ class Societe extends CommonObject
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
-
+
// Remove links to subsidiaries companies
if (! $error)
{
| |