Merge remote-tracking branch 'origin/develop' into fix_rest_api_fix_self_user_info_read
This commit is contained in:
commit
20e2eb1d9a
@ -1287,6 +1287,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
|
|||||||
|
|
||||||
$objecttmp = new $objectclass($db);
|
$objecttmp = new $objectclass($db);
|
||||||
$nbok = 0;
|
$nbok = 0;
|
||||||
|
$TMsg = array();
|
||||||
foreach ($toselect as $toselectid) {
|
foreach ($toselect as $toselectid) {
|
||||||
$result = $objecttmp->fetch($toselectid);
|
$result = $objecttmp->fetch($toselectid);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
@ -1314,7 +1315,9 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
|
|||||||
$result = $objecttmp->delete($user);
|
$result = $objecttmp->delete($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0) {
|
if (empty($result)) { // if delete returns 0, there is at least one object linked
|
||||||
|
$TMsg = array_merge($objecttmp->errors, $TMsg);
|
||||||
|
} elseif ($result < 0) { // if delete returns is < 0, there is an error, we break and rollback later
|
||||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
break;
|
break;
|
||||||
@ -1328,16 +1331,25 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (empty($error)) {
|
||||||
|
// Message for elements well deleted
|
||||||
if ($nbok > 1) {
|
if ($nbok > 1) {
|
||||||
setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
|
setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
|
||||||
} else {
|
} elseif ($nbok == 1) {
|
||||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Message for elements which can't be deleted
|
||||||
|
if (!empty($TMsg)) {
|
||||||
|
sort($TMsg);
|
||||||
|
setEventMessages('', array_unique($TMsg), 'warnings');
|
||||||
|
}
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump($listofobjectthirdparties);exit;
|
//var_dump($listofobjectthirdparties);exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
|||||||
$perm = 1;
|
$perm = 1;
|
||||||
} elseif ($table_element_line == 'mrp_production' && $user->rights->mrp->write) {
|
} elseif ($table_element_line == 'mrp_production' && $user->rights->mrp->write) {
|
||||||
$perm = 1;
|
$perm = 1;
|
||||||
} elseif ($table_element_line == 'supplier_proposaldet' && $user->rights->supplier_proposal->write) {
|
} elseif ($table_element_line == 'supplier_proposaldet' && $user->rights->supplier_proposal->creer) {
|
||||||
$perm = 1;
|
$perm = 1;
|
||||||
} elseif ($table_element_line == 'commande_fournisseurdet' && $user->rights->fournisseur->commande->creer) {
|
} elseif ($table_element_line == 'commande_fournisseurdet' && $user->rights->fournisseur->commande->creer) {
|
||||||
$perm = 1;
|
$perm = 1;
|
||||||
|
|||||||
@ -4297,10 +4297,10 @@ abstract class CommonObject
|
|||||||
//print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild;
|
//print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild;
|
||||||
$haschild += $obj->nb;
|
$haschild += $obj->nb;
|
||||||
if (is_numeric($elementname)) { // old usage
|
if (is_numeric($elementname)) { // old usage
|
||||||
$this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table);
|
$this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table);
|
||||||
} else // new usage: $elementname=Translation key
|
} else // new usage: $elementname=Translation key
|
||||||
{
|
{
|
||||||
$this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname));
|
$this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($elementname));
|
||||||
}
|
}
|
||||||
break; // We found at least one, we stop here
|
break; // We found at least one, we stop here
|
||||||
}
|
}
|
||||||
@ -8966,7 +8966,7 @@ abstract class CommonObject
|
|||||||
* @param User $user User that deletes
|
* @param User $user User that deletes
|
||||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
* @param int $forcechilddeletion 0=no, 1=Force deletion of children
|
* @param int $forcechilddeletion 0=no, 1=Force deletion of children
|
||||||
* @return int <=0 if KO, >0 if OK
|
* @return int <=0 if KO, 0=Nothing done because object has child, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion = 0)
|
public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion = 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -134,10 +134,6 @@ if (!$sortorder) {
|
|||||||
$sortorder = 'DESC';
|
$sortorder = 'DESC';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($search_status == '') {
|
|
||||||
$search_status = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
$object = new CommandeFournisseur($db);
|
$object = new CommandeFournisseur($db);
|
||||||
$hookmanager->initHooks(array('supplierorderlist'));
|
$hookmanager->initHooks(array('supplierorderlist'));
|
||||||
@ -245,7 +241,7 @@ if (empty($reshook)) {
|
|||||||
$search_multicurrency_montant_tva = '';
|
$search_multicurrency_montant_tva = '';
|
||||||
$search_multicurrency_montant_ttc = '';
|
$search_multicurrency_montant_ttc = '';
|
||||||
$search_project_ref = '';
|
$search_project_ref = '';
|
||||||
$search_status = -1;
|
$search_status = '';
|
||||||
$search_date_order_startday = '';
|
$search_date_order_startday = '';
|
||||||
$search_date_order_startmonth = '';
|
$search_date_order_startmonth = '';
|
||||||
$search_date_order_startyear = '';
|
$search_date_order_startyear = '';
|
||||||
@ -277,9 +273,42 @@ if (empty($reshook)) {
|
|||||||
$objectlabel = 'SupplierOrders';
|
$objectlabel = 'SupplierOrders';
|
||||||
$permissiontoread = $user->rights->fournisseur->commande->lire;
|
$permissiontoread = $user->rights->fournisseur->commande->lire;
|
||||||
$permissiontodelete = $user->rights->fournisseur->commande->supprimer;
|
$permissiontodelete = $user->rights->fournisseur->commande->supprimer;
|
||||||
|
$permissiontovalidate = $user->rights->fournisseur->commande->creer;
|
||||||
$uploaddir = $conf->fournisseur->commande->dir_output;
|
$uploaddir = $conf->fournisseur->commande->dir_output;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||||
|
|
||||||
|
if ($action == 'validate' && $permissiontovalidate) {
|
||||||
|
if (GETPOST('confirm') == 'yes') {
|
||||||
|
$objecttmp = new CommandeFournisseur($db);
|
||||||
|
$db->begin();
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
foreach ($toselect as $checked) {
|
||||||
|
if ($objecttmp->fetch($checked)) {
|
||||||
|
if ($objecttmp->statut == 0) {
|
||||||
|
$objecttmp->date_commande = dol_now();
|
||||||
|
$result = $objecttmp->valid($user);
|
||||||
|
if ($result >= 0) {
|
||||||
|
// If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step
|
||||||
|
if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
|
||||||
|
$result = $objecttmp->approve($user);
|
||||||
|
setEventMessages($langs->trans("SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans("SupplierOrderValidated"), array($objecttmp->ref));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) $db->commit();
|
||||||
|
else $db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mass action to generate vendor bills
|
// Mass action to generate vendor bills
|
||||||
if ($massaction == 'confirm_createsupplierbills') {
|
if ($massaction == 'confirm_createsupplierbills') {
|
||||||
$orders = GETPOST('toselect', 'array');
|
$orders = GETPOST('toselect', 'array');
|
||||||
@ -947,6 +976,15 @@ if ($resql) {
|
|||||||
'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||||
'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($permissiontovalidate) {
|
||||||
|
if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
|
||||||
|
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove");
|
||||||
|
} else {
|
||||||
|
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
|
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
|
||||||
$arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
|
$arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
|
||||||
}
|
}
|
||||||
@ -986,6 +1024,10 @@ if ($resql) {
|
|||||||
$trackid = 'sord'.$object->id;
|
$trackid = 'sord'.$object->id;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
|
||||||
|
if ($massaction == 'prevalidate') {
|
||||||
|
print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if ($massaction == 'createbills') {
|
if ($massaction == 'createbills') {
|
||||||
//var_dump($_REQUEST);
|
//var_dump($_REQUEST);
|
||||||
print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
|
print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
|
||||||
|
|||||||
@ -40,6 +40,12 @@
|
|||||||
|
|
||||||
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_project integer NOT NULL;
|
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_project integer NOT NULL;
|
||||||
|
|
||||||
|
UPDATE llx_extrafields SET elementtype = 'salary' WHERE elementtype = 'payment_salary';
|
||||||
|
ALTER TABLE llx_payment_salary_extrafields RENAME TO llx_salary_extrafields;
|
||||||
|
-- VMYSQL4.1 DROP INDEX idx_payment_salary_extrafields on llx_salary_extrafields
|
||||||
|
-- VPGSQL8.2 DROP INDEX idx_payment_salary_extrafields
|
||||||
|
ALTER TABLE llx_salary_extrafields ADD INDEX idx_salary_extrafields (fk_object);
|
||||||
|
|
||||||
|
|
||||||
-- v15
|
-- v15
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "status not s
|
|||||||
ErrorRefAlreadyExists=Ref used for creation already exists.
|
ErrorRefAlreadyExists=Ref used for creation already exists.
|
||||||
ErrorPleaseTypeBankTransactionReportName=Please enter the bank statement name where the entry has to be reported (Format YYYYMM or YYYYMMDD)
|
ErrorPleaseTypeBankTransactionReportName=Please enter the bank statement name where the entry has to be reported (Format YYYYMM or YYYYMMDD)
|
||||||
ErrorRecordHasChildren=Failed to delete record since it has some child records.
|
ErrorRecordHasChildren=Failed to delete record since it has some child records.
|
||||||
ErrorRecordHasAtLeastOneChildOfType=Object has at least one child of type %s
|
ErrorRecordHasAtLeastOneChildOfType=Object %s has at least one child of type %s
|
||||||
ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into another object.
|
ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into another object.
|
||||||
ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display.
|
ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display.
|
||||||
ErrorPasswordsMustMatch=Both typed passwords must match each other
|
ErrorPasswordsMustMatch=Both typed passwords must match each other
|
||||||
|
|||||||
@ -124,6 +124,8 @@ SupplierOrderReceivedInDolibarr=Purchase Order %s received %s
|
|||||||
SupplierOrderSubmitedInDolibarr=Purchase Order %s submitted
|
SupplierOrderSubmitedInDolibarr=Purchase Order %s submitted
|
||||||
SupplierOrderClassifiedBilled=Purchase Order %s set billed
|
SupplierOrderClassifiedBilled=Purchase Order %s set billed
|
||||||
OtherOrders=Other orders
|
OtherOrders=Other orders
|
||||||
|
SupplierOrderValidatedAndApproved=Supplier order is validated and approved : %s
|
||||||
|
SupplierOrderValidated=Supplier order is validated : %s
|
||||||
##### Types de contacts #####
|
##### Types de contacts #####
|
||||||
TypeContact_commande_internal_SALESREPFOLL=Representative following-up sales order
|
TypeContact_commande_internal_SALESREPFOLL=Representative following-up sales order
|
||||||
TypeContact_commande_internal_SHIPPING=Representative following-up shipping
|
TypeContact_commande_internal_SHIPPING=Representative following-up shipping
|
||||||
|
|||||||
@ -22,3 +22,4 @@ AllSalaries=All salaries
|
|||||||
SalariesStatistics=Salary statistics
|
SalariesStatistics=Salary statistics
|
||||||
SalariesAndPayments=Salaries and payments
|
SalariesAndPayments=Salaries and payments
|
||||||
ConfirmDeleteSalaryPayment=Do you want to delete this salary payment ?
|
ConfirmDeleteSalaryPayment=Do you want to delete this salary payment ?
|
||||||
|
FillFieldFirst=Fill employee field first
|
||||||
|
|||||||
@ -83,7 +83,7 @@ ErrorCantSaveADoneUserWithZeroPercentage=Impossible de sauver une action à l'é
|
|||||||
ErrorRefAlreadyExists=Le référence <b>%s</b> existe déjà.
|
ErrorRefAlreadyExists=Le référence <b>%s</b> existe déjà.
|
||||||
ErrorPleaseTypeBankTransactionReportName=Choisissez le nom du relevé bancaire sur lequel la ligne est rapportées (Format AAAAMM ou AAAAMMJJ)
|
ErrorPleaseTypeBankTransactionReportName=Choisissez le nom du relevé bancaire sur lequel la ligne est rapportées (Format AAAAMM ou AAAAMMJJ)
|
||||||
ErrorRecordHasChildren=Impossible de supprimer l'enregistrement car il possède des enregistrements fils.
|
ErrorRecordHasChildren=Impossible de supprimer l'enregistrement car il possède des enregistrements fils.
|
||||||
ErrorRecordHasAtLeastOneChildOfType=L'objet a au moins un enfant de type %s
|
ErrorRecordHasAtLeastOneChildOfType=L'objet %s a au moins un enfant de type %s
|
||||||
ErrorRecordIsUsedCantDelete=Ne peut effacer l'enregistrement. Ce dernier est déjà utilisé ou inclut dans un autre élément.
|
ErrorRecordIsUsedCantDelete=Ne peut effacer l'enregistrement. Ce dernier est déjà utilisé ou inclut dans un autre élément.
|
||||||
ErrorModuleRequireJavascript=Le javascript ne doit pas être désactivé pour que cette fonctionnalité soit utilisable. Pour activer/désactiver l'utilisation de javascript, allez dans le menu Accueil->Configuration->Affichage.
|
ErrorModuleRequireJavascript=Le javascript ne doit pas être désactivé pour que cette fonctionnalité soit utilisable. Pour activer/désactiver l'utilisation de javascript, allez dans le menu Accueil->Configuration->Affichage.
|
||||||
ErrorPasswordsMustMatch=Les 2 mots de passe saisis doivent correspondre
|
ErrorPasswordsMustMatch=Les 2 mots de passe saisis doivent correspondre
|
||||||
|
|||||||
@ -22,3 +22,4 @@ AllSalaries=Tous les salaires
|
|||||||
SalariesStatistics=Statistiques
|
SalariesStatistics=Statistiques
|
||||||
SalariesAndPayments=Salaires et paiements
|
SalariesAndPayments=Salaires et paiements
|
||||||
ConfirmDeleteSalaryPayment=Voulez-vous supprimer ce paiement de salaire ?
|
ConfirmDeleteSalaryPayment=Voulez-vous supprimer ce paiement de salaire ?
|
||||||
|
FillFieldFirst=Remplisez d'abord le champ salarié
|
||||||
|
|||||||
73
htdocs/salaries/ajax/ajaxsalaries.php
Normal file
73
htdocs/salaries/ajax/ajaxsalaries.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
|
* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2010 Cyrille de Lambert <info@auguria.net>
|
||||||
|
*
|
||||||
|
* 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 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
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/salaries/ajax/ajaxsalaries.php
|
||||||
|
* \brief File to return Ajax response on salary request
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('NOTOKENRENEWAL')) {
|
||||||
|
define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIREMENU')) {
|
||||||
|
define('NOREQUIREMENU', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIREHTML')) {
|
||||||
|
define('NOREQUIREHTML', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIREAJAX')) {
|
||||||
|
define('NOREQUIREAJAX', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIRESOC')) {
|
||||||
|
define('NOREQUIRESOC', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOCSRFCHECK')) {
|
||||||
|
define('NOCSRFCHECK', '1');
|
||||||
|
}
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
|
||||||
|
|
||||||
|
restrictedArea($user, 'salaries');
|
||||||
|
|
||||||
|
$fk_user = GETPOST('fk_user', 'int');
|
||||||
|
$return_arr = array();
|
||||||
|
if (!empty(GETPOST('fk_user', 'int'))) {
|
||||||
|
$sql = "SELECT s.amount, s.rowid FROM ".MAIN_DB_PREFIX."salary as s";
|
||||||
|
$sql .= " WHERE s.fk_user = ".$fk_user;
|
||||||
|
$sql .= " AND s.paye = 1";
|
||||||
|
$sql .= $db->order("s.dateep", "DESC");
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$label = "Salary amount";
|
||||||
|
$row_array['label'] = $label;
|
||||||
|
$row_array['value'] = $obj->amount;
|
||||||
|
$row_array['key'] = "Amount";
|
||||||
|
|
||||||
|
array_push($return_arr, $row_array);
|
||||||
|
echo json_encode($return_arr);
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter'));
|
||||||
|
}
|
||||||
@ -466,8 +466,10 @@ if ($action == 'create') {
|
|||||||
// Amount
|
// Amount
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
|
print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||||
print '<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST("amount").'">';
|
print '<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST("amount").'"> ';
|
||||||
print '</td></tr>';
|
print '<button class="dpInvisibleButtons" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans('UpdateAmountWithLastSalary').'</a>';
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
if (!empty($conf->projet->enabled)) {
|
if (!empty($conf->projet->enabled)) {
|
||||||
@ -560,6 +562,42 @@ if ($action == 'create') {
|
|||||||
print $form->buttonsSaveCancel("Save", "Cancel", $addition_button);
|
print $form->buttonsSaveCancel("Save", "Cancel", $addition_button);
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
print '<script>';
|
||||||
|
print '$( document ).ready(function() {';
|
||||||
|
print '$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
|
||||||
|
console.log("We click on link to autofill salary amount");
|
||||||
|
var fk_user = $("#fk_user").val()
|
||||||
|
var url = "'.DOL_URL_ROOT.'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
|
||||||
|
if (fk_user != -1) {
|
||||||
|
$.get(
|
||||||
|
url,
|
||||||
|
function( data ) {
|
||||||
|
if(data!=null) {
|
||||||
|
console.log("Data returned: "+data);
|
||||||
|
item = JSON.parse(data);
|
||||||
|
if(item[0].key == "Amount") {
|
||||||
|
value = item[0].value;
|
||||||
|
if (value != null) {
|
||||||
|
$("#amount").val(item[0].value);
|
||||||
|
} else {
|
||||||
|
console.error("Error: Ajax url "+url+" has returned a null value.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error("Error: Ajax url "+url+" has returned the wrong key.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error("Error: Ajax url "+url+" has returned an empty page.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert("'.$langs->trans("FillFieldFirst").'");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})';
|
||||||
|
print '</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user