Merge remote-tracking branch 'upstream/develop' into camelCaps

This commit is contained in:
Frédéric FRANCE 2018-08-25 09:07:04 +02:00
commit d8bf4a0ecf
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
33 changed files with 180 additions and 80 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
@ -990,7 +990,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print '<td>';
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');
}

View File

@ -99,6 +99,7 @@ class DolibarrApi
// Remove $db object property for object
unset($object->db);
unset($object->isextrafieldmanaged);
unset($object->ismultientitymanaged);
unset($object->restrictiononfksoc);

View File

@ -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
{

View File

@ -607,7 +607,7 @@ if ($resql)
print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
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
{

View File

@ -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.='<table class="paddingtopbottomonly" width="100%">'."\n";
$more.='<tr><td colspan="3">'.(! empty($formquestion['text'])?$formquestion['text']:'').'</td></tr>'."\n";
if (! empty($formquestion['text'])) $more.='<tr><td colspan="2">'.$formquestion['text'].'</td></tr>'."\n";
foreach ($formquestion as $key => $input)
{
if (is_array($input) && ! empty($input))
@ -3727,29 +3727,28 @@ class Form
if ($input['type'] == 'text')
{
$more.='<tr><td>'.$input['label'].'</td><td colspan="2" align="left"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td align="left"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
}
else if ($input['type'] == 'password')
{
$more.='<tr><td>'.$input['label'].'</td><td colspan="2" align="left"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td align="left"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
}
else if ($input['type'] == 'select')
{
$more.='<tr><td>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td valign="top" colspan="2" align="left">';
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td class="tdtop" align="left">';
$more.=$this->selectarray($input['name'],$input['values'],$input['default'],1,0,0,$moreattr,0,0,0,'',$morecss);
$more.='</td></tr>'."\n";
}
else if ($input['type'] == 'checkbox')
{
$more.='<tr>';
$more.='<td>'.$input['label'].' </td><td align="left">';
$more.='<td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].' </td><td align="left">';
$more.='<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr;
if (! is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') $more.=' checked';
if (is_bool($input['value']) && $input['value']) $more.=' checked';
if (isset($input['disabled'])) $more.=' disabled';
$more.=' /></td>';
$more.='<td align="left">&nbsp;</td>';
$more.='</tr>'."\n";
}
else if ($input['type'] == 'radio')
@ -3758,12 +3757,11 @@ class Form
foreach($input['values'] as $selkey => $selval)
{
$more.='<tr>';
if ($i==0) $more.='<td class="tdtop">'.$input['label'].'</td>';
else $more.='<td>&nbsp;</td>';
$more.='<td width="20"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
if ($i==0) $more.='<td'.(empty($input['tdclass'])?' class="tdtop"':(' class="tdtop '.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
else $more.='<td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>&nbsp;</td>';
$more.='<td><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
if ($input['disabled']) $more.=' disabled';
$more.=' /></td>';
$more.='<td align="left">';
$more.=' /> ';
$more.=$selval;
$more.='</td></tr>'."\n";
$i++;
@ -3771,8 +3769,8 @@ class Form
}
else if ($input['type'] == 'date')
{
$more.='<tr><td>'.$input['label'].'</td>';
$more.='<td colspan="2" align="left">';
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
$more.='<td align="left">';
$more.=$this->select_date($input['value'],$input['name'],0,0,0,'',1,0,1);
$more.='</td></tr>'."\n";
$formquestion[] = array('name'=>$input['name'].'day');
@ -3783,15 +3781,15 @@ class Form
}
else if ($input['type'] == 'other')
{
$more.='<tr><td>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td colspan="2" align="left">';
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td align="left">';
$more.=$input['value'];
$more.='</td></tr>'."\n";
}
else if ($input['type'] == 'onecolumn')
{
$more.='<tr><td colspan="3" align="left">';
$more.='<tr><td colspan="2" align="left">';
$more.=$input['value'];
$more.='</td></tr>'."\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.'",

View File

@ -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.= '</select>';
// 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;
}

View File

@ -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 ''

View File

@ -331,7 +331,7 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage=0, $
print '<font style="font-size: 10px;"><br><hr>'."\n";
print $fromcompany->name.'<br>';
print $line1;
if (strlen($line1+$line2) > 50) print '<br>';
if (strlen($line1.$line2) > 50) print '<br>';
else print ' - ';
print $line2;
print '</font></div>'."\n";

View File

@ -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].= ' <span class="badge">'.($nbTasks).'</span>';
if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
$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)
{

View File

@ -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,

View File

@ -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();

View File

@ -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();

View File

@ -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
*

View File

@ -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;

View File

@ -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

View File

@ -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;
}
}

View File

@ -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

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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');

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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))
{

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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 = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?withproject=1'.($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTimeSpent').'<span class="fa fa-plus-circle valignmiddle"></span></a>';
if (! empty($projectidforalltimes)) // We are on tab 'Time Spent' of project
{
$backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject?'&withproject=1':'');
$linktocreatetime = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?withproject=1&projectid='.$projectstatic->id.'&action=createtime'.$param.'&backtopage='.urlencode($backtourl).'">'.$langs->trans('AddTimeSpent').'<span class="fa fa-plus-circle valignmiddle"></span></a>';
}
else // We are on tab 'Time Spent' of task
{
$backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject?'&withproject=1':'');
$linktocreatetime = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?withproject=1'.($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($backtourl).'">'.$langs->trans('AddTimeSpent').'<span class="fa fa-plus-circle valignmiddle"></span></a>';
}
}
else
{
@ -600,7 +611,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
// Progress declared
print '<td class="nowrap">';
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 '</td>';
print '<td align="center">';
@ -785,7 +796,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
// Progress declared
print '<td class="nowrap">';
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 '</td>';
print '<td align="center">';

View File

@ -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);