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

This commit is contained in:
Laurent Destailleur 2017-08-01 10:22:37 +02:00
commit b6a7ce6822
26 changed files with 283 additions and 172 deletions

View File

@ -147,8 +147,12 @@ Following changes may create regression for some external modules, but were nece
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
exists, but if an external module need action on it, it must provides itself its trigger file.
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode. So, if you set var
$multicompany_transverse_mode to 1 into your conf file, you must remove this line and a new key into
the Home - setup - other admin page.
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
* Some other change were done in the way we read permission of a user when module multicompany is enabled. You can
retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.
* The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output
content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow
hook specifications so you must return output into "resprint".

View File

@ -1194,7 +1194,7 @@ class ActionComm extends CommonObject
{
$libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':'');
}
$result.=$linkstart.img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend;
$result.=$linkstart.img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'class="valigntextbottom"':'class="classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1).$linkend;
}
if ($withpicto==1) $result.=' ';
$result.=$linkstart.$libelleshort.$linkend;

View File

@ -748,6 +748,15 @@ class Facture extends CommonInvoice
// Charge facture source
$facture=new Facture($this->db);
$this->fetch_optionals();
if(!empty($this->array_options)){
$facture->array_options = $this->array_options;
}
foreach($this->lines as &$line){
$line->fetch_optionals();//fetch extrafields
}
$facture->fk_facture_source = $this->fk_facture_source;
$facture->type = $this->type;

View File

@ -1482,7 +1482,7 @@ else
$sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,";
$sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
$sql.= " cd.fk_unit,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE cd.rowid = ".$object->lines[$cursorline-1]->id;
@ -1513,7 +1513,7 @@ else
if ($action != 'editline' || GETPOST('rowid') != $objp->rowid)
{
print '<tr '.$bcnd[$var].' valign="top">';
// Libelle
// Label
if ($objp->fk_product > 0)
{
print '<td>';
@ -1521,19 +1521,21 @@ else
$productstatic->type=$objp->ptype;
$productstatic->ref=$objp->pref;
$productstatic->entity=$objp->pentity;
$text = $productstatic->getNomUrl(1,'',20);
if ($objp->label)
$productstatic->label=$objp->plabel;
$text = $productstatic->getNomUrl(1,'',20);
if ($objp->plabel)
{
$text .= ' - ';
$productstatic->ref=$objp->label;
$text .= $productstatic->getNomUrl(0,'',16);
//$productstatic->ref=$objp->label;
//$text .= $productstatic->getNomUrl(0,'',16);
$text .= $objp->plabel;
}
$description = $objp->description;
// Add description in form
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
$text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'<br>'.dol_htmlentitiesbr($objp->description):'';
$description = ''; // Already added into main visible desc
}
@ -1543,7 +1545,7 @@ else
}
else
{
print '<td>'.dol_htmlentitiesbr($objp->description)."</td>\n";
print '<td>'.img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description)."</td>\n";
}
// TVA
print '<td align="center">';

View File

@ -1278,7 +1278,7 @@ class Contrat extends CommonObject
//// End call triggers
}
}
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
@ -1831,13 +1831,13 @@ class Contrat extends CommonObject
$text.=': &nbsp; &nbsp; ';
}
$text.=($mode == 7?'<div class="inline-block">':'');
$text.=($mode != 7 || $this->nbofserviceswait > 0) ? $this->nbofserviceswait.' '.$line->LibStatut(0,3).(($this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?' &nbsp; ':'') : '';
$text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.$line->LibStatut(0,3)).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?' &nbsp; ':'') : '';
$text.=($mode == 7?'</div><div class="inline-block">':'');
$text.=($mode != 7 || $this->nbofservicesopened > 0) ? $this->nbofservicesopened.' '.$line->LibStatut(4,3,0).(($this->nbofservicesexpired || $this->nbofservicesclosed)?' &nbsp; ':'') : '';
$text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.$line->LibStatut(4,3,0)).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?' &nbsp; ':'') : '';
$text.=($mode == 7?'</div><div class="inline-block">':'');
$text.=($mode != 7 || $this->nbofservicesexpired > 0) ? $this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).(($this->nbofservicesclosed)?' &nbsp; ':'') : '';
$text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.$line->LibStatut(4,3,1)).(($mode != 7 || $this->nbofservicesclosed)?' &nbsp; ':'') : '';
$text.=($mode == 7?'</div><div class="inline-block">':'');
$text.=($mode != 7 || $this->nbofservicesclosed > 0) ? $this->nbofservicesclosed.' '.$line->LibStatut(5,3) : '';
$text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.$line->LibStatut(5,3)) : '';
$text.=($mode == 7?'</div>':'');
return $text;
}

