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

This commit is contained in:
Laurent Destailleur 2019-12-31 18:22:34 +01:00
commit 103f41f571
3 changed files with 27 additions and 28 deletions

View File

@ -44,6 +44,12 @@ $id=GETPOST("id", 'int');
$action=GETPOST('action', 'aZ09');
$cancel= GETPOST('cancel', 'aZ09');
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
$datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int'));
$dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int'));
// Security check
$socid = GETPOST("socid", "int");
@ -71,34 +77,30 @@ if ($cancel)
if ($action == 'classin' && $user->rights->banque->modifier)
{
$object->fetch($id);
$object->setProject(GETPOST('projectid'));
$object->setProject($projectid);
}
if ($action == 'add' && empty($cancel))
{
$error=0;
$datep=dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
$datev=dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
$datesp=dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int'));
$dateep=dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int'));
if (empty($datev)) $datev=$datep;
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1);
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0;
$object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user", "int") : 0;
$object->accountid=GETPOST("accountid", "int") > 0 ? GETPOST("accountid", "int") : 0;
$object->fk_user=GETPOST("fk_user", "int") > 0 ? GETPOST("fk_user", "int") : 0;
$object->datev=$datev;
$object->datep=$datep;
$object->amount=price2num(GETPOST("amount"));
$object->label=GETPOST("label");
$object->amount=price2num(GETPOST("amount", "alpha"));
$object->label=GETPOST("label", "alphanohtml");
$object->datesp=$datesp;
$object->dateep=$dateep;
$object->note=GETPOST("note");
$object->note=GETPOST("note", "none");
$object->type_payment=($type_payment > 0 ? $type_payment : 0);
$object->num_payment=GETPOST("num_payment");
$object->num_payment=GETPOST("num_payment", "alphanohtml");
$object->fk_user_author=$user->id;
$object->fk_project= GETPOST('fk_project', 'int');
$object->fk_project= $projectid;
// Set user current salary as ref salaray for the payment
$fuser=new User($db);
@ -303,7 +305,7 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$numproject=$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
print '</td></tr>';
}
@ -313,14 +315,14 @@ if ($action == 'create')
{
print '<tr><td>';
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
$form->select_comptes($_POST["accountid"], "accountid", 0, '', 1); // Affiche liste des comptes courant
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
print '</td></tr>';
}
// Type payment
print '<tr><td>';
print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype", '', 2);
$form->select_types_paiements(GETPOST("paymenttype", "aZ09"), "paymenttype", '', 2);
print '</td></tr>';
// Number

View File

@ -63,8 +63,6 @@ class FormMargin
{
global $conf, $db;
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
// Default returned array
$marginInfos = array(
'pa_products' => 0,

View File

@ -83,17 +83,16 @@ if (! isset($_POST['datesrfc']) && ! isset($_POST['datesday']) && ! empty($conf-
//$dates=dol_time_plus_duree($datee, -1, 'y');
$dates=dol_get_first_day($tmp['year'], 1);
}
if ($id == '' && $projectid == '' && $ref == '')
if ($id == '' && $ref == '')
{
dol_print_error('', 'Bad parameter');
exit;
setEventMessage($langs->trans('ErrorBadParameters'), 'errors');
header('Location: list.php');
exit();
}
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$projectid=$id; // For backward compatibility
$object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
@ -102,7 +101,7 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob
// Security check
$socid=$object->socid;
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
$result = restrictedArea($user, 'projet', $projectid, 'projet&project');
$result = restrictedArea($user, 'projet', $object->id, 'projet&project');
$hookmanager->initHooks(array('projectOverview'));
@ -513,7 +512,7 @@ elseif ($action == "unlink")
{
$tablename = GETPOST("tablename", "aZ09");
$projectField = GETPOST("projectfield", "aZ09");
$projectField = GETPOSTISSET('projectfield') ? GETPOST('projectfield', 'aZ09') : 'fk_projet';
$elementselectid = GETPOST("elementselect", "int");
$result = $object->remove_element($tablename, $elementselectid, $projectField);
@ -532,7 +531,7 @@ $showdatefilter=0;
if (! $showdatefilter)
{
print '<div class="center centpercent">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id=' . $object->id . '" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION["newtoken"].'">';
print '<input type="hidden" name="tablename" value="'.$tablename.'">';
print '<input type="hidden" name="action" value="view">';
@ -755,7 +754,7 @@ foreach ($listofreferent as $key => $value)
if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element))
{
$selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300', -2, !empty($project_field)?$project_field:'fk_projet');
if (! $selectList || ($selectList<0))
if ($selectList<0)
{
setEventMessages($formproject->error, $formproject->errors, 'errors');
}
@ -763,7 +762,7 @@ foreach ($listofreferent as $key => $value)
{
// Define form with the combo list of elements to link
$addform.='<div class="inline-block valignmiddle">';
$addform.='<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
$addform.='<form action="'.$_SERVER["PHP_SELF"].'?id=' . $object->id . '" method="post">';
$addform.='<input type="hidden" name="token" value="'.$_SESSION["newtoken"].'">';
$addform.='<input type="hidden" name="tablename" value="'.$tablename.'">';
$addform.='<input type="hidden" name="action" value="addelement">';
@ -890,7 +889,7 @@ foreach ($listofreferent as $key => $value)
{
if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true
{
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . ($project_field ? '&projectfield=' . $project_field : '') . '" class="reposition">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . ($project_field ? '&projectfield=' . $project_field : '') . '" class="reposition">';
print img_picto($langs->trans('Unlink'), 'unlink');
print '</a>';
}