Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2017-09-04 10:20:17 +02:00
commit 3e9679f273
7 changed files with 271 additions and 226 deletions

View File

@ -334,7 +334,7 @@ foreach my $target (sort keys %CHOOSEDTARGET) {
}
foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
if ($target eq 'ASSO') { $nbofpublishneedchangelog++; }
if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
$nboftargetok++;
}

View File

@ -163,6 +163,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/bookmarks
%_datadir/dolibarr/htdocs/cashdesk
%_datadir/dolibarr/htdocs/categories
%_datadir/dolibarr/htdocs/collab
%_datadir/dolibarr/htdocs/comm
%_datadir/dolibarr/htdocs/commande
%_datadir/dolibarr/htdocs/compta

View File

@ -882,115 +882,111 @@ if ($mode == 'marketplace')
if ($mode == 'deploy')
{
dol_fiche_head($head, $mode, '', -1);
dol_fiche_head($head, $mode, '', -1);
$dolibarrdataroot=preg_replace('/([\\/]+)$/i','',DOL_DATA_ROOT);
$allowonlineinstall=true;
$allowfromweb=1;
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false;
$allowonlineinstall=true;
$allowfromweb=1;
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false;
$fullurl='<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>';
$message='';
if (! empty($allowonlineinstall))
{
if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt)))
{
$message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
$allowfromweb=-1;
}
else
{
if ($dirins_ok)
{
if (! is_writable(dol_osencode($dirins)))
{
$langs->load("errors");
$message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins));
$allowfromweb=0;
}
}
else
{
$message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
$allowfromweb=0;
}
}
}
else
{
$message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock'));
$allowfromweb=0;
}
$fullurl='<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>';
$message='';
if (! empty($allowonlineinstall))
{
if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt)))
{
$message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
$allowfromweb=-1;
}
else
{
if ($dirins_ok)
{
if (! is_writable(dol_osencode($dirins)))
{
$langs->load("errors");
$message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins));
$allowfromweb=0;
}
}
else
{
if ($allowfromweb < 1)
{
print $langs->trans("SomethingMakeInstallFromWebNotPossible");
print $message;
//print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
print '<br>';
}
$message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
$allowfromweb=0;
}
}
}
else
{
$message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock'));
$allowfromweb=0;
}
print '<br>';
if ($allowfromweb < 1)
{
print $langs->trans("SomethingMakeInstallFromWebNotPossible");
print $message;
//print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
print '<br>';
}
if ($allowfromweb >= 0)
{
if ($allowfromweb == 1)
{
//print $langs->trans("ThisIsProcessToFollow").'<br>';
}
else
{
print $langs->trans("ThisIsAlternativeProcessToFollow").'<br>';
print '<b>'.$langs->trans("StepNb",1).'</b>: ';
print $langs->trans("FindPackageFromWebSite",$fullurl).'<br>';
print '<b>'.$langs->trans("StepNb",2).'</b>: ';
print $langs->trans("DownloadPackageFromWebSite",$fullurl).'<br>';
print '<b>'.$langs->trans("StepNb",3).'</b>: ';
}
print '<br>';
if ($allowfromweb == 1)
{
print $langs->trans("UnpackPackageInModulesRoot",$dirins).'<br>';
if ($allowfromweb >= 0)
{
if ($allowfromweb == 1)
{
//print $langs->trans("ThisIsProcessToFollow").'<br>';
}
else
{
print $langs->trans("ThisIsAlternativeProcessToFollow").'<br>';
print '<b>'.$langs->trans("StepNb",1).'</b>: ';
print $langs->trans("FindPackageFromWebSite",$fullurl).'<br>';
print '<b>'.$langs->trans("StepNb",2).'</b>: ';
print $langs->trans("DownloadPackageFromWebSite",$fullurl).'<br>';
print '<b>'.$langs->trans("StepNb",3).'</b>: ';
}
print '<br>';
if ($allowfromweb == 1)
{
print $langs->trans("UnpackPackageInModulesRoot",$dirins).'<br>';
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">';
print '<input type="hidden" name="mode" value="deploy">';
print $langs->trans("YouCanSubmitFile").' <input type="file" name="fileinstall"> ';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '</form>';
print '<br>';
print '<br>';
print '<br>';
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">';
print '<input type="hidden" name="mode" value="deploy">';
print $langs->trans("YouCanSubmitFile").' <input type="file" name="fileinstall"> ';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '</form>';
print '<div class="center"><div class="logo_setup"></div></div>';
}
else
{
print $langs->trans("UnpackPackageInModulesRoot",$dirins).'<br>';
print '<b>'.$langs->trans("StepNb",4).'</b>: ';
print $langs->trans("SetupIsReadyForUse").'<br>';
}
}
print '<br>';
print '<br>';
if (! empty($result['return']))
{
print '<br>';
print '<div class="center"><div class="logo_setup"></div></div>';
}
else
{
print $langs->trans("UnpackPackageInModulesRoot",$dirins).'<br>';
print '<b>'.$langs->trans("StepNb",4).'</b>: ';
print $langs->trans("SetupIsReadyForUse").'<br>';
}
}
foreach($result['return'] as $value)
{
echo $value.'<br>';
}
}
if (! empty($result['return']))
{
print '<br>';
foreach($result['return'] as $value)
{
echo $value.'<br>';
}
}
dol_fiche_end();
dol_fiche_end();
}
if ($mode == 'develop')
{
dol_fiche_head($head, $mode, '', -1);

View File

@ -799,6 +799,7 @@ TitleSetToDraft=Go back to draft
ConfirmSetToDraft=Are you sure you want to go back to Draft status ?
ImportId=Import id
Websites=Web sites
Events=Events
# Week day
Monday=Monday
Tuesday=Tuesday

View File

@ -180,26 +180,27 @@ $sql = "SELECT";
$sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
if ($client) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
$sql.= " sum(d.total_ht) as selling_price,";
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
// Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this)
$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,";
$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.fk_soc = s.rowid";
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " AND f.fk_statut > 0";
$sql.= ' AND s.entity IN ('.getEntity('societe').')';
$sql.= " AND d.fk_facture = f.rowid";
$sql.= " AND (d.product_type = 0 OR d.product_type = 1)";
if ($client)
$sql.= " AND f.fk_soc = ".$socid;
if (!empty($startdate))
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
if (!empty($enddate))
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND d.buy_price_ht IS NOT NULL";
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
$sql .= " AND d.buy_price_ht <> 0";
$sql .= " AND d.buy_price_ht <> 0";
if ($client) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut";
else $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client";
$sql.=$db->order($sortfield,$sortorder);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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
@ -70,7 +70,9 @@ $hookmanager->initHooks(array('projecttaskcard','globalcard'));
$progress=GETPOST('progress', 'int');
$label=GETPOST('label', 'alpha');
$description=GETPOST('description');
$planned_workload=GETPOST('planned_workloadhour')*3600+GETPOST('planned_workloadmin')*60;
$planned_workloadhour=(GETPOST('planned_workloadhour','int')?GETPOST('planned_workloadhour','int'):0);
$planned_workloadmin=(GETPOST('planned_workloadmin','int')?GETPOST('planned_workloadmin','int'):0);
$planned_workload=$planned_workloadhour*3600+$planned_workloadmin*60;
$userAccess=0;

View File

@ -44,6 +44,8 @@ class Dolresource extends CommonObject
public $type_label;
public $tms='';
var $oldcopy;
/**
* Constructor
*
@ -231,85 +233,108 @@ class Dolresource extends CommonObject
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
{
global $conf, $langs, $hookmanager;
$error=0;
function update($user=null, $notrigger=0)
{
global $conf, $langs, $hookmanager;
$error=0;
// Clean parameters
if (isset($this->ref)) $this->ref=trim($this->ref);
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
if (isset($this->description)) $this->description=trim($this->description);
// Clean parameters
if (isset($this->ref)) $this->ref=trim($this->ref);
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
if (isset($this->description)) $this->description=trim($this->description);
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null')."";
$sql.= " WHERE rowid=".$this->id;
if (empty($this->oldcopy))
{
$org=new self($this->db);
$org->fetch($this->id);
$this->oldcopy=$org;
}
$this->db->begin();
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null')."";
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
$this->db->begin();
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
//// Call triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('RESOURCE_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
if (! $error)
{
$action='update';
if (! $error)
{
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('RESOURCE_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
}
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
}
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
{
// We remove directory
if (! empty($conf->resource->dir_output))
{
$olddir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref);
$newdir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->ref);
if (file_exists($olddir))
{
$res = @rename($olddir, $newdir);
if (! $res)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir);
$error++;
}
}
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
if (! $error)
{
$action='update';
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* Load object in memory from database
@ -376,65 +401,84 @@ class Dolresource extends CommonObject
* @param int $notrigger Disable all triggers
* @return int >0 if OK, <0 if KO
*/
function delete($rowid, $notrigger=0)
{
global $user,$langs,$conf;
function delete($rowid, $notrigger=0)
{
global $user,$langs,$conf;
$error=0;
$error=0;
$this->db->begin();
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid =".$rowid;
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid =".$rowid;
dol_syslog(get_class($this), LOG_DEBUG);
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{
$this->error=$this->db->lasterror();
$error++;
}
}
else
{
$this->error=$this->db->lasterror();
$error++;
}
dol_syslog(get_class($this), LOG_DEBUG);
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{
$this->error=$this->db->lasterror();
$error++;
}
}
else
{
$this->error=$this->db->lasterror();
$error++;
}
// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('RESOURCE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('RESOURCE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
if (! $error)
{
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if (! empty($conf->resource->dir_output))
{
$dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->ref);
if (file_exists($dir))
{
$res=@dol_delete_dir_recursive($dir);
if (! $res)
{
$this->errors[] = 'ErrorFailToDeleteDir';
$error++;
}
}
}
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
/**
* Load resource objects into $this->lines