View File

@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
/**
* Class to manage the box to show last services lines
* Class to manage the box to show last contracted products/services lines
*/
class box_services_contracts extends ModeleBoxes
{
@ -72,6 +72,8 @@ class box_services_contracts extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$form = new Form($db);
$this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract",$max));
if ($user->rights->service->lire && $user->rights->contrat->lire)
@ -79,11 +81,12 @@ class box_services_contracts extends ModeleBoxes
$contractstatic=new Contrat($db);
$contratlignestatic=new ContratLigne($db);
$thirdpartytmp = new Societe($db);
$productstatic = new Product($db);
$sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " c.rowid, c.ref, c.statut as contract_status,";
$sql.= " cd.rowid as cdid, cd.tms as datem, cd.statut, cd.label, cd.description, cd.product_type as type,";
$sql.= " p.rowid as product_id, p.ref as product_ref";
$sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
@ -140,8 +143,41 @@ class box_services_contracts extends ModeleBoxes
}
}
// Label
if ($objp->product_id > 0)
{
$productstatic->id=$objp->product_id;
$productstatic->type=$objp->ptype;
$productstatic->ref=$objp->product_ref;
$productstatic->entity=$objp->pentity;
$productstatic->label=$objp->plabel;
$text = $productstatic->getNomUrl(1,'',20);
if ($objp->plabel)
{
$text .= ' - ';
//$productstatic->ref=$objp->label;
//$text .= $productstatic->getNomUrl(0,'',16);
$text .= $objp->plabel;
}
$description = $objp->description;
// Add description in form
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
//$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'<br>'.dol_htmlentitiesbr($objp->description):'';
$description = ''; // Already added into main visible desc
}
$s = $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
}
else
{
$s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description);
}
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'text' => $contratlignestatic->getNomUrl(1),
'text' => $s,
'asis' => 1
);

View File

@ -166,7 +166,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
}
$conf_css = $themepath."?lang=".$langs->defaultlang;
// Select templates
// Select templates dir
if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application
{
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/'));
@ -205,6 +205,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
// Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => GETPOST('entity','int'));
$reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. resArray is filled by hook.
$morelogincontent = $hookmanager->resArray['options']; // TODO Use here a resprints
// Login
$login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin));

View File

