diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 7824cd62614..da6989b41fd 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent @@ -990,7 +990,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; if (! empty($conf->global->MAIN_MULTILANGS)) { - $selectedlang = $langs->defaultlang; + $selectedlang = GETPOSTISSET('langcode','aZ09')?GETPOST('langcode','aZ09'):$langs->defaultlang; if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]}; print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index fa5a64e192a..32ebc4fb26e 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -99,6 +99,7 @@ class DolibarrApi // Remove $db object property for object unset($object->db); + unset($object->isextrafieldmanaged); unset($object->ismultientitymanaged); unset($object->restrictiononfksoc); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index a46b79d7d1b..00dd78ca1bd 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1513,7 +1513,7 @@ else //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); if (! $object->isMaxNbGenReached()) { - if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); + if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); } else { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 0cfb0347a2d..cf41f864f05 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -607,7 +607,7 @@ if ($resql) print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); if (! $invoicerectmp->isMaxNbGenReached()) { - if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 13978b5f0cd..0e55c9ef7de 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1357,7 +1357,7 @@ class Form * @param string $moreclass Add more class to class style * @param bool $options_only Return options only (for ajax treatment) * @param integer $showsoc Add company into label - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param string $htmlid Html id to use instead of htmlname @@ -1566,7 +1566,7 @@ class Form else $sql.= " WHERE u.entity IS NOT NULL"; } else - { + { if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; @@ -3716,7 +3716,7 @@ class Form // Now add questions $more.=''."\n"; - $more.=''."\n"; + if (! empty($formquestion['text'])) $more.=''."\n"; foreach ($formquestion as $key => $input) { if (is_array($input) && ! empty($input)) @@ -3727,29 +3727,28 @@ class Form if ($input['type'] == 'text') { - $more.=''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'password') { - $more.=''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'select') { - $more.=''; + if (! empty($input['label'])) $more.=$input['label'].''."\n"; } else if ($input['type'] == 'checkbox') { $more.=''; - $more.=''; - if ($i==0) $more.=''; - else $more.=''; - $more.=''; + else $more.=' '; + $more.=''.$input['label'].''; + $more.=''."\n"; $formquestion[] = array('name'=>$input['name'].'day'); @@ -3783,15 +3781,15 @@ class Form } else if ($input['type'] == 'other') { - $more.=''; + if (! empty($input['label'])) $more.=$input['label'].''."\n"; } else if ($input['type'] == 'onecolumn') { - $more.=''."\n"; } @@ -3845,14 +3843,14 @@ class Form $( "#'.$dialogconfirm.'" ).dialog( { autoOpen: '.($autoOpen ? "true" : "false").','; - if ($newselectedchoice == 'no') - { - $formconfirm.=' + if ($newselectedchoice == 'no') + { + $formconfirm.=' open: function() { $(this).parent().find("button.ui-button:eq(2)").focus(); },'; - } - $formconfirm.=' + } + $formconfirm.=' resizable: false, height: "'.$height.'", width: "'.$width.'", diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 111852f2c38..51184e9fed7 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -56,10 +56,11 @@ class FormAdmin * @param int $disabled Disable edit of select * @param string $morecss Add more css styles * @param int $showcode Add language code into label + * @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @return string Return HTML select string with list of languages */ // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - function select_language($selected='', $htmlname='lang_id', $showauto=0, $filter=null, $showempty='', $showwarning=0, $disabled=0, $morecss='', $showcode=0) + function select_language($selected='', $htmlname='lang_id', $showauto=0, $filter=null, $showempty='', $showwarning=0, $disabled=0, $morecss='', $showcode=0, $forcecombo=0) { global $langs; @@ -110,8 +111,11 @@ class FormAdmin $out.= ''; // Make select dynamic - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($htmlname); + if (! $forcecombo) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($htmlname); + } return $out; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 361f8370b78..ba9bc2f03bc 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -292,7 +292,7 @@ class FormMail extends Form $disablebademails=1; - // Define output language + // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels']; @@ -1088,7 +1088,7 @@ class FormMail extends Form $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; if ($label) $sql.=" AND label ='".$db->escape($label)."'"; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; + if (! ($id > 0) && is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 855c70ef05e..0d46dc7eacc 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -331,7 +331,7 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage=0, $ print '

