diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d98357bc93c..e7616ededf3 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -199,7 +199,7 @@ if ($action == 'update') { $nb_exists = $db->num_rows($resql_exists); if ($nb_exists <= 0) { // insert - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (fk_product, entity, '" . $db->escape($accountancy_field_name) . "')"; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (fk_product, entity, " . $db->escape($accountancy_field_name) . ")"; $sql .= " VALUES (" . ((int) $productid) . ", " . ((int) $conf->entity) . ", '" . $db->escape($accounting->account_number) . "')"; } else { $obj_exists = $db->fetch_object($resql_exists); diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 6246f9c09c3..74c46112241 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -237,7 +237,7 @@ if (empty($mysoc->country_code)) { $sql = "SELECT taux as vat_rate, t.code as vat_code, t.localtax1 as localtax_rate1, t.localtax2 as localtax_rate2"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($mysoc->country_code)."' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0)"; + $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($mysoc->country_code)."' AND (t.taux <> 0 OR t.localtax1 <> '0' OR t.localtax2 <> '0')"; $sql .= " ORDER BY t.taux ASC"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 5c9b863ba32..e8f59727c07 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -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 ""; +print "\n"; print ''; print ''.$langs->trans("WarehouseAskWarehouseDuringPropal").''; @@ -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 ""; +print "\n"; + print ''; print ''.$langs->trans("WarehouseAskWarehouseDuringOrder").''; print ''; @@ -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 ""; print ''; print "\n"; +/* +print ''; +print ''.$langs->trans("WarehouseAskWarehouseDuringProject").''; +print ''; +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 ''; +print "\n"; +*/ + print ''; print ''; print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index e6a94b21701..9a449d63700 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1976,6 +1976,12 @@ class Categorie extends CommonObject if ($type == 'bank_account') { $type = 'account'; } + if ($type == 'customer') { + $type = 'societe'; + } + if ($type == 'supplier') { + $type = 'fournisseur'; + } if (empty($searchList) && !is_array($searchList)) { return ""; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0d777980325..ba505f33d67 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2846,15 +2846,6 @@ if (empty($reshook)) { * View */ -if (empty($object->id)) { - llxHeader(); - $head = facture_prepare_head($object); - $langs->load('errors'); - echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; - llxFooter(); - exit; -} $form = new Form($db); $formother = new FormOther($db); @@ -3828,8 +3819,16 @@ if ($action == 'create') { print ''; } - print ''; + print "\n"; } elseif ($id > 0 || !empty($ref)) { + if (empty($object->id)) { + llxHeader(); + $langs->load('errors'); + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; + llxFooter(); + exit; + } + /* * Show object in view mode */ diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index c921a9f51b2..6354c0bf5fd 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -102,10 +102,8 @@ if ($action == 'addcontact' && $user->rights->facture->creer) { if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 094a3acf859..89a67e75cb7 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -94,10 +94,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index b721d958f36..f8dd1418000 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -64,10 +64,8 @@ $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $field if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index f67e72ad92c..6f699774d32 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -79,10 +79,8 @@ if (empty($reshook)) { if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 34ea7b0a2e8..022bf55f243 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -514,7 +514,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; } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index b9f320b7db8..7e2154ee309 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1,17 +1,18 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2021 Juanjo Menent +/* Copyright (C) 2013-2015 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2021 Juanjo Menent + * Copyright (C) 2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -508,11 +509,13 @@ class FormTicket print ''; } - if (!empty($conf->projet->enabled) && !$this->ispublic) { - $formproject = new FormProjets($this->db); - print ''; - print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - print ''; + if ($subelement != 'project') { + if (!empty($conf->projet->enabled) && !$this->ispublic) { + $formproject = new FormProjets($this->db); + print ''; + print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); + print ''; + } } // Other attributes diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 47edfcc9ca2..0d4a85e00ae 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -349,7 +349,7 @@ class modAdherent extends DolibarrModules $this->import_fields_array[$r]['a.fk_soc'] = "ThirdParty"; } // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 3caf5db88c6..f72dc00cfaf 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -638,7 +638,7 @@ class modProduct extends DolibarrModules // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 2d89baa07a3..08eb3c58adc 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -296,7 +296,7 @@ class modProjet extends DolibarrModules $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 6f2d3f8d409..377d5aadbc4 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -268,7 +268,7 @@ class modResource extends DolibarrModules $this->import_tables_array[$r] = array('r'=>MAIN_DB_PREFIX.'resource', 'extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('r.ref'=>"ResourceFormLabel_ref*", 'r.fk_code_type_resource'=>'ResourceTypeCode', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>'DateCreation'); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 21a26bdc750..0390a23cc83 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -584,7 +584,7 @@ class modService extends DolibarrModules } // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index c3eba65673b..ca5b484499a 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -496,7 +496,7 @@ class modSociete extends DolibarrModules $this->import_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode'); } // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { @@ -674,7 +674,7 @@ class modSociete extends DolibarrModules 's.note_public' => "NotePublic" ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on an old database (during a migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index abeca50b77d..4b660e6159a 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -298,7 +298,7 @@ class modUser extends DolibarrModules 'u.statut'=>'Status' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index bc79aa4d6e1..6c152c5751e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2093,7 +2093,7 @@ class CommandeFournisseur extends CommonOrder // Test we can delete $this->fetchObjectLinked(null, 'order_supplier'); - if (!empty($this->linkedObjects)) { + if (!empty($this->linkedObjects) && array_key_exists('reception', $this->linkedObjects)) { foreach ($this->linkedObjects['reception'] as $element) { if ($element->statut >= 0) { $this->errors[] = $langs->trans('ReceptionExist'); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 4227aed6afa..cd416585101 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -465,7 +465,7 @@ if ($step == 2 && $datatoimport) { print ''; // Module - print ''; + print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services @@ -571,10 +571,10 @@ if ($step == 3 && $datatoimport) { print '
'; print '
'; - print ''; + print '
'; // Module - print ''; + print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services @@ -603,7 +603,7 @@ if ($step == 3 && $datatoimport) { print ''; // Source file format - print ''; + print ''; print ''; - print ''; print '
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); @@ -733,8 +733,8 @@ if ($step == 3 && $datatoimport) { $relativepath = $file; print '
'.img_mime($file).''; + print img_mime($file, '', 'pictofixedwidth'); print ''; print $file; print ''; @@ -876,7 +876,7 @@ if ($step == 4 && $datatoimport) { print ''; // Module - print ''; + print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services @@ -905,7 +905,7 @@ if ($step == 4 && $datatoimport) { print ''; // Source file format - print ''; + print ''; print ''; } @@ -938,6 +938,7 @@ if ($step == 4 && $datatoimport) { $modulepart = 'import'; $relativepath = GETPOST('filetoimport'); print ''; + print img_mime($file, '', 'pictofixedwidth'); print $filetoimport; print ''; print ''; @@ -1385,7 +1386,7 @@ if ($step == 5 && $datatoimport) { print '
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); @@ -926,8 +926,8 @@ if ($step == 4 && $datatoimport) { print $langs->trans("Separator").' : '; print ''; print '    '.$langs->trans("Enclosure").' : '; - print ''; - print ''; + print ' '; + print ''; print ''; print '
'; // Module - print ''; + print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services @@ -1414,7 +1415,7 @@ if ($step == 5 && $datatoimport) { print ''; // Source file format - print ''; + print ''; print ''; @@ -1509,7 +1511,7 @@ if ($step == 5 && $datatoimport) { print '
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); @@ -1435,6 +1436,7 @@ if ($step == 5 && $datatoimport) { $modulepart = 'import'; $relativepath = GETPOST('filetoimport'); print ''; + print img_mime($file, '', 'pictofixedwidth'); print $filetoimport; print ''; print '
'; // Tables imported - print '
'; + print '
'; print $langs->trans("TablesTarget"); print ''; $listtables = array(); @@ -1675,10 +1677,15 @@ if ($step == 5 && $datatoimport) { print '
'.img_picto($langs->trans("OK"), 'tick').' '.$langs->trans("NoError").'


'; print '
'; print $langs->trans("NbInsert", empty($obj->nbinsert) ? 0 : $obj->nbinsert).'
'; - print $langs->trans("NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).'

'; + print $langs->trans("NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).'
'; print '
'; + print '
'; } else { - print $langs->trans("NbOfLinesOK", $nbok).'

'; + print '
'; + print '
'; + print $langs->trans("NbOfLinesOK", $nbok).'
'; + print '
'; + print '
'; } // Show Errors @@ -1823,7 +1830,7 @@ if ($step == 6 && $datatoimport) { print ''; // Module - print ''; + print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services @@ -1852,7 +1859,7 @@ if ($step == 6 && $datatoimport) { print ''; // Source file format - print ''; + print ''; print ''; diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index d4dc53f42ed..c0e115a20df 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -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 diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 62d9ac6cc99..8c0cc76f075 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -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 Sales Orders +WarehouseAskWarehouseDuringProject=Set a warehouse on Projects UserDefaultWarehouse=Set a warehouse on Users MainDefaultWarehouse=Default warehouse MainDefaultWarehouseUser=Use a default warehouse for each user @@ -262,4 +263,4 @@ ErrorSameBatchNumber=Same batch number found in inventory list ProductBatchDoesNotExist=Product with batch/serial does not exist ProductBarcodeDoesNotExist=Product with barcode does not exist WarehouseId=Warehouse ID -WarehouseRef=Warehouse Ref \ No newline at end of file +WarehouseRef=Warehouse Ref diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 8ffae0bee8c..32a2cd08cc9 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -178,7 +178,7 @@ $arrayofmode = array( 'facture' => 'Facture' ); $title .= ' '.$form->selectarray('mode', $arrayofmode, $mode, 1); -$title .= ' '; +$title .= ' '; print ''; @@ -198,7 +198,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort print '
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); @@ -1875,6 +1882,7 @@ if ($step == 6 && $datatoimport) { $modulepart = 'import'; $relativepath = GETPOST('filetoimport'); print ''; + print img_mime($file, '', 'pictofixedwidth'); print $filetoimport; print ''; print '
'; -print ""; +print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'p.fk_product_type', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Label', $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index ef4abef5173..d2d9f289fd1 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -45,6 +45,7 @@ $ref = GETPOST('ref', 'alpha'); $mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit'); $search_year = GETPOST('search_year', 'int'); $search_categ = GETPOST('search_categ', 'int'); +$notab = GETPOST('notab', 'int'); $error = 0; $mesg = ''; @@ -56,7 +57,7 @@ if (!empty($user->socid)) { } // Security check -$fieldvalue = (!empty($id) ? $id : $ref); +$fieldvalue = ($id > 0 ? $id : $ref); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -69,6 +70,11 @@ if (empty($search_year)) { } $moreforfilter = ""; +$object = new Product($db); +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref); +} + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -85,9 +91,10 @@ $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product $form = new Form($db); $htmlother = new FormOther($db); -$object = new Product($db); -if (!$id && empty($ref)) { +if (!($id > 0) && empty($ref) || $notab) { + $notab = 1; + llxHeader("", $langs->trans("ProductStatistics")); $type = GETPOST('type', 'int'); @@ -132,7 +139,7 @@ if (!$id && empty($ref)) { } -if ($result && (!empty($id) || !empty($ref))) { +if ($result && ($id > 0 || !empty($ref)) && empty($notab)) { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -145,11 +152,11 @@ if ($result && (!empty($id) || !empty($ref))) { print dol_get_fiche_end(); } -if (empty($id) && empty($ref)) { +if ((!($id > 0) && empty($ref)) || $notab) { $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.$type : ''); + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.((int) $type) : ''); $head[$h][1] = $langs->trans("Chart"); $head[$h][2] = 'chart'; $h++; @@ -162,7 +169,7 @@ if (empty($id) && empty($ref)) { $title = $langs->trans("ListProductByPopularity"); } - $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.$type : ''); + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.((int) $type) : ''); $head[$h][1] = $langs->trans("ProductsPerPopularity"); $head[$h][2] = 'popularity'; $h++; @@ -171,21 +178,29 @@ if (empty($id) && empty($ref)) { } -if ($result || empty($id)) { +if ($result || !($id > 0)) { print ''; print ''; - print ''; + if (empty($id) || $notab) { + print ''; + } print '
'; print ''; - if (empty($id)) { + if (!($id > 0) || $notab) { // Type - print ''; + // Product + print ''; + // Tag if ($conf->categorie->enabled) { print ''; } + } else { + print ''; } // Year @@ -224,7 +241,7 @@ if ($result || empty($id)) { } if ($mode == 'bynumber') { - print 'id).($type != '' ? '&type='.$type : '').'&mode=byunit&search_year='.$search_year.'">'; + print ''; } else { print ''; } @@ -240,7 +257,7 @@ if ($result || empty($id)) { } if ($mode == 'byunit') { - print 'id).($type != '' ? '&type='.$type : '').'&mode=bynumber&search_year='.$search_year.'">'; + print ''; } else { print ''; } @@ -258,9 +275,7 @@ if ($result || empty($id)) { } print '
'; - //print '
'.$langs->trans("Filter").'
'.$langs->trans("ProductsAndServices").''; + print '
'.$langs->trans("Type").''; $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); print $form->selectarray('type', $array, $type); print '
'.$langs->trans("ProductOrService").''; + print img_picto('', 'product', 'class="pictofixedwidth"'); + print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500'); + print '
'.$langs->trans("Categories").''; @@ -194,6 +209,8 @@ if ($result || empty($id)) { print $moreforfilter; print '
'; - - // Generation des graphs + // Generation of graphs $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); if ($object->id > 0) { // We are on statistics for a dedicated product if (!file_exists($dir.'/'.$object->id)) { @@ -385,7 +400,7 @@ if ($result || empty($id)) { $px->SetShading(3); //print 'x '.$key.' '.$graphfiles[$key]['file']; - $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); + $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.((int) $object->entity).'&file='.urlencode($graphfiles[$key]['file']).($notab ? '¬ab='.$notab : ''); $px->draw($dir."/".$graphfiles[$key]['file'], $url); $graphfiles[$key]['total'] = $px->total(); @@ -446,7 +461,9 @@ if ($result || empty($id)) { } else { $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); } - $linktoregenerate = 'id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; + $linktoregenerate = ' 0 ? '&search_categ='.((int) $search_categ) : '').'">'; + $linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh'); + $linktoregenerate .= ''; // Show graph print '
'; @@ -480,7 +497,7 @@ if ($result || empty($id)) { } } -if (!$id) { +if (!($id > 0)) { print dol_get_fiche_end(); } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index e223714e82d..bfd96716bb7 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -195,6 +195,7 @@ $now = dol_now(); $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ListOfWarehouses"); +$totalarray = array(); // Build and execute select // -------------------------------------------------------------------- @@ -566,7 +567,6 @@ print ''."\n"; // Loop on record // -------------------------------------------------------------------- $i = 0; -$totalarray = array(); $warehouse = new Entrepot($db); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index d5bf172f5b3..ed7b5f1980e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -358,12 +358,14 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product AND s.fk_entrepot IN ('.$db->sanitize($listofqualifiedwarehousesid).')'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product'; +$list_warehouse = (empty($listofqualifiedwarehousesid) ? '0' : $listofqualifiedwarehousesid); +$sql .= ' AND s.fk_entrepot IN ('.$db->sanitize($list_warehouse) .')'; + //$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.((int) $fk_entrepot).')'; } - // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook @@ -577,6 +579,9 @@ print load_fiche_titre($langs->trans('Replenishment'), '', 'stock'); print dol_get_fiche_head($head, 'replenish', '', -1, ''); print ''.$langs->trans("ReplenishmentStatusDesc").''."\n"; + +//$link = ''.$langs->trans("MenuNewWarehouse").''; + if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index feee30f3527..ff68d9fbb05 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1,13 +1,13 @@ - * Copyright (C) 2004-2020 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2012-2016 Juanjo Menent - * Copyright (C) 2015-2019 Alexandre Spangaro - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Josep Lluís Amador - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2021 Noé Cendrier +/* Copyright (C) 2001-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2012-2016 Juanjo Menent + * Copyright (C) 2015-2021 Alexandre Spangaro + * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Josep Lluís Amador + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Noé Cendrier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -164,7 +164,7 @@ if ($id == '' && $ref == '') { exit(); } -$mine = (!empty($_REQUEST['mode']) && $_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); @@ -366,19 +366,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, @@ -389,7 +389,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, @@ -401,7 +401,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, @@ -412,7 +412,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, @@ -423,7 +423,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, @@ -434,7 +434,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), @@ -446,7 +446,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), @@ -457,7 +457,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, @@ -470,7 +470,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, @@ -481,7 +481,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, @@ -492,7 +492,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', @@ -506,7 +506,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, @@ -519,7 +519,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, @@ -532,7 +532,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, @@ -545,7 +545,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, @@ -558,7 +558,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, @@ -571,7 +571,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))), @@ -588,13 +588,13 @@ $listofreferent = array( 'name'=>"Salaries", 'title'=>"ListSalariesAssociatedProject", 'class'=>'Salary', - 'table'=>'payment_salary', - 'datefieldname'=>'datev', + 'table'=>'salary', + '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( @@ -605,7 +605,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, @@ -618,7 +618,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, @@ -814,7 +814,7 @@ foreach ($listofreferent as $key => $value) { } // Define $total_ht_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ht_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ht_by_line = $element->getAmount(); @@ -856,7 +856,7 @@ foreach ($listofreferent as $key => $value) { } // Define $total_ttc_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ttc_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ttc_by_line = $element->getAmount(); @@ -1073,7 +1073,7 @@ foreach ($listofreferent as $key => $value) { print ''; // if $key == 'project_task', we don't want details per user } elseif (in_array($tablename, array('payment_various'))) { print ''; // if $key == 'payment_various', we don't have any thirdparty - } elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'payment_salary'))) { + } elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'salary'))) { print $langs->trans("User"); } else { print $langs->trans("ThirdParty"); @@ -1231,8 +1231,8 @@ foreach ($listofreferent as $key => $value) { $date = $element->date; // No draft status on lines } elseif ($tablename == 'stock_mouvement') { $date = $element->datem; - } elseif ($tablename == 'payment_salary') { - $date = $element->datev; + } elseif ($tablename == 'salary') { + $date = $element->datesp; } elseif ($tablename == 'payment_various') { $date = $element->datev; } elseif ($tablename == 'chargesociales') { @@ -1290,7 +1290,7 @@ foreach ($listofreferent as $key => $value) { $tmpuser = new User($db); $tmpuser->fetch($expensereport->fk_user_author); print $tmpuser->getNomUrl(1, '', 48); - } elseif ($tablename == 'payment_salary') { + } elseif ($tablename == 'salary') { $tmpuser = new User($db); $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1, '', 48); @@ -1318,7 +1318,7 @@ foreach ($listofreferent as $key => $value) { if (empty($value['disableamount'])) { $total_ht_by_line = null; $othermessage = ''; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ht_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ht_by_line = $element->getAmount(); @@ -1372,7 +1372,7 @@ foreach ($listofreferent as $key => $value) { // Amount inc tax if (empty($value['disableamount'])) { $total_ttc_by_line = null; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ttc_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ttc_by_line = $element->getAmount(); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 931605dace0..3caf2afa7bd 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -48,6 +48,8 @@ $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $confirm = GETPOST('confirm'); $label = GETPOST('label', 'alphanohtml'); @@ -76,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); @@ -98,6 +99,7 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + restrictedArea($user, 'salaries', $object->id, 'salary', ''); @@ -105,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 @@ -405,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); @@ -440,6 +471,12 @@ if ($action == 'create') { print ''; print ''; print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print load_fiche_titre($langs->trans("NewSalary"), '', 'salary'); diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 18e46d9750d..581ca8601e8 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1,8 +1,9 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2018 Laurent Destailleur - * Copyright (C) 2021 Frédéric France +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2018 Laurent Destailleur + * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -232,6 +233,12 @@ if (empty($reshook)) { } // Link ticket to project + if (GETPOST('origin', 'alpha') == 'projet') { + $projectid = GETPOST('originid', 'int'); + } else { + $projectid = GETPOST('projectid', 'int'); + } + if ($projectid > 0) { $object->setProject($projectid); }