@ -808,8 +808,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
{
$langs->load("bills");
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
$newmenu->add("/fourn/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer);
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"),1,$user->rights->fournisseur->facture->lire, 'suppliers_bills_list');
$newmenu->add("/fourn/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create');
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"),1,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list');
if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_draft&amp;search_status=0", $langs->trans("BillShortStatusDraft"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft');

View File

@ -568,7 +568,7 @@ class pdf_crabe extends ModelePDFFactures
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
if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
{
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;

View File

@ -17,7 +17,7 @@
*/
// Need global variable $title to be defined by caller (like dol_loginfunction)
// Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...);
header('Cache-Control: Public, must-revalidate');
header("Content-type: text/html; charset=".$conf->file->character_set_client);
@ -123,8 +123,8 @@ if ($disablenofollow) echo '</a>';
</span>
</td></tr>
<?php
if (! empty($hookmanager->resArray['options'])) {
foreach ($hookmanager->resArray['options'] as $format => $option)
if (! empty($morelogincontent) && is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option)
{
if ($format == 'table') {
echo '<!-- Option by hook -->';
@ -249,7 +249,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) {
} else {
$resgetcommitstrip = getURLContent("http://www.commitstrip.com/en/feed/");
}
if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200')
if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200')
{
$xml = simplexml_load_string($resgetcommitstrip['content']);
$little = $xml->channel->item[0]->children('content',true);
@ -278,8 +278,8 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) {
<?php if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?>
<?php
if (! empty($hookmanager->resArray['options'])) {
foreach ($hookmanager->resArray['options'] as $format => $option)
if (! empty($morelogincontent) && is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option)
{
if ($format == 'js') {
echo "\n".'<!-- Javascript by hook -->';

View File

@ -924,16 +924,16 @@ class Cronjob extends CommonObject
// load classes
if (! $error)
{
$ret=dol_include_once($this->classesname);
if ($ret===false || (! class_exists($this->objectname)))
{
$this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname);
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
$this->lastoutput = $this->error;
$this->lastresult = -1;
$retval = $this->lastresult;
$error++;
}
$ret=dol_include_once($this->classesname);
if ($ret===false || (! class_exists($this->objectname)))
{
$this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname);
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
$this->lastoutput = $this->error;
$this->lastresult = -1;
$retval = $this->lastresult;
$error++;
}
}
// test if method exists
@ -973,6 +973,7 @@ class Cronjob extends CommonObject
$object = new $this->objectname($this->db);
$params_arr = array_map('trim', explode(",",$this->params));
if (!is_array($params_arr))
{
$result = call_user_func(array($object, $this->methodename), $this->params);
@ -982,7 +983,7 @@ class Cronjob extends CommonObject
$result = call_user_func_array(array($object, $this->methodename), $params_arr);
}
if ($result===false || $result != 0)
if ($result === false || (! is_bool($result) && $result != 0))
{
$langs->load("errors");
dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$object->error, LOG_ERR);
@ -1031,7 +1032,7 @@ class Cronjob extends CommonObject
$result = call_user_func_array($this->methodename, $params_arr);
}
if ($result === false || $result != 0)
if ($result === false || (! is_bool($result) && $result != 0))
{
$langs->load("errors");
dol_syslog(get_class($this)."::run_jobs result=".$result, LOG_ERR);

View File

@ -118,7 +118,7 @@ $langs->load("contracts");
if (empty($user->societe_id))
{
$boxstat.='<div class="box">';
$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">';
$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable nohover" width="100%">';
$boxstat.='<tr class="liste_titre">';
$boxstat.='<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>';
$boxstat.='</tr>';
@ -541,7 +541,7 @@ if ($showweather)
$boxwork.='</tr>';
}
$boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer">';
$boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer centpercent">';
// Show dashboard
$nbworkboardempty=0;

View File

@ -78,6 +78,11 @@ InvoiceDeleted=Invoice deleted
PRODUCT_CREATEInDolibarr=Product %s created
PRODUCT_MODIFYInDolibarr=Product %s modified
PRODUCT_DELETEInDolibarr=Product %s deleted
EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created
EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated
EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved
EXPENSE_REPORT_DELETEInDolibarr=Expense report %s deleted
EXPENSE_REPORT_REFUSEDInDolibarr=Expense report %s refused
##### End agenda events #####
AgendaModelModule=Document templates for event
DateActionStart=Start date

View File

@ -23,7 +23,7 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st
ClosedProjectsAreHidden=Closed projects are not visible.
TasksPublicDesc=This view presents all projects and tasks you are allowed to read.
TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything).
AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it.
AllTaskVisibleButEditIfYouAreAssigned=All tasks for qualified projects are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it.
OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it.
ImportDatasetTasks=Tasks of projects
ProjectCategories=Project tags/categories

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$search_project_user = GETPOST('search_project_user','int');
$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
if ($search_project_user == $user->id) $mine = 1;
// Security check
$socid=0;
@ -73,7 +75,7 @@ $morehtml='';
$morehtml.='<form name="projectform">';
$morehtml.='<SELECT name="mode">';
$morehtml.='<option name="all" value="all"'.($mine?'':' selected').'>'.$titleall.'</option>';
$morehtml.='<option name="mine" value="mine"'.($mine?' selected':'').'>'.$langs->trans("ProjectsImContactFor").'</option>';
$morehtml.='<option name="mine" value="'.$user->id.'"'.(($search_project_user == $user->id)?' selected':'').'>'.$langs->trans("ProjectsImContactFor").'</option>';
$morehtml.='</SELECT>';
$morehtml.='<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">';
@ -98,7 +100,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
{
$listofsearchfields['search_task']=array('text'=>'Task');
}
if (count($listofsearchfields))
{
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
@ -114,7 +116,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '</tr>';
$i++;
}
print '</table>';
print '</table>';
print '</form>';
print '<br>';
}
@ -148,7 +150,7 @@ if ( $resql )
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
print '<td>';
$projectstatic->id=$row->rowid;
@ -205,7 +207,7 @@ if ( $resql )
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
print '<td>';
$projectstatic->id=$row->rowid;
@ -237,14 +239,14 @@ print "</table>";
if ($db->type != 'pgsql')
{
print '<br>';
// Affichage de la liste des projets de la semaine
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
@ -256,16 +258,16 @@ if ($db->type != 'pgsql')
$sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ...";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$resql = $db->query($sql);
if ( $resql )
{
$total = 0;
$var=true;
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
print '<td>';
$projectstatic->id=$row->rowid;
@ -278,7 +280,7 @@ if ($db->type != 'pgsql')
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
else
@ -302,7 +304,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now,"%B %Y").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
@ -314,12 +316,12 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
$sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public";
$resql = $db->query($sql);
if ( $resql )
{
$var=false;
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
@ -331,7 +333,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
}
$db->free($resql);
}
@ -383,7 +385,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
}
$db->free($resql);
}
@ -430,12 +432,12 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
}
else dol_print_error($db);
if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found
// Tasks for all resources of all opened projects and time spent for each task/resource
// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
// Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,";
@ -489,7 +491,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
while ($i < $num && $i < $max)
{
$obj = $db->fetch_object($resql);
$username='';
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
@ -509,7 +511,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
$projectstatic->public = $obj->public;
$projectstatic->dateo = $db->jdate($obj->projdateo);
$projectstatic->datee = $db->jdate($obj->projdatee);
print $projectstatic->getNomUrl(1,'',0,'','<br>');
print '</td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
@ -536,7 +538,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
$taskstatic->datee = $db->jdate($obj->datee);
print '<td align="center">'.dol_print_date($db->jdate($obj->dateo),'day').'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->datee),'day');
print dol_print_date($obj->date_end,'dayhour');
print dol_print_date($obj->date_end,'dayhour');
if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
print '</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';

View File

@ -82,13 +82,18 @@ else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day,
if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id)
{
$usertoprocess=$user;
$search_usertoprocessid=$usertoprocess->id;
}
else
elseif (search_usertoprocessid > 0)
{
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
$search_usertoprocessid=$usertoprocess->id;
}
else
{
$usertoprocess=new User($db);
}
$search_usertoprocessid=$usertoprocess->id;
$object=new Task($db);
@ -305,9 +310,9 @@ $next_month = $next['mon'];
$next_day = $next['mday'];
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
if ($mine || ($usertoprocess->id == $user->id)) $title=$langs->trans("MyTimeSpent");
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id)
{
@ -320,7 +325,7 @@ $morewherefilter='';
if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref);
if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label);
if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty);
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
//var_dump($tasksarray);
@ -362,13 +367,16 @@ dol_fiche_head($head, 'inputperday', '', -1, 'task');
// Show description of content
print '<div class="hideonsmartphone">';
if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
if (empty($usertoprocess->id) || $usertoprocess->id < 0)
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
}
}
if ($mine)
if ($mine || ($usertoprocess->id == $user->id))
{
print $langs->trans("OnlyYourTaskAreVisible").'<br>';
}
@ -413,7 +421,7 @@ $moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
$includeonly='hierachyme';
if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.='</div>';
if (! empty($moreforfilter))