'."\n"; print $fromcompany->name.'
'; print $line1; - if (strlen($line1+$line2) > 50) print '
'; + if (strlen($line1.$line2) > 50) print '
'; else print ' - '; print $line2; print '
'."\n"; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e11fd409a6e..db1aff3d444 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -104,9 +104,24 @@ function project_prepare_head($object) $head[$h][2] = 'tasks'; $h++; + $nbTimeSpent=0; + $sql = "SELECT t.rowid"; + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " WHERE t.fk_task = pt.rowid"; + $sql .= " AND pt.fk_projet =".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbTimeSpent=1; + } + else dol_print_error($db); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; $head[$h][1] = $langs->trans("TimeSpent"); - //if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; + if ($nbTimeSpent > 0) $head[$h][1].= ' ...'; $head[$h][2] = 'timespent'; $h++; } @@ -165,9 +180,10 @@ function task_prepare_head($object) // Is there timespent ? $nbTimeSpent=0; $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - $sql .= " AND t.fk_task =".$object->id; + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE t.fk_task =".$object->id; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 74f61fd288f..de84c653060 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -349,12 +349,12 @@ class modAdherent extends DolibarrModules // Cronjobs $this->cronjobs = array( 0=>array( - 'label'=>'SendReminderForExpiredSubscription', + 'label'=>'SendReminderForExpiredSubscriptionTitle', 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', 'objectname'=>'Adherent', 'method'=>'sendReminderForExpiredSubscription', 'parameters'=>'10', - 'comment'=>'sendReminderForExpiredSubscription', + 'comment'=>'SendReminderForExpiredSubscription', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 6b052ca59d4..855620756a7 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT."/core/class/html.formcron.class.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'cron')); +$langs->loadLangs(array('admin', 'cron', 'members')); if (!$user->rights->cron->create) accessforbidden(); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 238bd17d5c5..cc3b8e879ed 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","cron","bills")); +$langs->loadLangs(array("admin","cron","bills","members")); if (!$user->rights->cron->read) accessforbidden(); diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 1aa164bd33c..50527690bbb 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -117,27 +117,29 @@ class MyModuleApi extends DolibarrApi $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $restictonsocid = 0; // Set to 1 if there is a field socid in table of object + // If the internal user must only see his customers, force searching by him - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if ($restictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT s.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."myobject as s"; + $sql = "SELECT t.rowid"; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."myobject_mytable as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE s.fk_stcomm = st.id"; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql.= " WHERE 1 = 1"; // Example of use $mode //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $sql.= ' AND s.entity IN ('.getEntity('myobject').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; - if ($socid) $sql.= " AND s.fk_soc = ".$socid; - if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $tmpobject = new MyObject($db); + if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('myobject').')'; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; + if ($restictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($search_sale > 0) + if ($restictonsocid && $search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } @@ -171,7 +173,7 @@ class MyModuleApi extends DolibarrApi $obj = $db->fetch_object($result); $myobject_static = new MyObject($db); if($myobject_static->fetch($obj->rowid)) { - $obj_ret[] = parent::_cleanObjectDatas($myobject_static); + $obj_ret[] = $this->_cleanObjectDatas($myobject_static); } $i++; } @@ -254,7 +256,7 @@ class MyModuleApi extends DolibarrApi */ function delete($id) { - if(! DolibarrApiAccess::$user->rights->myobject->supprimer) { + if(! DolibarrApiAccess::$user->rights->myobject->delete) { throw new RestException(401); } $result = $this->myobject->fetch($id); @@ -266,7 +268,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->myobject->delete($id)) + if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) { throw new RestException(500); } @@ -280,6 +282,27 @@ class MyModuleApi extends DolibarrApi } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) + { + $object = parent::_cleanObjectDatas($object); + + /*unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder);*/ + + return $object; + } + /** * Validate fields before create or update object * diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 22e1fb1940d..027927c3c49 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -66,6 +66,7 @@ class MyObject extends CommonObject * 'position' is the sort order of field. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' * 'help' is a string visible as a tooltip on field * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record @@ -285,7 +286,7 @@ class MyObject extends CommonObject */ function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) { - global $db, $conf, $langs, $hoomanager; + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 3f2d9b14dac..04de3e1e40e 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -122,7 +122,7 @@ if (empty($reshook)) $permissiontoadd = $user->rights->mymodule->write; $permissiontodelete = $user->rights->mymodule->delete; - if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id=__ID__'; + if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 2a5793a3c0e..bc674b2ba95 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -64,6 +64,7 @@ if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id=$object->id; } } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 9a943dfb3e2..fd7647c8f35 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -454,18 +454,12 @@ class Project extends CommonObject // fetch optionals attributes and labels $this->fetch_optionals(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) - { - $this->fetchComments(); - } - return 1; } $this->db->free($resql); - if ($num_rows) return 1; - else return 0; + return 0; } else { @@ -655,9 +649,8 @@ class Project extends CommonObject $this->getLinesArray($user); // Delete tasks - foreach($this->lines as &$task) { - $task->delete($user); - } + $ret = $this->deleteTasks($user); + if ($ret < 0) $error++; // Delete project if (! $error) @@ -733,6 +726,40 @@ class Project extends CommonObject return -1; } } + + /** + * Delete tasks with no children first, then task with children recursively + * + * @param User $user User + * @return int <0 if KO, 1 if OK + */ + function deleteTasks($user) + { + $countTasks = count($this->lines); + $deleted = false; + if ($countTasks) + { + foreach($this->lines as $task) + { + if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them) + $deleted = true; + $ret = $task->delete($user); + if ($ret <= 0) + { + $this->errors[] = $this->db->lasterror(); + return -1; + } + } + } + } + $this->getLinesArray($user); + if ($deleted && count($this->lines) < $countTasks) + { + if (count($this->lines)) $this->deleteTasks($this->lines); + } + + return 1; + } /** * Validate a project diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 52f1facb548..0d634e18888 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -194,7 +194,7 @@ class Task extends CommonObject */ function fetch($id, $ref='', $loadparentdata=0) { - global $langs; + global $langs, $conf; $sql = "SELECT"; $sql.= " t.rowid,"; @@ -267,7 +267,6 @@ class Task extends CommonObject } // Retreive all extrafield - // fetch optionals attributes and labels $this->fetch_optionals(); } diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 7f547feffb3..f6cd6ac0005 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -67,6 +67,7 @@ if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id=$object->id; } } diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index f7edf686eb2..68c9b530c88 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -43,6 +43,7 @@ $mine = GETPOST('mode')=='mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; @@ -140,6 +141,7 @@ $userstatic=new User($db); if ($id > 0 || ! empty($ref)) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user,'write'); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 3af813ba698..e585acd7d85 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -48,6 +48,7 @@ $result=restrictedArea($user,'projet',$id,'projet&project'); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); if ($id > 0 || ! empty($ref)) { $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 28cc833eeb2..23ecadd9939 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -97,6 +97,7 @@ $projectid=$id; // For backward compatibility $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=$object->socid; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index a1ac7c32aaa..00f568271e0 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -42,6 +42,7 @@ $mine = ($mode == 'mine' ? 1 : 0); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 31d633e70d1..7aa0dccd67d 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -98,6 +98,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $object->info($object->id); } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 96dce3da63f..4d455bdcbc7 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -39,6 +39,7 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 17d245f94bf..c10dc2b9c42 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -64,6 +64,7 @@ $extrafields_project = new ExtraFields($db); $extrafields_task = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); if ($id > 0 || ! empty($ref)) { diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index c1b6c1b2848..19ba461fbe4 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -106,6 +106,7 @@ if ($id > 0 || ! empty($ref)) $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index f27ff3393f5..3272c43ad10 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -173,9 +173,11 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id, $ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id = $object->id; // So when doing a search from ref, id is also set correctly. $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 4e8e1319aa3..a186c89988f 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -91,7 +91,9 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) { $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index ebd4210ff6e..668c2a96d83 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -51,7 +51,9 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 7b4a9d25537..b7588257455 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -211,8 +211,10 @@ if ($id > 0 || ! empty($ref)) if ($object->fetch($id,$ref) > 0) { $res=$object->fetch_optionals(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 4c2e60f05b2..18adfc47bed 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -71,7 +71,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; -if (! $sortorder) $sortorder='DESC'; +if (! $sortorder) $sortorder='DESC,DESC,DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context //$object = new TaskTime($db); @@ -158,7 +158,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) else { $object->timespent_note = $_POST["timespent_note"]; - $object->progress = GETPOST('progress', 'int'); + if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds $object->timespent_duration+= ($_POST["timespent_durationmin"]?$_POST["timespent_durationmin"]:0)*60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered @@ -307,7 +307,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } elseif ($object->fetch($id, $ref) >= 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $res=$projectstatic->fetch_optionals(); @@ -422,7 +424,16 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { if ($projectstatic->public || $userWrite > 0) { - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + if (! empty($projectidforalltimes)) // We are on tab 'Time Spent' of project + { + $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject?'&withproject=1':''); + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + } + else // We are on tab 'Time Spent' of task + { + $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject?'&withproject=1':''); + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + } } else { @@ -600,7 +611,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Progress declared print ''; print ''; print '
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'.$formquestion['text'].'
'.$input['label'].'
'.$input['label'].'
'; - if (! empty($input['label'])) $more.=$input['label'].''; + $more.='
'; $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1,0,0,$moreattr,0,0,0,'',$morecss); $more.='
'.$input['label'].' '; + $more.=''.$input['label'].' '; $more.=' $selval) { $more.='
'.$input['label'].' '.$input['label'].''; - $more.=''; + $more.='
'; $more.=$this->select_date($input['value'],$input['name'],0,0,0,'',1,0,1); $more.='
'; - if (! empty($input['label'])) $more.=$input['label'].''; + $more.='
'; $more.=$input['value']; $more.='
'; + $more.='
'; $more.=$input['value']; $more.='
'; - print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress, 'progress', 0, 5, 0, 100, 1); print ''; @@ -785,7 +796,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Progress declared print ''; - print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress, 'progress', 0, 5, 0, 100, 1); print ''; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5a7916f6bd9..ce8be81e2cd 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1800,11 +1800,12 @@ if (count($object->records) > 0) // Confirmation to clone if ($action == 'createpagefromclone') { // Create an array for form + $preselectedlanguage = GETPOST('newlang', 'az09') ? GETPOST('newlang', 'az09') : ($objectpage->lang ? $objectpage->lang : $langs->defaultlang); $formquestion = array( - array('type' => 'text', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME") ,'value'=> 'copy_of_'.$objectpage->pageurl), - array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200')), - array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), + array('type' => 'text', 'tdclass'=>'maxwidth200', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), + array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), + array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), + array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?website='.$object->ref.'&pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);