diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 42b5fc4056a..eefa6a1fc24 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -39,6 +39,7 @@ $langs->load("products");
$langs->load("members");
$langs->load("projects");
$langs->load("hrm");
+$langs->load("agenda");
if (! $user->admin) accessforbidden();
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 654bfd4c0d8..f03242a8868 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -670,6 +670,7 @@ class Propal extends CommonObject
//Fetch current line from the database and then clone the object and set it in $oldline property
$line = new PropaleLigne($this->db);
$line->fetch($rowid);
+ $line->fetch_optionals(); // Fetch extrafields for oldcopy
$staticline = clone $line;
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 0e2ac88fe83..93b2b63070f 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -133,7 +133,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search
$fieldstosearchall = array(
'f.facnumber'=>'Ref',
'f.ref_client'=>'RefCustomer',
- 'fd.description'=>'Description',
+ 'pd.description'=>'Description',
's.nom'=>"ThirdParty",
'f.note_public'=>'NotePublic',
);
@@ -156,7 +156,7 @@ $arrayfields=array(
'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
- 'am'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
+ 'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
@@ -253,7 +253,9 @@ $sql.= ' f.datec as date_creation, f.tms as date_update,';
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name";
-if (! $sall) $sql.= ', SUM(pf.amount) as am'; // To be able to sort on status
+// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
+// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
+if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@@ -267,7 +269,6 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s
$sql.= ', '.MAIN_DB_PREFIX.'facture as f';
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)";
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
-else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid';
if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture';
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
// We'll need this table joined to the select in order to filter by sale
@@ -655,8 +656,8 @@ if ($resql)
if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'],$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder);
- if (! empty($arrayfields['am']['checked'])) print_liste_field_titre($arrayfields['am']['label'],$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder);
- if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'rtp','',$param,'align="right"',$sortfield,$sortorder);
+ if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder);
+ if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@@ -675,7 +676,7 @@ if ($resql)
print $hookmanager->resPrint;
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
- if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder);
+ if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye,type,dynamount_payed","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "\n";
@@ -786,7 +787,7 @@ if ($resql)
print ' ';
print '';
}
- if (! empty($arrayfields['am']['checked']))
+ if (! empty($arrayfields['dynamount_payed']['checked']))
{
print '
';
print ' ';
@@ -1025,9 +1026,9 @@ if ($resql)
$totalarray['totalttc'] += $obj->total_ttc;
}
- if (! empty($arrayfields['am']['checked']))
+ if (! empty($arrayfields['dynamount_payed']['checked']))
{
- print ''.(! empty($paiement)?price($paiement,0,$langs):' ').' ';
+ print ''.(! empty($paiement)?price($paiement,0,$langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
$totalarray['totalam'] += $paiement;
@@ -1035,7 +1036,7 @@ if ($resql)
if (! empty($arrayfields['rtp']['checked']))
{
- print ''.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').' ';
+ print ''.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
$totalarray['totalrtp'] += $remaintopay;
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index 8fd4eee5339..3c820099e58 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -171,7 +171,7 @@ if ($resql)
print '';
print ' ';
print '';
- print ' ';
+ print ' ';
print ' ';
print ' ';
print '';
@@ -190,7 +190,7 @@ if ($resql)
print " ";
// Num ref cheque
- print '';
+ print ' ';
$checkdepositstatic->id=$objp->rowid;
$checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid);
$checkdepositstatic->statut=$objp->statut;
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index b39e5c47f7f..6f780de554b 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -52,6 +52,17 @@ if ($user->societe_id > 0) $socid = $user->societe_id;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
+$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0; }
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortfield) $sortfield='s.nom, s.rowid';
+if (! $sortorder) $sortorder='ASC';
+
// Date range
$year=GETPOST("year");
if (empty($year))
@@ -155,12 +166,23 @@ if (! empty($conf->accounting->enabled))
}
// Show report array
+$param='&modecompta='.$modecompta;
+if ($date_startday) $param.='&date_startday='.$date_startday;
+if ($date_startmonth) $param.='&date_startmonth='.$date_startmonth;
+if ($date_startyear) $param.='&date_startyear='.$date_startyear;
+if ($date_endday) $param.='&date_endday='.$date_endday;
+if ($date_endmonth) $param.='&date_endmonth='.$date_endmonth;
+if ($date_endyear) $param.='&date_endyear='.$date_startyear;
+
print '';
print '';
-print ' ';
+print_liste_field_titre('');
+print_liste_field_titre($langs->trans("Name"), $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder);
if ($modecompta == 'CREANCES-DETTES')
- print "".$langs->trans("AmountHT")." ";
-print "".$langs->trans("AmountTTC")." ";
+{
+ print_liste_field_titre($langs->trans("AmountHT"), $_SERVER["PHP_SELF"],'amount_ht','',$param,'align="right"',$sortfield,$sortorder);
+}
+print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"],'amount_ttc','',$param,'align="right"',$sortfield,$sortorder);
print " \n";
/*
@@ -202,7 +224,7 @@ else
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY s.nom, s.rowid";
-$sql.= " ORDER BY s.nom, s.rowid";
+$sql.= $db->order($sortfield, $sortorder);
dol_syslog("get customer invoices", LOG_DEBUG);
$result = $db->query($sql);
@@ -328,7 +350,7 @@ else
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY s.nom, s.rowid";
-$sql .= " ORDER BY s.nom, s.rowid";
+$sql.= $db->order($sortfield, $sortorder);
print ''.$langs->trans("SuppliersInvoices").' ';
@@ -413,7 +435,11 @@ else
}
$sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle, c.id";
-$sql.= " ORDER BY c.libelle, c.id";
+$newsortfield = $sortfield;
+if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
+if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=0", LOG_DEBUG);
$result=$db->query($sql);
@@ -473,8 +499,6 @@ if ($modecompta == 'CREANCES-DETTES')
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity;
- $sql.= " GROUP BY c.libelle, c.id";
- $sql.= " ORDER BY c.libelle, c.id";
}
else
{
@@ -488,9 +512,13 @@ else
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity;
- $sql.= " GROUP BY c.libelle, c.id";
- $sql.= " ORDER BY c.libelle, c.id";
}
+$sql.= " GROUP BY c.libelle, c.id";
+$newsortfield = $sortfield;
+if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
+if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=1", LOG_DEBUG);
$result=$db->query($sql);
@@ -574,8 +602,12 @@ if (! empty($conf->salaries->enabled))
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
- $sql.= " ORDER BY u.firstname";
-
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'u.firstname, u.lastname';
+ if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+ if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+ $sql.= $db->order($newsortfield, $sortorder);
+
dol_syslog("get payment salaries");
$result=$db->query($sql);
$subtotal_ht = 0;
@@ -642,7 +674,7 @@ if (! empty($conf->expensereport->enabled))
$column='p.date_valid';
} else {
- $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
+ $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht, sum(p.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
@@ -656,55 +688,59 @@ if (! empty($conf->expensereport->enabled))
print ''.$langs->trans("ExpenseReport").' ';
if (! empty($date_start) && ! empty($date_end))
+ {
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
+ }
+
+ $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref';
+ $sql.= $db->order($newsortfield, $sortorder);
- $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
- $sql.= " ORDER BY p.ref";
-
- dol_syslog("get expense report outcome");
- $result=$db->query($sql);
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($result)
+ dol_syslog("get expense report outcome");
+ $result=$db->query($sql);
+ $subtotal_ht = 0;
+ $subtotal_ttc = 0;
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ $var=true;
+ if ($num)
{
- $num = $db->num_rows($result);
- $var=true;
- if ($num)
+ while ($obj = $db->fetch_object($result))
{
- while ($obj = $db->fetch_object($result))
- {
- $total_ht -= $obj->amount_ht;
- $total_ttc -= $obj->amount_ttc;
- $subtotal_ht += $obj->amount_ht;
- $subtotal_ttc += $obj->amount_ttc;
+ $total_ht -= $obj->amount_ht;
+ $total_ttc -= $obj->amount_ttc;
+ $subtotal_ht += $obj->amount_ht;
+ $subtotal_ttc += $obj->amount_ttc;
- $var = !$var;
- print " ";
-
- print "".$langs->trans("ExpenseReport")." userid."\">".$obj->firstname." ".$obj->lastname." \n";
-
- if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount_ht).' ';
- print ''.price(-$obj->amount_ttc).' ';
- print ' ';
- }
- }
- else
- {
$var = !$var;
print " ";
- print ''.$langs->trans("None").' ';
+
+ print "".$langs->trans("ExpenseReport")." userid."\">".$obj->firstname." ".$obj->lastname." \n";
+
+ if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount_ht).' ';
+ print ''.price(-$obj->amount_ttc).' ';
print ' ';
}
}
else
{
- dol_print_error($db);
- }
- print '';
- if ($modecompta == 'CREANCES-DETTES')
- print ''.price(-$subtotal_ht).' ';
- print ''.price(-$subtotal_ttc).' ';
+ $var = !$var;
+ print " ";
+ print ''.$langs->trans("None").' ';
print ' ';
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ print '';
+ if ($modecompta == 'CREANCES-DETTES')
+ print ''.price(-$subtotal_ht).' ';
+ print ''.price(-$subtotal_ttc).' ';
+ print ' ';
}
/*
@@ -733,7 +769,11 @@ if (! empty($conf->don->enabled))
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
- $sql.= " ORDER BY p.societe, p.firstname, p.lastname, dm";
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
+ if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+ if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+ $sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get dunning");
$result=$db->query($sql);
@@ -808,7 +848,11 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
- $sql.= " ORDER BY dm";
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
+ if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+ if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+ $sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat to pay", LOG_DEBUG);
$result=$db->query($sql);
@@ -853,7 +897,11 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
- $sql.= " ORDER BY dm";
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
+ if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+ if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+ $sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat received back", LOG_DEBUG);
$result=$db->query($sql);
@@ -897,7 +945,11 @@ else
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
- $sql.= " ORDER BY dm";
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
+ if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+ if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+ $sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat really paid", LOG_DEBUG);
$result=$db->query($sql);
@@ -938,7 +990,11 @@ else
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
- $sql.= " ORDER BY dm";
+ $newsortfield = $sortfield;
+ if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
+ if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
+ if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
+ $sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat really received back", LOG_DEBUG);
$result=$db->query($sql);
diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php
index f41978eb757..62cca5a0f20 100644
--- a/htdocs/cron/admin/cron.php
+++ b/htdocs/cron/admin/cron.php
@@ -88,9 +88,20 @@ print "";
print '';
print ''.$langs->trans("KeyForCronAccess").' ';
-print ' ';
-if (! empty($conf->use_javascript_ajax))
- print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
+$disabled='';
+if (! empty($conf->global->CRON_DISABLE_KEY_CHANGE)) $disabled=' disabled="disabled"';
+print '';
+if (empty($conf->global->CRON_DISABLE_KEY_CHANGE))
+{
+ print ' ';
+ if (! empty($conf->use_javascript_ajax))
+ print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
+}
+else
+{
+ print (! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'');
+ print ' ';
+}
print ' ';
print ' ';
print ' ';
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 06b7fb94cc0..66f516cca48 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -2225,7 +2225,8 @@ if ($action != 'create' && $action != 'edit')
// If bank module is not used
if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5)
{
- if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0)
+ //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0)
+ if ($object->paid == 0)
{
print '";
}
diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php
index 3cf520c6739..d55e262e2e4 100644
--- a/htdocs/expensereport/export_csv.php
+++ b/htdocs/expensereport/export_csv.php
@@ -128,6 +128,7 @@ if (isset($_POST['action']))
$sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
+ $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')';
$sql.= " ORDER BY d.rowid";
$result = $db->query($sql);
diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php
index 8d19a8e9f6d..0bf9c7cd30c 100644
--- a/htdocs/expensereport/index.php
+++ b/htdocs/expensereport/index.php
@@ -147,7 +147,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u"
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE u.rowid = d.fk_user_author";
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND d.fk_user_author IN ('.join(',',$childids).')';
-//$sql.= " AND d.entity = ".$conf->entity;
+$sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')';
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND d.fk_user_author = ".$socid;
$sql.= $db->order($sortfield,$sortorder);
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index d3189cbd577..935faab9983 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -203,7 +203,7 @@ $sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields as ef on (d.rowid = ef.fk_object)";
$sql.= ", ".MAIN_DB_PREFIX."user as u";
-$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity = ".$conf->entity;
+$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport', 1).")";
// Search all
if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
// Ref
diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php
index 19d5b3206f7..f9ba5af3dc0 100644
--- a/htdocs/expensereport/payment/card.php
+++ b/htdocs/expensereport/payment/card.php
@@ -199,7 +199,7 @@ $disable_delete = 0;
$sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er';
$sql.= ' WHERE per.fk_expensereport = er.rowid';
-$sql.= ' AND er.entity = '.$conf->entity;
+$sql.= ' AND er.entity IN ('.getEntity('expensereport', 1).')';
$sql.= ' AND per.rowid = '.$id;
dol_syslog("expensereport/payment/card.php", LOG_DEBUG);
diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php
index c4351e4d038..e361a9954c0 100644
--- a/htdocs/expensereport/payment/payment.php
+++ b/htdocs/expensereport/payment/payment.php
@@ -193,8 +193,9 @@ if (GETPOST("action") == 'create')
print ''.$langs->trans("Amount").' '.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).' ';
$sql = "SELECT sum(p.amount) as total";
- $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p";
- $sql.= " WHERE p.fk_expensereport = ".$chid;
+ $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e";
+ $sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$chid;
+ $sql.= ' AND e.entity IN ('.getEntity('expensereport', 1).')';
$resql = $db->query($sql);
if ($resql)
{
diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php
index 31c2d985840..eba616d2620 100644
--- a/htdocs/expensereport/synchro_compta.php
+++ b/htdocs/expensereport/synchro_compta.php
@@ -139,6 +139,7 @@ else:
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
$sql.= " WHERE d.fk_statut = 6";
+ $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')';
$sql.= " ORDER BY d.date_valid DESC";
$resql=$db->query($sql);
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index f404f5c3029..12e4013a11f 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -2342,7 +2342,7 @@ else
print '';
$paymentstatic->id=$objp->rowid;
$paymentstatic->datepaye=$db->jdate($objp->dp);
- $paymentstatic->ref=$objp->ref;
+ $paymentstatic->ref=($objp->ref ? $objp->ref : $objp->rowid);;
$paymentstatic->num_paiement=$objp->num_paiement;
$paymentstatic->payment_code=$objp->payment_code;
print $paymentstatic->getNomUrl(1);
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 7ae18da125f..84b91bd3a27 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -247,9 +247,9 @@ llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:Factur
$sql = "SELECT";
if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT';
-$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite,";
+$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,";
$sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label,";
-$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
+$sql.= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= " p.rowid as project_id, p.ref as project_ref";
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 9ee5510f983..d1648be1d1b 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -41,7 +41,7 @@ ConsumedBy=Consumed by
NotConsumed=Not consumed
NoReplacableInvoice=No replacable invoices
NoInvoiceToCorrect=No invoice to correct
-InvoiceHasAvoir=Corrected by one or several invoices
+InvoiceHasAvoir=Was source of one or several credit notes
CardBill=Invoice card
PredefinedInvoices=Predefined Invoices
Invoice=Invoice
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 6d1e9cb2828..2da7a6e5227 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -877,6 +877,8 @@ foreach ($listofreferent as $key => $value)
$warning='';
if (empty($value['disableamount']))
{
+ $total_ht_by_line=null;
+ $othermessage='';
if ($tablename == 'don') $total_ht_by_line=$element->amount;
elseif ($tablename == 'projet_task')
{
@@ -893,7 +895,7 @@ foreach ($listofreferent as $key => $value)
}
else
{
- print $langs->trans("ModuleDisabled");
+ $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled"));
}
}
else
@@ -901,9 +903,13 @@ foreach ($listofreferent as $key => $value)
$total_ht_by_line=$element->total_ht;
}
print ' ';
- if (! $qualifiedfortotal) print '';
- print (isset($total_ht_by_line)?price($total_ht_by_line):' ');
- if (! $qualifiedfortotal) print ' ';
+ if ($othermessage) print $othermessage;
+ if (isset($total_ht_by_line))
+ {
+ if (! $qualifiedfortotal) print '';
+ print price($total_ht_by_line);
+ if (! $qualifiedfortotal) print ' ';
+ }
if ($warning) print ' '.img_warning($warning);
print ' ';
}
@@ -912,20 +918,33 @@ foreach ($listofreferent as $key => $value)
// Amount inc tax
if (empty($value['disableamount']))
{
+ $total_ttc_by_line=null;
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
elseif ($tablename == 'projet_task')
{
- $defaultvat = get_default_tva($mysoc, $mysoc);
- $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT');
+ if (! empty($conf->salaries->enabled))
+ {
+ // TODO Permission to read daily rate
+ $defaultvat = get_default_tva($mysoc, $mysoc);
+ $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT');
+ }
+ else
+ {
+ $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled"));
+ }
}
else
{
$total_ttc_by_line=$element->total_ttc;
}
print '';
- if (! $qualifiedfortotal) print '';
- print (isset($total_ttc_by_line)?price($total_ttc_by_line):' ');
- if (! $qualifiedfortotal) print ' ';
+ if ($othermessage) print $othermessage;
+ if (isset($total_ttc_by_line))
+ {
+ if (! $qualifiedfortotal) print '';
+ print price($total_ttc_by_line);
+ if (! $qualifiedfortotal) print ' ';
+ }
if ($warning) print ' '.img_warning($warning);
print ' ';
}
@@ -988,15 +1007,25 @@ foreach ($listofreferent as $key => $value)
if ($breakline) print $breakline;
+ // Total
print ''.$langs->trans("Number").': '.$i.' ';
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalHT").' : '.price($total_ht).' ';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Total").' : '.price($total_ht).' ';
- if (empty($value['disableamount'])) print ''.$langs->trans("TotalHT").' : '.price($total_ht).' ';
- else print ' ';
+ print '';
+ if (empty($value['disableamount']))
+ {
+ if (! 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).' ';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ' ';
- if (empty($value['disableamount'])) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).' ';
- else print ' ';
+ print '';
+ if (empty($value['disableamount']))
+ {
+
+ if (! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc);
+ }
+ print ' ';
print ' ';
print ' ';
}
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index e46e0aa5848..197a2041eac 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -249,6 +249,7 @@ if ($type_element == 'supplier_invoice')
$tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d";
$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid;
$where.= " AND d.fk_facture_fourn = f.rowid";
+ $where.= " AND f.entity = ".$conf->entity;
$dateprint = 'f.datef';
$doc_number='f.ref';
$thirdTypeSelect='supplier';
@@ -261,6 +262,7 @@ if ($type_element == 'supplier_order')
$tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d";
$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
$where.= " AND d.fk_commande = c.rowid";
+ $where.= " AND c.entity = ".$conf->entity;
$dateprint = 'c.date_valid';
$doc_number='c.ref';
$thirdTypeSelect='supplier';
@@ -274,6 +276,7 @@ if ($type_element == 'contract')
$tables_from = MAIN_DB_PREFIX."contrat as c,".MAIN_DB_PREFIX."contratdet as d";
$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
$where.= " AND d.fk_contrat = c.rowid";
+ $where.= " AND c.entity = ".$conf->entity;
$dateprint = 'c.date_valid';
$doc_number='c.ref';
$thirdTypeSelect='customer';