View File

@ -95,13 +95,18 @@ $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id)
{
$usertoprocess=$user;
$search_usertoprocessid=$usertoprocess->id;
}
else
elseif (search_usertoprocessid > 0)
{
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
$search_usertoprocessid=$usertoprocess->id;
}
else
{
$usertoprocess=new User($db);
}
$search_usertoprocessid=$usertoprocess->id;
$object=new Task($db);
@ -300,9 +305,9 @@ $taskstatic = new Task($db);
$thirdpartystatic = new Societe($db);
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
if ($mine || $usertoprocess->id == $user->id) $title=$langs->trans("MyTimeSpent");
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project
//var_dump($projectsListId);
if ($id)
{
@ -316,7 +321,7 @@ if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref
if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label);
if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty);
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
//var_dump($tasksarray);
@ -356,13 +361,16 @@ dol_fiche_head($head, 'inputperweek', '', -1, 'task');
// Show description of content
print '<div class="hideonsmartphone">';
if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
if (empty($usertoprocess->id) || $usertoprocess->id < 0)
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
}
}
if ($mine)
if ($mine || ($usertoprocess->id == $user->id))
{
print $langs->trans("OnlyYourTaskAreVisible").'<br>';
}
@ -408,7 +416,7 @@ $moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
$includeonly='hierachyme';
if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter.='</div>';
if (! empty($moreforfilter))

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load("projects");
$langs->load("companies");
$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
$search_project_user = GETPOST('search_project_user','int');
$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
if ($search_project_user == $user->id) $mine = 1;
// Security check
$socid=0;
@ -122,7 +123,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
{
$listofsearchfields['search_project']=array('text'=>'Project');
}
if (count($listofsearchfields))
{
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
@ -138,7 +139,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '</tr>';
$i++;
}
print '</table>';
print '</table>';
print '</form>';
print '<br>';
}
@ -185,7 +186,7 @@ if ( $resql )
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
if ($obj->socid)
@ -217,9 +218,9 @@ if (! empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA))
{
// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
// Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list
print '<br>';
print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array());
}

