| '.$langs->trans("Ref").' | ';
print '';
-if ($_GET["account"])
+if (!empty($id))
{
if (! preg_match('/,/', $id))
{
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 2043516564c..131efda6e34 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -916,7 +916,10 @@ class BonPrelevement extends CommonObject
$row = $this->db->fetch_row($resql);
$ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1,0,2),2,"0",STR_PAD_LEFT);
- $this->filename = $conf->prelevement->dir_output.'/receipts/'.$ref.'.xml';
+ $dir=$conf->prelevement->dir_output.'/receipts';
+ if (! is_dir($dir)) dol_mkdir($dir);
+
+ $this->filename = $dir.'/receipts/'.$ref.'.xml';
// Create withdraw receipt in database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
@@ -932,10 +935,6 @@ class BonPrelevement extends CommonObject
{
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
$this->id = $prev_id;
-
- $dir=$conf->prelevement->dir_output.'/receipts';
- $file=$filebonprev;
- if (! is_dir($dir)) dol_mkdir($dir);
}
else
{
@@ -1031,7 +1030,7 @@ class BonPrelevement extends CommonObject
// Generation of SEPA file
$this->generate();
}
- dol_syslog(__METHOD__."::End withdraw receipt, file ".$filebonprev, LOG_DEBUG);
+ dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
}
/*
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 8c704aba52d..a973c2622cc 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -6,6 +6,7 @@
* Copyright (C) 2013 Cédric Salvador
* Copyright (C) 2014 Marcos García
* Copyright (C) 2015 Bahfir Abbes
+ * Copyright (C) 2016 Ferran Marcet
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -720,9 +721,6 @@ class FormFile
if ($modulepart == 'export') {
$relativepath = $file["name"];
}
- if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_fournisseur') {
- $relativepath = get_exdir($modulesubdir, 2,0,0,null,'invoice_supplier'). $modulesubdir. "/" . $file["name"];
- }
// Show file name with link to download
$out.= 'type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
$result='';
$reshook=0;
@@ -1447,7 +1450,7 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
}
if (empty($reshook))
{
- if (empty($hidedetails) || $hidedetails > 1) $result.=price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
+ if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs);
}
return $result;
}
@@ -1751,7 +1754,10 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
*/
function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
{
- global $hookmanager;
+ global $hookmanager,$conf;
+
+ $sign=1;
+ if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
$reshook=0;
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
@@ -1771,7 +1777,7 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
{
return $outputlangs->transnoentities("Option");
}
- if (empty($hidedetails) || $hidedetails > 1) $result.=price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
+ if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
}
return $result;
}
diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php
index 8cfd5f202d5..e52396e59e5 100644
--- a/htdocs/core/lib/sendings.lib.php
+++ b/htdocs/core/lib/sendings.lib.php
@@ -305,6 +305,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
$expedition->id=$objp->sendingid;
$expedition->fetchObjectLinked($expedition->id,$expedition->element);
//var_dump($expedition->linkedObjects);
+
$receiving='';
if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 910d8d6c562..a2fa413b9e8 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -539,13 +539,16 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
+
+ $sign=1;
+ if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
if ($prev_progress > 0) // Compute progress from previous situation
{
- $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
} else {
- $tvaligne = $object->lines[$i]->total_tva;
+ $tvaligne = $sign * $object->lines[$i]->total_tva;
}
$localtax1ligne=$object->lines[$i]->total_localtax1;
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index ac12c46b879..8a40c85b191 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -739,9 +739,9 @@ if (! empty($id) && $action != 'edit')
// Delete
if ($user->rights->don->supprimer)
{
- if ($don->statut == -1 || $don->statut == 0)
+ if ($object->statut == -1 || $object->statut == 0)
{
- print '";
+ print '";
}
else
{
@@ -779,4 +779,4 @@ if (! empty($id) && $action != 'edit')
}
llxFooter();
-$db->close();
\ No newline at end of file
+$db->close();
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 1b7fbefb8a6..a15c3b53b83 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -1266,7 +1266,7 @@ class Expedition extends CommonObject
$sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked";
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
- $sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent";
+ $sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht";
$sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
$sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type";
$sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch";
@@ -1336,6 +1336,8 @@ class Expedition extends CommonObject
$line->volume = $obj->volume;
$line->volume_units = $obj->volume_units;
+ $line->pa_ht = $obj->pa_ht;
+
// For invoicing
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc); // We force type to 0
$line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements)
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 61c2d3862af..80b02718878 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -379,6 +379,18 @@ if ($object->id > 0)
}
// TODO move to DAO class
+ $sql = "SELECT count(p.rowid) as total";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p ";
+ $sql.= " WHERE p.fk_soc =".$object->id;
+ $sql.= " AND p.entity =".$conf->entity;
+ $sql.= " ORDER BY p.date_commande DESC";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $object_count = $db->fetch_object($resql);
+ $num = $object_count->total;
+ }
+
$sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p ";
$sql.= " WHERE p.fk_soc =".$object->id;
@@ -389,7 +401,6 @@ if ($object->id > 0)
if ($resql)
{
$i = 0 ;
- $num = $db->num_rows($resql);
if ($num > 0)
{
@@ -405,7 +416,7 @@ if ($object->id > 0)
}
$var = True;
- while ($i < $num && $i <= $MAXLIST)
+ while ($i < $num && $i < $MAXLIST)
{
$obj = $db->fetch_object($resql);
$var=!$var;
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index e64ced4d6b9..05d3886ffd0 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -380,7 +380,8 @@ if ($resql)
print $facturestatic->getNomUrl(1);
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref);
- print $formfile->getDocumentsLink('facture_fournisseur', $filename, $filedir);
+ $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref);
+ print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir);
print " | \n";
// Ref supplier
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index af3373bf4aa..d5086ca1343 100755
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -564,6 +564,8 @@ Module59000Name=Margins
Module59000Desc=Module to manage margins
Module60000Name=Commissions
Module60000Desc=Module to manage commissions
+Module63000Name=Resources
+Module63000Desc=Manage resources (printers, cars, room, ...) you can then share into events
Permission11=Read customer invoices
Permission12=Create/modify customer invoices
Permission13=Unvalidate customer invoices
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 02fa370fc13..7fc6be32725 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -53,7 +53,7 @@ $projectstatic = new Project($db);
* Actions
*/
-if ($action == 'addtimespent' && $user->rights->projet->creer)
+if ($action == 'addtimespent' && $user->rights->projet->lire)
{
$error=0;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 0e7e375ac2f..e9b77836d3c 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -3483,17 +3483,17 @@ class Societe extends CommonObject
* Because this function is meant to be executed within a transaction, we won't take care of it.
*/
$sql = 'SELECT rowid
-FROM llx_societe_commerciaux
+FROM '.MAIN_DB_PREFIX.'societe_commerciaux
WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN (
SELECT fk_user
- FROM llx_societe_commerciaux
+ FROM '.MAIN_DB_PREFIX.'societe_commerciaux
WHERE fk_soc = '.(int) $origin_id.'
);';
$query = $db->query($sql);
while ($result = $db->fetch_object($query)) {
- $db->query('DELETE FROM llx_societe_commerciaux WHERE rowid = '.$result->rowid);
+ $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$result->rowid);
}
/**
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index e07e13ef751..ea2cb899893 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -280,43 +280,45 @@ if ($type_element == 'contract')
$thirdTypeSelect='customer';
}
-$sql = $sql_select;
-$sql.= ' d.description as description,';
-if ($type_element != 'fichinter' && $type_element != 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,';
-if ($type_element == 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty,';
-if ($type_element != 'fichinter') $sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,';
-$sql.= " s.rowid as socid ";
-if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
-if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
-$sql.= $where;
-if ($month > 0) {
- if ($year > 0) {
- $start = dol_mktime(0, 0, 0, $month, 1, $year);
- $end = dol_time_plus_duree($start,1,'m') - 1;
+if(!empty($sql_select)) {
+ $sql = $sql_select;
+ $sql.= ' d.description as description,';
+ if ($type_element != 'fichinter' && $type_element != 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,';
+ if ($type_element == 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty,';
+ if ($type_element != 'fichinter') $sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,';
+ $sql.= " s.rowid as socid ";
+ if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
+ if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
+ $sql.= $where;
+ if ($month > 0) {
+ if ($year > 0) {
+ $start = dol_mktime(0, 0, 0, $month, 1, $year);
+ $end = dol_time_plus_duree($start,1,'m') - 1;
+ $sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
+ } else {
+ $sql.= " AND date_format(".$dateprint.", '%m') = '".sprintf('%02d',$month)."'";
+ }
+ } else if ($year > 0) {
+ $start = dol_mktime(0, 0, 0, 1, 1, $year);
+ $end = dol_time_plus_duree($start,1,'y') - 1;
$sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
- } else {
- $sql.= " AND date_format(".$dateprint.", '%m') = '".sprintf('%02d',$month)."'";
}
-} else if ($year > 0) {
- $start = dol_mktime(0, 0, 0, 1, 1, $year);
- $end = dol_time_plus_duree($start,1,'y') - 1;
- $sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
+ if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'";
+ if ($sprod_fulldescr)
+ {
+ $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
+ if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
+ if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
+ $sql.=")";
+ }
+ $sql.= $db->order($sortfield,$sortorder);
+
+ $resql=$db->query($sql);
+ $totalnboflines = $db->num_rows($resql);
+
+ $sql.= $db->plimit($limit + 1, $offset);
}
-if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'";
-if ($sprod_fulldescr)
-{
- $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
- if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
- if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
- $sql.=")";
-}
-$sql.= $db->order($sortfield,$sortorder);
-
-$resql=$db->query($sql);
-$totalnboflines = $db->num_rows($resql);
-
-$sql.= $db->plimit($limit + 1, $offset);
//print $sql;
// Define type of elements
diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php
index 30c795bbd72..437be45c7b2 100644
--- a/htdocs/user/class/userbankaccount.class.php
+++ b/htdocs/user/class/userbankaccount.class.php
@@ -142,8 +142,7 @@ class UserBankAccount extends Account
$sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql.= " owner_address, label, datec, tms as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."user_rib";
- if ($id) $sql.= " WHERE rowid = ".$id;
- if ($socid) $sql.= " WHERE fk_user = ".$userid;
+ $sql.= " WHERE rowid = ".$id;
$resql = $this->db->query($sql);
if ($resql)