diff --git a/ChangeLog b/ChangeLog index 3cfc257bbb2..154222d599a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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". diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 70b2acb86b7..84e75e06cbd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -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; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 508f71fdc86..598616798b6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c13571dd6cb..90ec4c7edba 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -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 ''; - // Libelle + // Label if ($objp->fk_product > 0) { print ''; @@ -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)?'
'.dol_htmlentitiesbr($objp->description):''; + $text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; $description = ''; // Already added into main visible desc } @@ -1543,7 +1545,7 @@ else } else { - print ''.dol_htmlentitiesbr($objp->description)."\n"; + print ''.img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description)."\n"; } // TVA print ''; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0c3ee14666a..bf31ef4070c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -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.=':     '; } $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofserviceswait > 0) ? $this->nbofserviceswait.' '.$line->LibStatut(0,3).(($this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.$line->LibStatut(0,3)).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesopened > 0) ? $this->nbofservicesopened.' '.$line->LibStatut(4,3,0).(($this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.$line->LibStatut(4,3,0)).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? $this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).(($this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.$line->LibStatut(4,3,1)).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
':''); - $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?'
':''); return $text; } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index ccdcfbdbe5a..1795f7c6f2f 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -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)?'
'.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 ); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 248c3bde43e..817fd2be8da 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -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)); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7715d09d2b5..38232a73876 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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&search_status=0", $langs->trans("BillShortStatusDraft"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft'); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6c10f67507f..4f72175ca72 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -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; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 9cddb8d183d..a1fdc3e9e9d 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -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 ''; resArray['options'])) { - foreach ($hookmanager->resArray['options'] as $format => $option) +if (! empty($morelogincontent) && is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) { if ($format == 'table') { echo ''; @@ -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)) { global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?> 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".''; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index b7de98b0c1c..64c2d026ab4 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -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); diff --git a/htdocs/index.php b/htdocs/index.php index 9b190ac1e2b..f76526d23ea 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -118,7 +118,7 @@ $langs->load("contracts"); if (empty($user->societe_id)) { $boxstat.='
'; - $boxstat.=''; + $boxstat.='
'; $boxstat.=''; $boxstat.=''; $boxstat.=''; @@ -541,7 +541,7 @@ if ($showweather) $boxwork.=''; } -$boxwork.=''; $i++; } - print '
'.$langs->trans("DolibarrStateBoard").'
'; +$boxwork.='
'; // Show dashboard $nbworkboardempty=0; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 38a40315985..a62db9c7158 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -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 diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index d940555f206..a30768709f9 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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 diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 7bea4bf3213..8418561aa30 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -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.='
'; $morehtml.=''; $morehtml.=''; @@ -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 ''; @@ -114,7 +116,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print '
'; + print ''; print ''; print '
'; } @@ -148,7 +150,7 @@ if ( $resql ) while ($row = $db->fetch_object($resql)) { - + print ''; print ''; $projectstatic->id=$row->rowid; @@ -205,7 +207,7 @@ if ( $resql ) while ($row = $db->fetch_object($resql)) { - + print ''; print ''; $projectstatic->id=$row->rowid; @@ -237,14 +239,14 @@ print ""; if ($db->type != 'pgsql') { print '
'; - + // Affichage de la liste des projets de la semaine print ''; print ''; print ''; print ''; print "\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 ''; print '\n"; $total += $row->nb; } - + $db->free($resql); } else @@ -302,7 +304,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print ''; print ''; print "\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 ''; @@ -331,7 +333,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print ''; print ''; print "\n"; - + } $db->free($resql); } @@ -383,7 +385,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print ''; print ''; print "\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,'','
'); print ''; 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 ''; print ''; print ''; $i++; } - print '
'.$langs->trans("ActivityOnProjectThisWeek").''.$langs->trans("Time").'
'; $projectstatic->id=$row->rowid; @@ -278,7 +280,7 @@ if ($db->type != 'pgsql') print "
'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now,"%B %Y").''.$langs->trans("Time").'
'.convertSecondToTime($row->nb, 'allhourmin').'
'.convertSecondToTime($row->nb, 'allhourmin').'
'.dol_print_date($db->jdate($obj->dateo),'day').''.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 ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 7b1f50bb50c..45d7aa237ad 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -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 '
'; -if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; - else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } } -if ($mine) +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'
'; } @@ -413,7 +421,7 @@ $moreforfilter.='
'; $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.='
'; if (! empty($moreforfilter)) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 3410ba1d949..b4fcd68a3c9 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -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 '
'; -if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; - else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } } -if ($mine) +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'
'; } @@ -408,7 +416,7 @@ $moreforfilter.='
'; $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.='
'; if (! empty($moreforfilter)) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index c7f0181dbf5..7aecd454365 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -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 '
'; @@ -138,7 +139,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print '
'; + print ''; print ''; print '
'; } @@ -185,7 +186,7 @@ if ( $resql ) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; 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 '
'; - + print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array()); } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9e2971195e3..7ee41fcd024 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -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 ''; if (! empty($arrayfields['p.ref']['checked'])) { print ''; - print ''; + print ''; print ''; } if (! empty($arrayfields['p.title']['checked'])) { print ''; - print ''; + print ''; print ''; } if (! empty($arrayfields['s.nom']['checked'])) { print ''; - print ''; + if ($socid > 0) + { + $tmpthirdparty=new Societe($db); + $tmpthirdparty->fetch($socid); + $search_societe=$tmpthirdparty->nom; + } + print ''; print ''; } // Sale representative @@ -511,8 +517,8 @@ if (! empty($arrayfields['commercial']['checked'])) if (! empty($arrayfields['p.dateo']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5); print ''; } @@ -520,8 +526,8 @@ if (! empty($arrayfields['p.dateo']['checked'])) if (! empty($arrayfields['p.datee']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5); print ''; } diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 3ca058acb8a..725aea8825d 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -1,7 +1,8 @@ - * Copyright (C) 2013-2015 Laurent Destailleur +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * 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 diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d6dad12a139..d7e9990cb7a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -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 diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 20e8596d8b3..0e3e620da58 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -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 diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2ff98899462..e03bdd8ccd5 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -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"; diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 96c0ac881be..49739fa7c77 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -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 '
'; print '
'; print ''; @@ -128,7 +129,7 @@ if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") { $userSID = $ldap->getObjectSid($object->login); } - print ''; + print ''; print ''; print "\n"; } @@ -150,6 +151,8 @@ print '
'.$langs->trans("SID").'
'.$langs->trans("SID").''.$userSID.'
'; print '
'; +dol_fiche_end(); + /* * Barre d'actions */ diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f6eb4c58935..d3e6964aea6 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -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(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 76a091ad8a2..0ec1bf07b68 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -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 = ''.$langs->trans("BackToList").''; $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: [] }; - fetch($pc2v->fk_prod_attr_val); ?> @@ -355,8 +355,8 @@ if (! empty($id) || ! empty($ref)) label: 'value ?>' } }; - 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)) }); }); - - '."\n"; print ''."\n"; print ''."\n"; - + print dol_fiche_head(); - + ?> - + @@ -445,7 +445,7 @@ if (! empty($id) || ! empty($ref))