View File

@ -261,8 +261,8 @@ if ($search_project_user > 0)
}
$sql.= " WHERE p.entity IN (".getEntity('project').')';
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
// No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
if ($socid > 0) $sql.= " AND (p.fk_soc = ".$socid.")";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
@ -487,19 +487,25 @@ print '<tr class="liste_titre_filter">';
if (! empty($arrayfields['p.ref']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="6">';
print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
print '</td>';
}
if (! empty($arrayfields['p.title']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_label" size="8" value="'.$search_label.'">';
print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_societe" size="8" value="'.$search_societe.'">';
if ($socid > 0)
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty->fetch($socid);
$search_societe=$tmpthirdparty->nom;
}
print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
print '</td>';
}
// Sale representative
@ -511,8 +517,8 @@ if (! empty($arrayfields['commercial']['checked']))
if (! empty($arrayfields['p.dateo']['checked']))
{
print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
$formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5);
print '</td>';
}
@ -520,8 +526,8 @@ if (! empty($arrayfields['p.dateo']['checked']))
if (! empty($arrayfields['p.datee']['checked']))
{
print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
$formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5);
print '</td>';
}

View File

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
* Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro>
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
* Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro>
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 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
@ -30,6 +31,11 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOLOGIN')) define('NOLOGIN','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) define("DOLENTITY", $entity);
// librarie core
// Dolibarr environment
$res = @include("../../main.inc.php"); // From htdocs directory

View File

@ -63,7 +63,7 @@ require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined)
if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']);
if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login'],'',1);
// Define css type

View File

@ -64,7 +64,7 @@ require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined)
if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']);
if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login'],'',1);
// Define css type

View File

@ -223,7 +223,7 @@ class User extends CommonObject
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
else
$sql.= " WHERE u.entity IN (0, ".($entity!=''?$entity:$conf->entity).")"; // search in entity provided in parameter
$sql.= " WHERE u.entity IN (0, ".(($entity!='' && $entity >= 0)?$entity:$conf->entity).")"; // search in entity provided in parameter
}
if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba
@ -238,8 +238,8 @@ class User extends CommonObject
{
$sql.= " AND u.rowid = ".$id;
}
$sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
$sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
$result = $this->db->query($sql);
if ($result)
{
@ -667,7 +667,14 @@ class User extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= ", ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = ur.fk_id";
$sql.= " AND ur.entity = ".$conf->entity;
if (! empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY))
{
$sql.= " AND r.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?"1,":"").$conf->entity.")";
}
else
{
$sql.= " AND ur.entity = ".$conf->entity;
}
$sql.= " AND ur.fk_user= ".$this->id;
$sql.= " AND r.perms IS NOT NULL";
if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'";
@ -713,8 +720,19 @@ class User extends CommonObject
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
$sql.= " ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = gr.fk_id";
$sql.= " AND gr.entity = ".$conf->entity;
$sql.= " AND r.entity = ".$conf->entity;
if (! empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY))
{
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql.= " AND gu.entity IN (0,".$conf->entity.")";
} else {
$sql.= " AND r.entity = ".$conf->entity;
}
}
else
{
$sql.= " AND gr.entity = ".$conf->entity;
$sql.= " AND r.entity = ".$conf->entity;
}
$sql.= " AND gr.fk_usergroup = gu.fk_usergroup";
$sql.= " AND gu.fk_user = ".$this->id;
$sql.= " AND r.perms IS NOT NULL";

