Fix #19257 error in the page Overview of a project

This commit is contained in:
Laurent Destailleur 2021-10-31 15:14:15 +01:00
parent 8064ecce73
commit e6e440e573
6 changed files with 100 additions and 32 deletions

View File

@ -683,6 +683,8 @@ if ($conf->use_javascript_ajax) {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("SOCIETE_ASK_FOR_WAREHOUSE", $arrval, $conf->global->SOCIETE_ASK_FOR_WAREHOUSE);
}
print "</td>";
print "</tr>\n";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("WarehouseAskWarehouseDuringPropal").'</td>';
@ -693,6 +695,9 @@ if ($conf->use_javascript_ajax) {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL);
}
print "</td>";
print "</tr>\n";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("WarehouseAskWarehouseDuringOrder").'</td>';
print '<td class="right">';
@ -702,10 +707,23 @@ if ($conf->use_javascript_ajax) {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER);
}
print "</td>";
print '</td>';
print "</tr>\n";
/*
print '<tr class="oddeven">';
print '<td>'.$langs->trans("WarehouseAskWarehouseDuringProject").'</td>';
print '<td class="right">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT);
}
print '</td>';
print "</tr>\n";
*/
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc"));

View File

@ -505,7 +505,17 @@ class FormProjets
}
$linkedtothirdparty = false;
if (!in_array($table_element, array('don', 'expensereport_det', 'expensereport', 'loan', 'stock_mouvement', 'payment_salary', 'payment_various', 'chargesociales', 'entrepot'))) {
if (!in_array($table_element, array(
'don',
'expensereport_det',
'expensereport', 'loan',
'stock_mouvement',
'payment_salary',
'payment_various',
'salary',
'chargesociales',
'entrepot')
)) {
$linkedtothirdparty = true;
}

View File

@ -6,6 +6,7 @@ CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT=By default, leave empty the option "Autom
Salary=Salary
Salaries=Salaries
NewSalary=New salary
AddSalary=Add salary
NewSalaryPayment=New salary card
AddSalaryPayment=Add salary payment
SalaryPayment=Salary payment

View File

@ -63,6 +63,7 @@ RuleForWarehouse=Rule for warehouses
WarehouseAskWarehouseOnThirparty=Set a warehouse on Third-parties
WarehouseAskWarehouseDuringPropal=Set a warehouse on Commercial proposals
WarehouseAskWarehouseDuringOrder=Set a warehouse on Sale orders
WarehouseAskWarehouseDuringProject=Set a warehouse on Projects
UserDefaultWarehouse=Set a warehouse on Users
MainDefaultWarehouse=Default warehouse
MainDefaultWarehouseUser=Use a default warehouse for each user

View File

@ -164,7 +164,7 @@ if ($id == '' && $ref == '') {
exit();
}
$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0;
$mine = GETPOST('mode') == 'mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db);
@ -368,19 +368,19 @@ $listofreferent = array(
'class'=>'Entrepot',
'table'=>'entrepot',
'datefieldname'=>'date_entrepot',
'urlnew'=>DOL_URL_ROOT.'/product/stock/card.php?action=create&projectid='.$id,
'urlnew'=>DOL_URL_ROOT.'/product/stock/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'entrepot',
'buttonnew'=>'AddWarehouse',
'project_field'=>'fk_project',
'testnew'=>$user->rights->stock->creer,
'test'=>$conf->stock->enabled && $user->rights->stock->lire),
'test'=>$conf->stock->enabled && $user->rights->stock->lire && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)),
'propal'=>array(
'name'=>"Proposals",
'title'=>"ListProposalsAssociatedProject",
'class'=>'Propal',
'table'=>'propal',
'datefieldname'=>'datep',
'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'propal',
'buttonnew'=>'AddProp',
'testnew'=>$user->rights->propal->creer,
@ -391,7 +391,7 @@ $listofreferent = array(
'class'=>'Commande',
'table'=>'commande',
'datefieldname'=>'date_commande',
'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'orders',
'buttonnew'=>'CreateOrder',
'testnew'=>$user->rights->commande->creer,
@ -403,7 +403,7 @@ $listofreferent = array(
'margin'=>'add',
'table'=>'facture',
'datefieldname'=>'datef',
'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'bills',
'buttonnew'=>'CreateBill',
'testnew'=>$user->rights->facture->creer,
@ -414,7 +414,7 @@ $listofreferent = array(
'class'=>'FactureRec',
'table'=>'facture_rec',
'datefieldname'=>'datec',
'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'bills',
'buttonnew'=>'CreateBill',
'testnew'=>$user->rights->facture->creer,
@ -425,7 +425,7 @@ $listofreferent = array(
'class'=>'SupplierProposal',
'table'=>'supplier_proposal',
'datefieldname'=>'date_valid',
'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object
'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object
'lang'=>'supplier_proposal',
'buttonnew'=>'AddSupplierProposal',
'testnew'=>$user->rights->supplier_proposal->creer,
@ -436,7 +436,7 @@ $listofreferent = array(
'class'=>'CommandeFournisseur',
'table'=>'commande_fournisseur',
'datefieldname'=>'date_commande',
'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object
'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object
'lang'=>'suppliers',
'buttonnew'=>'AddSupplierOrder',
'testnew'=>($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer),
@ -448,7 +448,7 @@ $listofreferent = array(
'margin'=>'minus',
'table'=>'facture_fourn',
'datefieldname'=>'datef',
'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object
'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object
'lang'=>'suppliers',
'buttonnew'=>'AddSupplierInvoice',
'testnew'=>($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer),
@ -459,7 +459,7 @@ $listofreferent = array(
'class'=>'Contrat',
'table'=>'contrat',
'datefieldname'=>'date_contrat',
'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'contracts',
'buttonnew'=>'AddContract',
'testnew'=>$user->rights->contrat->creer,
@ -472,7 +472,7 @@ $listofreferent = array(
'datefieldname'=>'date_valid',
'disableamount'=>0,
'margin'=>'minus',
'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'interventions',
'buttonnew'=>'AddIntervention',
'testnew'=>$user->rights->ficheinter->creer,
@ -483,7 +483,7 @@ $listofreferent = array(
'class'=>'Expedition',
'table'=>'expedition',
'datefieldname'=>'date_valid',
'urlnew'=>DOL_URL_ROOT.'/expedition/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/expedition/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'sendings',
'buttonnew'=>'CreateShipment',
'testnew'=>0,
@ -494,7 +494,7 @@ $listofreferent = array(
'class'=>'Mo',
'table'=>'mrp_mo',
'datefieldname'=>'date_valid',
'urlnew'=>DOL_URL_ROOT.'/mrp/mo_card.php?action=create&origin=project&originid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/mrp/mo_card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'mrp',
'buttonnew'=>'CreateMO',
'testnew'=>'$user->rights->mrp->write',
@ -508,7 +508,7 @@ $listofreferent = array(
'datefieldname'=>'dated',
'margin'=>'minus',
'disableamount'=>1,
'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'trips',
'buttonnew'=>'AddTrip',
'testnew'=>$user->rights->deplacement->creer,
@ -521,7 +521,7 @@ $listofreferent = array(
'datefieldname'=>'date',
'margin'=>'minus',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'trips',
'buttonnew'=>'AddTrip',
'testnew'=>$user->rights->expensereport->creer,
@ -534,7 +534,7 @@ $listofreferent = array(
'table'=>'don',
'datefieldname'=>'datedon',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'donations',
'buttonnew'=>'AddDonation',
'testnew'=>$user->rights->don->creer,
@ -547,7 +547,7 @@ $listofreferent = array(
'table'=>'loan',
'datefieldname'=>'datestart',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'loan',
'buttonnew'=>'AddLoan',
'testnew'=>$user->rights->loan->write,
@ -560,7 +560,7 @@ $listofreferent = array(
'table'=>'chargesociales',
'datefieldname'=>'date_ech',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id,
'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'compta',
'buttonnew'=>'AddSocialContribution',
'testnew'=>$user->rights->tax->charges->lire,
@ -573,7 +573,7 @@ $listofreferent = array(
'table'=>'projet_task',
'datefieldname'=>'task_date',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id,
'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'buttonnew'=>'AddTimeSpent',
'testnew'=>$user->rights->projet->creer,
'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))),
@ -594,9 +594,9 @@ $listofreferent = array(
'datefieldname'=>'datesp',
'margin'=>'minus',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id,
'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'salaries',
'buttonnew'=>'AddSalaryPayment',
'buttonnew'=>'AddSalary',
'testnew'=>$user->rights->salaries->write,
'test'=>$conf->salaries->enabled && $user->rights->salaries->read),
'variouspayment'=>array(
@ -607,7 +607,7 @@ $listofreferent = array(
'datefieldname'=>'datev',
'margin'=>'minus',
'disableamount'=>0,
'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id,
'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'banks',
'buttonnew'=>'AddVariousPayment',
'testnew'=>$user->rights->banque->modifier,
@ -620,7 +620,7 @@ $listofreferent = array(
'table'=>'actioncomm',
'datefieldname'=>'datep',
'disableamount'=>1,
'urlnew'=>DOL_URL_ROOT.'/comm/action/card.php?action=create&projectid='.$id.'&socid='.$socid,
'urlnew'=>DOL_URL_ROOT.'/comm/action/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
'lang'=>'agenda',
'buttonnew'=>'AddEvent',
'testnew'=>$user->rights->agenda->myactions->create,

View File

@ -48,6 +48,9 @@ $id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
$confirm = GETPOST('confirm');
@ -75,7 +78,6 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('salarycard', 'globalcard'));
$object = new Salary($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
@ -97,6 +99,7 @@ $socid = GETPOSTINT('socid');
if ($user->socid) {
$socid = $user->socid;
}
restrictedArea($user, 'salaries', $object->id, 'salary', '');
@ -104,9 +107,39 @@ restrictedArea($user, 'salaries', $object->id, 'salary', '');
* Actions
*/
if ($cancel) {
header("Location: list.php");
exit;
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/salaries/list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/salaries/card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
}
}
if ($cancel) {
/*var_dump($cancel);
var_dump($backtopage);exit;*/
if (!empty($backtopageforcancel)) {
header("Location: ".$backtopageforcancel);
exit;
} elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
$action = '';
}
}
// Link to a project
@ -404,8 +437,7 @@ llxHeader("", $title, $help_url);
$form = new Form($db);
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
if ($id) {
$object = new Salary($db);
if ($id > 0) {
$result = $object->fetch($id);
if ($result <= 0) {
dol_print_error($db);
@ -439,6 +471,12 @@ if ($action == 'create') {
print '<form name="salary" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
}
print load_fiche_titre($langs->trans("NewSalary"), '', 'salary');