Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: hregis/dolibarr
base: 812c3e7998
...
head fork: hregis/dolibarr
compare: 1dd1e024ab
Checking mergeability… Don't worry, you can still create the pull request.
  • 9 commits
  • 21 files changed
  • 0 commit comments
  • 2 contributors
View
2  htdocs/admin/company.php
@@ -159,7 +159,7 @@
if ($action == 'addthumb')
{
- if (file_exists($conf->societe->dir_output.'/logos/'.$_GET["file"]))
+ if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
{
$isimage=image_format_supported($_GET["file"]);
View
4 htdocs/compta/facture.php
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
- * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@@ -1924,7 +1924,7 @@
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$objectsrc->remise_absolue=$remise_absolue;
$objectsrc->remise_percent=$remise_percent;
- $objectsrc->update_price(1);
+ $objectsrc->update_price(1,-1,1);
}
print "\n<!-- ".$classname." info -->";
View
96 htdocs/contrat/class/contrat.class.php
@@ -821,7 +821,7 @@ function delete($user,$langs='',$conf='')
* @param float $remise_percent Pourcentage de remise de la ligne
* @param timestamp $date_start Date de debut prevue
* @param timestamp $date_end Date de fin prevue
- * @param float $price_base_type HT ou TTC
+ * @param float $price_base_type HT or TTC
* @param float $pu_ttc Prix unitaire TTC
* @param int $info_bits Bits de type de lignes
* @return int <0 si erreur, >0 si ok
@@ -897,8 +897,8 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
$sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).",";
$sql.= " '".$info_bits."',";
$sql.= " ".price2num($price).",".price2num($remise); // TODO A virer
- if ($date_start > 0) { $sql.= ",".$this->db->idate($date_start); }
- if ($date_end > 0) { $sql.= ",".$this->db->idate($date_end); }
+ if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; }
+ if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; }
$sql.= ")";
dol_syslog(get_class($this)."::addline sql=".$sql);
@@ -949,9 +949,11 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
* @param float $localtax2tx Local tax 2 rate
* @param timestamp $date_debut_reel Date de debut reelle
* @param timestamp $date_fin_reel Date de fin reelle
+ * @param float $price_base_type HT or TTC
+ * @param int $info_bits Bits de type de lignes
* @return int < 0 si erreur, > 0 si ok
*/
- function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='')
+ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0)
{
global $user, $conf, $langs;
@@ -975,30 +977,55 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
$remise_percent=0;
}
- dol_syslog(get_class($this)."::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx, $localtax1tx, $localtax2tx");
+ dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx, $localtax1tx, $localtax2tx, $price_base_type, $info_bits");
$this->db->begin();
+ // Calcul du total TTC et de la TVA pour la ligne a partir de
+ // qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits);
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1= $tabprice[9];
+ $total_localtax2= $tabprice[10];
+ // TODO A virer
+ // Anciens indicateurs: $price, $remise (a ne plus utiliser)
+ $remise = 0;
+ $price = price2num(round($pu_ht, 2));
+ if (dol_strlen($remise_percent) > 0)
+ {
+ $remise = round(($pu_ht * $remise_percent / 100), 2);
+ $price = $pu_ht - $remise;
+ }
+
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'";
- $sql .= ",price_ht='" . price2num($price)."'";
- $sql .= ",subprice='" . price2num($subprice)."'";
- $sql .= ",remise='" . price2num($remise)."'";
- $sql .= ",remise_percent='".price2num($remise_percent)."'";
- $sql .= ",qty='$qty'";
- $sql .= ",tva_tx='". price2num($tvatx)."'";
- $sql .= ",localtax1_tx='". price2num($localtax1tx)."'";
- $sql .= ",localtax2_tx='". price2num($localtax2tx)."'";
- if ($date_start > 0) { $sql.= ",date_ouverture_prevue=".$this->db->idate($date_start); }
+ $sql.= ",price_ht='" . price2num($price)."'";
+ $sql.= ",subprice='" . price2num($subprice)."'";
+ $sql.= ",remise='" . price2num($remise)."'";
+ $sql.= ",remise_percent='".price2num($remise_percent)."'";
+ $sql.= ",qty='".$qty."'";
+ $sql.= ",tva_tx='". price2num($tvatx)."'";
+ $sql.= ",localtax1_tx='". price2num($localtax1tx)."'";
+ $sql.= ",localtax2_tx='". price2num($localtax2tx)."'";
+ $sql.= ", total_ht='". price2num($total_ht)."'";
+ $sql.= ", total_tva='". price2num($total_tva)."'";
+ $sql.= ", total_localtax1='".price2num($total_localtax1)."'";
+ $sql.= ", total_localtax2='".price2num($total_localtax2)."'";
+ $sql.= ", total_ttc='". price2num($total_ttc)."'";
+ if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; }
else { $sql.=",date_ouverture_prevue=null"; }
- if ($date_end > 0) { $sql.= ",date_fin_validite=".$this->db->idate($date_end); }
+ if ($date_end > 0) { $sql.= ",date_fin_validite='".$this->db->idate($date_end)."'"; }
else { $sql.=",date_fin_validite=null"; }
- if ($date_debut_reel > 0) { $sql.= ",date_ouverture=".$this->db->idate($date_debut_reel); }
+ if ($date_debut_reel > 0) { $sql.= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; }
else { $sql.=",date_ouverture=null"; }
- if ($date_fin_reel > 0) { $sql.= ",date_cloture=".$this->db->idate($date_fin_reel); }
+ if ($date_fin_reel > 0) { $sql.= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; }
else { $sql.=",date_cloture=null"; }
$sql .= " WHERE rowid = ".$rowid;
- dol_syslog(get_class($this)."::UpdateLine sql=".$sql);
+ dol_syslog(get_class($this)."::updateline sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
@@ -1011,7 +1038,7 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
else
{
$this->db->rollback();
- dol_syslog(get_class($this)."::UpdateLigne Erreur -2");
+ dol_syslog(get_class($this)."::updateligne Erreur -2");
return -2;
}
}
@@ -1019,7 +1046,7 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
{
$this->db->rollback();
$this->error=$this->db->error();
- dol_syslog(get_class($this)."::UpdateLigne Erreur -1");
+ dol_syslog(get_class($this)."::updateligne Erreur -1");
return -1;
}
}
@@ -1818,6 +1845,17 @@ function update($user, $notrigger=0)
// Check parameters
// Put here code to add control on parameters values
+ // Calcul du total TTC et de la TVA pour la ligne a partir de
+ // qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ $tabprice=calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0);
+ $this->total_ht = $tabprice[0];
+ $this->total_tva = $tabprice[1];
+ $this->total_ttc = $tabprice[2];
+ $this->total_localtax1= $tabprice[9];
+ $this->total_localtax2= $tabprice[10];
+
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
$sql.= " fk_contrat='".$this->fk_contrat."',";
@@ -1825,11 +1863,11 @@ function update($user, $notrigger=0)
$sql.= " statut='".$this->statut."',";
$sql.= " label='".$this->db->escape($this->label)."',";
$sql.= " description='".$this->db->escape($this->description)."',";
- $sql.= " date_commande=".($this->date_commande!=''?$this->db->idate($this->date_commande):"null").",";
- $sql.= " date_ouverture_prevue=".($this->date_ouverture_prevue!=''?$this->db->idate($this->date_ouverture_prevue):"null").",";
- $sql.= " date_ouverture=".($this->date_ouverture!=''?$this->db->idate($this->date_ouverture):"null").",";
- $sql.= " date_fin_validite=".($this->date_fin_validite!=''?$this->db->idate($this->date_fin_validite):"null").",";
- $sql.= " date_cloture=".($this->date_cloture!=''?$this->db->idate($this->date_cloture):"null").",";
+ $sql.= " date_commande=".($this->date_commande!=''?"'".$this->db->idate($this->date_commande)."'":"null").",";
+ $sql.= " date_ouverture_prevue=".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null").",";
+ $sql.= " date_ouverture=".($this->date_ouverture!=''?"'".$this->db->idate($this->date_ouverture)."'":"null").",";
+ $sql.= " date_fin_validite=".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null").",";
+ $sql.= " date_cloture=".($this->date_cloture!=''?"'".$this->db->idate($this->date_cloture)."'":"null").",";
$sql.= " tva_tx='".$this->tva_tx."',";
$sql.= " localtax1_tx='".$this->localtax1_tx."',";
$sql.= " localtax2_tx='".$this->localtax2_tx."',";
@@ -1851,7 +1889,7 @@ function update($user, $notrigger=0)
$sql.= " commentaire='".$this->db->escape($this->commentaire)."'";
$sql.= " WHERE rowid=".$this->id;
- dol_syslog("ContratLigne::update sql=".$sql, LOG_DEBUG);
+ dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@@ -1862,7 +1900,7 @@ function update($user, $notrigger=0)
else
{
$this->error="Error ".$this->db->lasterror();
- dol_syslog("ContratLigne::update ".$this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1;
}
@@ -1899,7 +1937,7 @@ function update_total()
$sql.= ",total_ttc=".price2num($this->total_ttc,'MT')."";
$sql.= " WHERE rowid = ".$this->rowid;
- dol_syslog("ContratLigne::update_total sql=".$sql);
+ dol_syslog(get_class($this)."::update_total sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
@@ -1910,7 +1948,7 @@ function update_total()
else
{
$this->error=$this->db->error();
- dol_syslog("ContratLigne::update_total Error ".$this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::update_total Error ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
View
32 htdocs/contrat/fiche.php
@@ -148,7 +148,7 @@
$datecontrat = dol_mktime($_POST["rehour"], $_POST["remin"], 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
}
-else if ($action == 'add' && $user->rights->contrat->creer)
+if ($action == 'add' && $user->rights->contrat->creer)
{
$object->socid = $socid;
$object->date_contrat = $datecontrat;
@@ -481,13 +481,13 @@
if ($action == 'addcontact' && $user->rights->contrat->creer)
{
$result = $object->fetch($id);
-
+
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
-
+
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -506,7 +506,7 @@
}
}
}
-
+
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->contrat->creer)
{
@@ -519,13 +519,13 @@
dol_print_error($db);
}
}
-
+
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->contrat->creer)
{
$object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]);
-
+
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -660,7 +660,7 @@
}
dol_htmloutput_errors($mesg,'');
-
+
$object->fetch_thirdparty();
$nbofservices=count($object->lines);
@@ -781,24 +781,24 @@
}
echo '<br>';
-
+
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
-
+
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
-
+
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
-
+
$servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1);
$colorb='666666';
@@ -809,9 +809,9 @@
* Lines of contracts
*/
$productstatic=new Product($db);
-
+
// TODO move css and DAO
-
+
// Title line for service
print '<table class="notopnoleft allwidth">'; // Array with (n*2)+1 lines
$cursorline=1;
@@ -1078,9 +1078,9 @@
{
if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline')
{
- $action='activateline';
- if ($objp->statut == 4) $action='unactivateline';
- print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;ligne='.$object->lines[$cursorline-1]->id.'&amp;action='.$action.'">';
+ $tmpaction='activateline';
+ if ($objp->statut == 4) $tmpaction='unactivateline';
+ print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;ligne='.$object->lines[$cursorline-1]->id.'&amp;action='.$tmpaction.'">';
print img_edit();
print '</a>';
}
View
24 htdocs/contrat/index.php
@@ -25,6 +25,7 @@
require ("../main.inc.php");
require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
+require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("products");
$langs->load("companies");
@@ -290,9 +291,9 @@
$max=5;
$sql = 'SELECT ';
$sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
-$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= ".$db->idate($now).")",1,0).') as nb_running,';
-$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now).")",1,0).') as nb_expired,';
-$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now - $conf->contrat->services->expires->warning_delay).")",1,0).') as nb_late,';
+$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')",1,0).') as nb_running,';
+$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')",1,0).') as nb_expired,';
+$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')",1,0).') as nb_late,';
$sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,';
$sql.= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
@@ -367,11 +368,11 @@
$sql.= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
$sql.= " s.nom,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype";
-$sql.= " FROM (".MAIN_DB_PREFIX."contratdet as cd";
-$sql.= ", ".MAIN_DB_PREFIX."contrat as c";
+$sql.= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
+$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
+$sql.= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " AND cd.fk_contrat = c.rowid";
$sql.= " AND c.fk_soc = s.rowid";
@@ -445,10 +446,10 @@
$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,";
$sql.= " s.nom,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype";
-$sql.= " FROM (".MAIN_DB_PREFIX."contratdet as cd";
-$sql.= ", ".MAIN_DB_PREFIX."contrat as c";
+$sql.= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " AND c.statut = 1";
@@ -524,10 +525,10 @@
$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,";
$sql.= " s.nom,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype";
-$sql.= " FROM (".MAIN_DB_PREFIX."contratdet as cd";
-$sql.= ", ".MAIN_DB_PREFIX."contrat as c";
+$sql.= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " AND c.statut = 1";
@@ -602,7 +603,8 @@
print '<br>';
-$db->close();
llxFooter();
+
+$db->close();
?>
View
2  htdocs/core/ajax/ajaxdirpreview.php
@@ -162,7 +162,7 @@
// Right area
if ($module == 'company') // Auto area for suppliers invoices
{
- $upload_dir = $conf->societe->dir_output;
+ $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
$filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$param.='&module='.$module;
View
87 htdocs/core/class/commonobject.class.php
@@ -1439,18 +1439,19 @@ function update_note_public($note_public)
/**
* Update total_ht, total_ttc and total_vat for an object (sum of lines)
*
- * @param int $exclspec Exclude special product (product_type=9)
- * @param int $roundingadjust -1=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND or 0), 0=Use total of rounding, 1=Use rounding of total
- * @return int <0 if KO, >0 if OK
+ * @param int $exclspec Exclude special product (product_type=9)
+ * @param int $roundingadjust -1=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND or 0), 0=Use total of rounding, 1=Use rounding of total
+ * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
+ * @return int <0 if KO, >0 if OK
*/
- function update_price($exclspec=0,$roundingadjust=-1)
+ function update_price($exclspec=0,$roundingadjust=-1,$nodatabaseupdate=0)
{
include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');
if ($roundingadjust < 0 && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $roundingadjust=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
if ($roundingadjust < 0) $roundingadjust=0;
- $err=0;
+ $error=0;
// Define constants to find lines to sum
$fieldtva='total_tva';
@@ -1462,7 +1463,12 @@ function update_price($exclspec=0,$roundingadjust=-1)
$sql.= ' tva_tx as vatrate';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
- if ($exclspec) $sql.= ' AND product_type <> 9';
+ if ($exclspec)
+ {
+ $product_field='product_type';
+ if ($this->table_element_line == 'contratdet') $product_field=''; // contratdet table has no product_type field
+ if ($product_field) $sql.= ' AND '.$product_field.' <> 9';
+ }
dol_syslog(get_class($this)."::update_price sql=".$sql);
$resql = $this->db->query($sql);
@@ -1537,32 +1543,39 @@ function update_price($exclspec=0,$roundingadjust=-1)
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva';
if ($this->element == 'propal') $fieldttc='total';
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
- $sql .= " ".$fieldht."='".price2num($this->total_ht)."',";
- $sql .= " ".$fieldtva."='".price2num($this->total_tva)."',";
- $sql .= " ".$fieldlocaltax1."='".price2num($this->total_localtax1)."',";
- $sql .= " ".$fieldlocaltax2."='".price2num($this->total_localtax2)."',";
- $sql .= " ".$fieldttc."='".price2num($this->total_ttc)."'";
- $sql .= ' WHERE rowid = '.$this->id;
+ if (empty($nodatabaseupdate))
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
+ $sql .= " ".$fieldht."='".price2num($this->total_ht)."',";
+ $sql .= " ".$fieldtva."='".price2num($this->total_tva)."',";
+ $sql .= " ".$fieldlocaltax1."='".price2num($this->total_localtax1)."',";
+ $sql .= " ".$fieldlocaltax2."='".price2num($this->total_localtax2)."',";
+ $sql .= " ".$fieldttc."='".price2num($this->total_ttc)."'";
+ $sql .= ' WHERE rowid = '.$this->id;
+
+ //print "xx".$sql;
+ dol_syslog(get_class($this)."::update_price sql=".$sql);
+ $resql=$this->db->query($sql);
+ if (! $resql)
+ {
+ $error++;
+ $this->error=$this->db->error();
+ dol_syslog(get_class($this)."::update_price error=".$this->error,LOG_ERR);
+ }
+ }
- //print "xx".$sql;
- dol_syslog(get_class($this)."::update_price sql=".$sql);
- $resql=$this->db->query($sql);
- if ($resql)
+ if (! $error)
{
return 1;
}
else
{
- $this->error=$this->db->error();
- dol_syslog(get_class($this)."::update_price error=".$this->error,LOG_ERR);
return -1;
}
}
else
{
- $this->error=$this->db->error();
- dol_syslog(get_class($this)."::update_price error=".$this->error,LOG_ERR);
+ dol_print_error($this->db,'Bad request in update_price');
return -1;
}
}
@@ -2140,7 +2153,7 @@ function hasProductsOrServices($predefined=-1)
function setExtraParameters()
{
$this->db->begin();
-
+
$extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null);
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
@@ -2364,7 +2377,7 @@ function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false)
function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false)
{
global $conf,$langs;
-
+
print '<tr class="liste_titre nodrag nodrop">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
{
@@ -2380,15 +2393,15 @@ function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$ho
print '<td width="10">&nbsp;</td>';
print '<td nowrap="nowrap">&nbsp;</td>'; // No width to allow autodim
print "</tr>\n";
-
+
$num = count($this->lines);
$var = true;
$i = 0;
-
+
foreach ($this->lines as $line)
{
$var=!$var;
-
+
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
{
if (empty($line->fk_parent_line))
@@ -2401,11 +2414,11 @@ function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$ho
{
$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager);
}
-
+
$i++;
}
}
-
+
/**
* Return HTML content of a detail line
* TODO Move this into an output class file (htmlline.class.php)
@@ -2428,16 +2441,16 @@ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer
{
global $conf,$langs,$user;
global $form,$bc,$bcdd;
-
+
$element=$this->element;
-
+
// Show product and description
$type=$line->product_type?$line->product_type:$line->fk_product_type;
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (! empty($line->date_start)) $type=1;
if (! empty($line->date_end)) $type=1;
-
+
// Ligne en mode visu
if ($action != 'editline' || $selected != $line->id)
{
@@ -2445,13 +2458,13 @@ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer
if ($line->fk_product > 0)
{
$product_static = new Product($this->db);
-
+
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
$this->fetch_thirdparty();
$prod = new Product($this->db, $line->fk_product);
-
+
$outputlangs = $langs;
$newlang='';
if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
@@ -2461,14 +2474,14 @@ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
-
+
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label;
}
else
{
$label = $line->product_label;
}
-
+
$product_static->type=$line->fk_product_type;
$product_static->id=$line->fk_product;
$product_static->ref=$line->ref;
@@ -2476,7 +2489,7 @@ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer
$text=$product_static->getNomUrl(1);
$text.= ' - '.$label;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
-
+
// Use global variables + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php');
}
@@ -2486,7 +2499,7 @@ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php');
}
}
-
+
// Ligne en mode update
if ($this->statut == 0 && $action == 'editline' && $selected == $line->id)
{
View
10 htdocs/core/class/html.form.class.php
@@ -3691,7 +3691,7 @@ function showphoto($modulepart,$object,$width=100)
if ($modulepart=='societe')
{
- $dir=$conf->societe->dir_output;
+ $dir=$conf->societe->multidir_output[$object->entity];
$smallfile=$object->logo;
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
if ($object->logo) $file=$object->id.'/logos/thumbs/'.$smallfile;
@@ -3717,14 +3717,14 @@ function showphoto($modulepart,$object,$width=100)
if ($file && file_exists($dir."/".$file))
{
// TODO Link to large image
- $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'&cache='.$cache.'">';
- $ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'&cache='.$cache.'">';
+ $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">';
+ $ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='</a>';
}
else if ($altfile && file_exists($dir."/".$altfile))
{
- $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'&cache='.$cache.'">';
- $ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($altfile).'&cache='.$cache.'">';
+ $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">';
+ $ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
$ret.='</a>';
}
else
View
4 htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
@@ -179,7 +179,7 @@ function write_file($object,$outputlangs,$srctemplatepath)
$outputlangs->load("companies");
$outputlangs->load("projects");
- if ($conf->societe->dir_output)
+ if ($conf->societe->multidir_output[$object->entity])
{
// If $object is id instead of object
if (! is_object($object))
@@ -194,7 +194,7 @@ function write_file($object,$outputlangs,$srctemplatepath)
}
}
- $dir = $conf->societe->dir_output;
+ $dir = $conf->societe->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->id);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
View
13 htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
- * Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@@ -31,8 +31,7 @@
/**
- * \class pdf_canelle
- * \brief Class to generate the supplier invoices with the canelle model
+ * Class to generate the supplier invoices with the canelle model
*/
class pdf_canelle extends ModelePDFSuppliersInvoices
{
@@ -885,7 +884,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
// If BILLING contact defined on invoice, we use it
$usecontact=false;
- $arrayidcontact=$object->getIdContact('external','BILLING');
+ $arrayidcontact=$object->getIdContact('internal','BILLING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
@@ -897,15 +896,15 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
// On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
- else $socname = $object->client->nom;
+ else $socname = $mysoc->nom;
$carac_client_name=$outputlangs->convToOutputCharset($socname);
}
else
{
- $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
+ $carac_client_name=$outputlangs->convToOutputCharset($mysoc->nom);
}
- $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
+ $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,$object->contact,$usecontact,'target');
// Show recipient
$posy=42;
View
8 htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -956,7 +956,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
// If BILLING contact defined on invoice, we use it
$usecontact=false;
- $arrayidcontact=$object->getIdContact('external','BILLING');
+ $arrayidcontact=$object->getIdContact('internal','BILLING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
@@ -968,15 +968,15 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
// On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
- else $socname = $object->client->nom;
+ else $socname = $mysoc->nom;
$carac_client_name=$outputlangs->convToOutputCharset($socname);
}
else
{
- $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
+ $carac_client_name=$outputlangs->convToOutputCharset($mysoc->nom);
}
- $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
+ $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,$object->contact,$usecontact,'target');
// Show recipient
$posy=42;
View
15 htdocs/document.php
@@ -124,13 +124,13 @@ function llxHeader() { }
// On fait une verification des droits et on definit le repertoire concerne
// Wrapping for third parties
- if ($modulepart == 'company')
+ if ($modulepart == 'company' || $modulepart == 'societe')
{
if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file))
{
$accessallowed=1;
}
- $original_file=$conf->societe->dir_output.'/'.$original_file;
+ $original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file;
$sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity;
}
@@ -252,17 +252,6 @@ function llxHeader() { }
$original_file=$conf->compta->dir_output.'/'.$original_file;
}
- // Wrapping pour les societe
- else if ($modulepart == 'societe')
- {
- if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file))
- {
- $accessallowed=1;
- }
- $original_file=$conf->societe->dir_output.'/'.$original_file;
- $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity;
- }
-
// Wrapping pour les expedition
else if ($modulepart == 'expedition')
{
View
3  htdocs/install/mysql/migration/3.1.0-3.2.0.sql
@@ -15,6 +15,9 @@
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
+-- Delete old themes setup
+DELETE FROM llx_user_param WHERE param = 'MAIN_THEME' and value = 'freelug';
+
update llx_propal set fk_projet = null where fk_projet not in (select rowid from llx_projet);
update llx_commande set fk_projet = null where fk_projet not in (select rowid from llx_projet);
View
2  htdocs/install/repair.php
@@ -199,7 +199,7 @@
{
$filearray=array();
$upload_dir = $conf->$modulepart->dir_output;
- if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output;
+ if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output;
if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output;
View
27 htdocs/install/upgrade2.php
@@ -308,6 +308,8 @@
$beforeversionarray=explode('.','3.2.9');
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
{
+ migrate_price_contrat($db,$langs,$conf);
+
migrate_mode_reglement($db,$langs,$conf);
// Reload modules
@@ -1460,7 +1462,6 @@ function migrate_price_contrat($db,$langs,$conf)
$pu = $obj->subprice;
$txtva = $obj->tva_taux;
$remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
$info_bits = $obj->info_bits;
// On met a jour les 3 nouveaux champs
@@ -1468,7 +1469,7 @@ function migrate_price_contrat($db,$langs,$conf)
//$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis
$contratligne->rowid=$rowid;
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,0,'HT',$info_bits);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
@@ -1477,30 +1478,10 @@ function migrate_price_contrat($db,$langs,$conf)
$contratligne->total_tva = $total_tva;
$contratligne->total_ttc = $total_ttc;
- dolibarr_install_syslog("upgrade2: Line $rowid: contratdetid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ dolibarr_install_syslog("upgrade2: Line $rowid: contratdetid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent -> $total_ht, $total_tva, $total_ttc");
print ". ";
$contratligne->update_total($rowid);
-
- /* On touche pas a contrat mere
- $propal = new Propal($db);
- $propal->id=$obj->rowid;
- if ( $propal->fetch($propal->id) >= 0 )
- {
- if ( $propal->update_price() > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$propal->id;
- }
- }
- else
- {
- print "Error #3";
- }
- */
$i++;
}
}
View
2  htdocs/societe/canvas/company/tpl/card_view.tpl.php
@@ -259,7 +259,7 @@
/*
* Documents generes
*/
-$filedir=$conf->societe->dir_output.'/'.$socid;
+$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
View
2  htdocs/societe/canvas/individual/tpl/card_view.tpl.php
@@ -199,7 +199,7 @@
/*
* Documents generes
*/
-$filedir=$conf->societe->dir_output.'/'.$socid;
+$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
View
8 htdocs/societe/class/societe.class.php
@@ -845,7 +845,7 @@ function delete($id)
// Remove contacts
if (! $error)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
@@ -873,7 +873,7 @@ function delete($id)
// Remove ban
if (! $error)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this)."::Delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
@@ -906,7 +906,7 @@ function delete($id)
// Remove third party
if (! $error)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."societe";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
@@ -932,7 +932,7 @@ function delete($id)
$this->db->commit();
// Delete directory
- $docdir = $conf->societe->dir_output . "/" . $id;
+ $docdir = $conf->societe->multidir_output[$this->entity] . "/" . $id;
if (file_exists($docdir))
{
dol_delete_dir_recursive($docdir);
View
205 htdocs/societe/document.php
@@ -35,9 +35,10 @@
$mesg='';
-$action = GETPOST('action');
-$confirm = GETPOST('confirm');
-$socid = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
+$action=GETPOST('action');
+$confirm=GETPOST('confirm');
+$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
+$ref = GETPOST('ref', 'alpha');
// Security check
if ($user->societe_id > 0)
@@ -46,7 +47,7 @@
$action='';
$socid = $user->societe_id;
}
-$result = restrictedArea($user, 'societe', $socid, '&societe');
+$result = restrictedArea($user, 'societe', $id, '&societe');
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
@@ -59,19 +60,24 @@
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
-$upload_dir = $conf->societe->dir_output . "/" . $socid ;
-$courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid);
-
$object = new Societe($db);
+if ($id > 0 || ! empty($ref))
+{
+ $result = $object->fetch($id, $ref);
+
+ $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ;
+ $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id);
+}
+
/*
* Actions
*/
// Post file
-if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
+if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
- if ($object->fetch($socid))
+ if ($object->id)
{
if (dol_mkdir($upload_dir) >= 0)
{
@@ -113,7 +119,7 @@
// Delete file
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
- if ($object->fetch($socid))
+ if ($object->id)
{
$file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
@@ -131,107 +137,98 @@
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('',$langs->trans("ThirdParty").' - '.$langs->trans("Files"),$help_url);
-if ($socid > 0)
+if ($object->id)
{
- if ($object->fetch($socid))
- {
- /*
- * Affichage onglets
- */
- if ($conf->notification->enabled) $langs->load("mails");
- $head = societe_prepare_head($object);
-
- $form=new Form($db);
-
- dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company');
-
-
- // Construit liste des fichiers
- $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
- $totalsize=0;
- foreach($filearray as $key => $file)
- {
- $totalsize+=$file['size'];
- }
-
-
- print '<table class="border"width="100%">';
-
- // Ref
- print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td>';
- print '<td colspan="3">';
- print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom');
- print '</td></tr>';
-
- // Prefix
- if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
- {
- print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
- }
-
- if ($object->client)
- {
- print '<tr><td>';
- print $langs->trans('CustomerCode').'</td><td colspan="3">';
- print $object->code_client;
- if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
- print '</td></tr>';
- }
-
- if ($object->fournisseur)
- {
- print '<tr><td>';
- print $langs->trans('SupplierCode').'</td><td colspan="3">';
- print $object->code_fournisseur;
- if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
- print '</td></tr>';
- }
-
- // Nbre fichiers
- print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
-
- //Total taille
- print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
-
- print '</table>';
-
- print '</div>';
-
- dol_htmloutput_mesg($mesg,$mesgs);
-
- /*
- * Confirmation suppression fichier
- */
- if ($action == 'delete')
- {
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?socid='.$socid.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
- if ($ret == 'html') print '<br>';
- }
-
- $formfile=new FormFile($db);
-
- // Show upload form
- $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer,50,$object);
-
- // List of document
- $param='&socid='.$object->id;
- $formfile->list_of_documents($filearray,$object,'societe',$param);
-
- print "<br><br>";
- }
- else
- {
- dol_print_error($db);
- }
+ /*
+ * Affichage onglets
+ */
+ if ($conf->notification->enabled) $langs->load("mails");
+ $head = societe_prepare_head($object);
+
+ $form=new Form($db);
+
+ dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company');
+
+
+ // Construit liste des fichiers
+ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+ $totalsize=0;
+ foreach($filearray as $key => $file)
+ {
+ $totalsize+=$file['size'];
+ }
+
+
+ print '<table class="border"width="100%">';
+
+ // Ref
+ print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td>';
+ print '<td colspan="3">';
+ print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom');
+ print '</td></tr>';
+
+ // Prefix
+ if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
+ {
+ print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
+ }
+
+ if ($object->client)
+ {
+ print '<tr><td>';
+ print $langs->trans('CustomerCode').'</td><td colspan="3">';
+ print $object->code_client;
+ if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
+ print '</td></tr>';
+ }
+
+ if ($object->fournisseur)
+ {
+ print '<tr><td>';
+ print $langs->trans('SupplierCode').'</td><td colspan="3">';
+ print $object->code_fournisseur;
+ if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
+ print '</td></tr>';
+ }
+
+ // Nbre fichiers
+ print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
+
+ //Total taille
+ print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
+
+ print '</table>';
+
+ print '</div>';
+
+ dol_htmloutput_mesg($mesg,$mesgs);
+
+ /*
+ * Confirmation suppression fichier
+ */
+ if ($action == 'delete')
+ {
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
+ if ($ret == 'html') print '<br>';
+ }
+
+ $formfile=new FormFile($db);
+
+ // Show upload form
+ $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,'',0,0,$user->rights->societe->creer,50,$object);
+
+ // List of document
+ $param='&socid='.$object->id;
+ $formfile->list_of_documents($filearray,$object,'societe',$param);
+
+ print "<br><br>";
}
else
{
accessforbidden('',0,0);
}
-$db->close();
-
llxFooter();
-
+$db->close();
?>
View
12 htdocs/societe/soc.php
@@ -252,7 +252,7 @@
}
// Gestion du logo de la société
- $dir = $conf->societe->dir_output."/".$object->id."/logos/";
+ $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
@@ -328,14 +328,14 @@
}
// Gestion du logo de la société
- $dir = $conf->societe->dir_output."/".$object->id."/logos";
+ $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
if (GETPOST('deletephoto'))
{
- $fileimg=$conf->societe->dir_output.'/'.$object->id.'/logos/'.$object->logo;
- $dirthumbs=$conf->societe->dir_output.'/'.$object->id.'/logos/thumbs';
+ $fileimg=$dir.'/'.$object->logo;
+ $dirthumbs=$dir.'/thumbs';
dol_delete_file($fileimg);
dol_delete_dir_recursive($dirthumbs);
}
@@ -568,7 +568,7 @@
$object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
// Gestion du logo de la société
- $dir = $conf->societe->dir_output."/".$object->id."/logos";
+ $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
@@ -1821,7 +1821,7 @@
/*
* Documents generes
*/
- $filedir=$conf->societe->dir_output.'/'.$object->id;
+ $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
View
2  htdocs/viewimage.php
@@ -121,7 +121,7 @@ function llxHeader() { }
elseif ($modulepart == 'societe')
{
$accessallowed=1;
- $original_file=$conf->societe->dir_output.'/'.$original_file;
+ $original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file;
}
// Wrapping pour les apercu factures
elseif ($modulepart == 'apercufacture')

No commit comments for this range

Something went wrong with that request. Please try again.