View File

@ -70,12 +70,12 @@ if (empty($reshook)) {
$result = $ldap->update($dn, $info, $user, $olddn);
if ($result >= 0)
if ($result >= 0)
{
setEventMessages($langs->trans("UserSynchronized"), null, 'mesgs');
$db->commit();
}
else
}
else
{
setEventMessages($ldap->error, $ldap->errors, 'errors');
$db->rollback();
@ -104,6 +104,7 @@ if ($user->rights->user->user->lire || $user->admin) {
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -128,7 +129,7 @@ if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
{
$userSID = $ldap->getObjectSid($object->login);
}
print '<tr><td width="25%" valign="top">'.$langs->trans("SID").'</td>';
print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>';
print '<td>'.$userSID.'</td>';
print "</tr>\n";
}
@ -150,6 +151,8 @@ print '</table>';
print '</div>';
dol_fiche_end();
/*
* Barre d'actions
*/

View File

@ -186,7 +186,7 @@ class ProductCombination
{
$nb = 0;
$sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")";
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@ -195,7 +195,7 @@ class ProductCombination
return $nb;
}
/**
* Creates a product attribute combination
*
@ -249,9 +249,10 @@ class ProductCombination
/**
* Deletes a product combination
*
* @return int <0 KO >0 OK
* @param User $user Object user
* @return int <0 if KO, >0 if OK
*/
public function delete()
public function delete(User $user)
{
$this->db->begin();

View File

@ -101,8 +101,8 @@ if ($_POST) {
if (!$features) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors');
}
else
}
else
{
$weight_impact = price2num($weight_impact);
$price_impact = price2num($price_impact);
@ -149,8 +149,8 @@ if ($_POST) {
$db->rollback();
}
}
elseif (! empty($massaction))
}
elseif (! empty($massaction))
{
$bulkaction = $massaction;
$error = 0;
@ -203,7 +203,7 @@ if ($_POST) {
setEventMessage($langs->trans('RecordSaved'));
}
}
}
elseif ($valueid > 0) {
if ($prodcomb->fetch($valueid) < 0) {
@ -234,7 +234,7 @@ if ($action === 'confirm_deletecombination') {
$db->begin();
if ($prodcomb->delete() > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete() > 0) {
if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) {
$db->commit();
setEventMessage($langs->trans('RecordSaved'));
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2));
@ -288,26 +288,26 @@ if ($action === 'confirm_deletecombination') {
$form = new Form($db);
if (! empty($id) || ! empty($ref))
if (! empty($id) || ! empty($ref))
{
llxHeader("", "", $langs->trans("CardProduct".$object->type));
$showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'combinations', $titre, 0, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter=" fk_product_type = ".$object->type;
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1);
dol_fiche_end();
// Create or edit a varian
if ($action == 'add' || ($action == 'edit')) {
@ -343,7 +343,7 @@ if (! empty($id) || ! empty($ref))
info: []
};
<?php
<?php
foreach ($productCombination2ValuePairs1 as $pc2v) {
$prodattr_val->fetch($pc2v->fk_prod_attr_val);
?>
@ -355,8 +355,8 @@ if (! empty($id) || ! empty($ref))
label: '<?php echo $prodattr_val->value ?>'
}
};
<?php
}
<?php
}
?>
restoreAttributes = function() {
@ -369,7 +369,7 @@ if (! empty($id) || ! empty($ref))
});
};
jQuery(document).ready(function() {
jQuery("select#attribute").change(function () {
console.log("Change of field variant attribute");
@ -404,18 +404,18 @@ if (! empty($id) || ! empty($ref))
});
});
</script>
<?php
<?php
}
print '<form method="post" id="combinationform" action="'.$_SERVER["PHP_SELF"].'#parttoaddvariant">'."\n";
print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
print '<input type="hidden" name="action" value="add">'."\n";
print dol_fiche_head();
?>
<table class="border" style="width: 100%">
<?php if ($action == 'add') { ?>
<!-- Variant -->
@ -445,7 +445,7 @@ if (! empty($id) || ! empty($ref))
</tr>
</table>
<hr>
<?php }
<?php }
?>
<table class="border" style="width: 100%">
<tr>
@ -495,12 +495,12 @@ if (! empty($id) || ! empty($ref))
&nbsp;
<input type="submit" name="cancel" value="<?php echo $langs->trans('Cancel'); ?>" class="button">
</div>
<?php
print '</form>';
}
else
else
{
if ($action === 'delete') {
@ -538,7 +538,7 @@ if (! empty($id) || ! empty($ref))
$comb2val = new ProductCombination2ValuePair($db);
if ($productCombinations)
if ($productCombinations)
{
?>
@ -563,36 +563,36 @@ if (! empty($id) || ! empty($ref))
});
</script>
<?php }
<?php }
// Buttons
print '<div class="tabsAction">';
print ' <div class="inline-block divButAction">';
if ($productCombinations) {
print '<a href="combinations.php?id='.$object->id.'&action=copy" class="butAction">'.$langs->trans('PropagateVariant').'</a>';
}
print '<a href="combinations.php?id='.$object->id.'&action=add#parttoaddvariant" class="butAction">'.$langs->trans('NewProductCombination').'</a>'; // NewVariant
// Too much bugged page.
/*
print '<a href="generator.php?id='.$object->id.'" class="butAction">'.$langs->trans('ProductCombinationGenerator').'</a>';
*/
print ' </div>';
print '</div>';
$arrayofselected=is_array($toselect)?$toselect:array();
// List of variants
print '<form method="POST" action="#parttoaddvariant">';
// List of mass actions available
/*
$arrayofmassactions = array(
@ -603,7 +603,7 @@ if (! empty($id) || ! empty($ref))
if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
*/
$aaa='';
if (count($productCombinations))
{
@ -620,11 +620,11 @@ if (! empty($id) || ! empty($ref))
$aaa .= '<input type="submit" value="'.dol_escape_htmltag($langs->trans("Apply")).'" class="button">';
}
$massactionbutton = $aaa;
$title = $langs->trans("ProductCombinations");
print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $aaa, 0);
print '<div class="div-table-responsive">';
?>
<table class="liste">
@ -636,7 +636,7 @@ if (! empty($id) || ! empty($ref))
<td class="liste_titre center"><?php echo $langs->trans('OnSell') ?></td>
<td class="liste_titre center"><?php echo $langs->trans('OnBuy') ?></td>
<td class="liste_titre"></td>
<?php
<?php
print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showCheckAddButtons('checkforselect', 1);
print $searchpicto;
@ -644,23 +644,23 @@ if (! empty($id) || ! empty($ref))
?>
</tr>
<?php
if (count($productCombinations))
{
foreach ($productCombinations as $currcomb) {
$prodstatic->fetch($currcomb->fk_product_child);
$prodstatic->fetch($currcomb->fk_product_child);
?>
<tr class="oddeven">
<td><?php echo $prodstatic->getNomUrl(1) ?></td>
<td>
<?php
$productCombination2ValuePairs = $comb2val->fetchByFkCombination($currcomb->id);
$iMax = count($productCombination2ValuePairs);
for ($i = 0; $i < $iMax; $i++) {
echo dol_htmlentities($productCombination2ValuePairs[$i]);
if ($i !== ($iMax - 1)) {
echo ', ';
}
@ -674,7 +674,7 @@ if (! empty($id) || ! empty($ref))
<a class="paddingleft paddingright" href="<?php echo dol_buildpath('/variants/combinations.php?id='.$id.'&action=edit&valueid='.$currcomb->id, 2) ?>"><?php echo img_edit() ?></a>
<a class="paddingleft paddingright" href="<?php echo dol_buildpath('/variants/combinations.php?id='.$id.'&action=delete&valueid='.$currcomb->id, 2) ?>"><?php echo img_delete() ?></a>
</td>
<?php
<?php
print '<td class="nowrap" align="center">';
if ($productCombinations || $massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
@ -690,7 +690,7 @@ if (! empty($id) || ! empty($ref))
}
else
{
print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
}
?>
</table>