- @@ -495,12 +495,12 @@ if (! empty($id) || ! empty($ref))   - + '; } - 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)) }); - '; - + print '
'; if ($productCombinations) { print ''.$langs->trans('PropagateVariant').''; } - + print ''.$langs->trans('NewProductCombination').''; // NewVariant - + // Too much bugged page. /* print ''.$langs->trans('ProductCombinationGenerator').''; */ - + print '
'; - + print ''; - - - + + + $arrayofselected=is_array($toselect)?$toselect:array(); - - + + // List of variants print ''; - - + + // 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 .= ''; } $massactionbutton = $aaa; - + $title = $langs->trans("ProductCombinations"); - + print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $aaa, 0); - + print '
'; ?>
@@ -636,7 +636,7 @@ if (! empty($id) || ! empty($ref)) - '; $searchpicto=$form->showCheckAddButtons('checkforselect', 1); print $searchpicto; @@ -644,23 +644,23 @@ if (! empty($id) || ! empty($ref)) ?> fetch($currcomb->fk_product_child); + $prodstatic->fetch($currcomb->fk_product_child); ?> - '; 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 ''; + print ''; } ?>
trans('OnSell') ?> trans('OnBuy') ?>
getNomUrl(1) ?> 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))
'.$langs->trans("None").'
'.$langs->trans("None").'