Merge branch 'develop' into agenda-fcomm-cancel

This commit is contained in:
Christian Foellmann 2021-07-29 08:14:02 +02:00 committed by GitHub
commit b9cb04d4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 103 additions and 43 deletions

View File

@ -27,17 +27,42 @@
// $permissiondellink must be defined
$dellinkid = GETPOST('dellinkid', 'int');
$addlink = GETPOST('addlink', 'alpha');
$addlinkid = GETPOST('idtolinkto', 'int');
$addlinkref = GETPOST('reftolinkto', 'alpha');
$cancellink = GETPOST('cancel', 'alpha');
// Link invoice to order
if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) {
if ($action == 'addlink' && !empty($permissiondellink) && !$cancellink && $id > 0 && $addlinkid > 0) {
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid);
$result = $object->add_object_linked($addlink, $addlinkid);
}
// Link by reference
if ($action == 'addlinkbyref' && ! empty($permissiondellink) && !$cancellink && $id > 0 && !empty($addlinkref) && !empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
$element_prop = getElementProperties($addlink);
if (is_array($element_prop)) {
dol_include_once('/' . $element_prop['classpath'] . '/' . $element_prop['classfile'] . '.class.php');
$objecttmp = new $element_prop['classname']($db);
$ret = $objecttmp->fetch(0, $addlinkref);
if ($ret > 0) {
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->add_object_linked($addlink, $objecttmp->id);
if (isset($_POST['reftolinkto'])) unset($_POST['reftolinkto']);
} elseif ($ret < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
} else {
$langs->load('errors');
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
}
}
}
// Delete link
if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0) {
if ($action == 'dellink' && !empty($permissiondellink) && !$cancellink && $dellinkid > 0) {
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');

View File

@ -680,9 +680,7 @@ class dolReceiptPrinter extends Printer
foreach ($object->lines as $line) {
$total_localtax1 += $line->total_localtax1;
}
foreach ($vatarray as $vatkey => $vatvalue) {
$this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n");
}
$this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n");
break;
case 'DOL_PRINT_OBJECT_TAX2':
//var_dump($object);
@ -690,9 +688,7 @@ class dolReceiptPrinter extends Printer
foreach ($object->lines as $line) {
$total_localtax2 += $line->total_localtax2;
}
foreach ($vatarray as $vatkey => $vatvalue) {
$this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n");
}
$this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n");
break;
case 'DOL_PRINT_OBJECT_TOTAL':
$title = $langs->trans('TotalHT');

View File

@ -1332,7 +1332,7 @@ class Form
}
// We search companies
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
$sql .= ", s.address, s.zip, s.town";
$sql .= ", dictp.code as country_code";
@ -1384,6 +1384,7 @@ class Form
$sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
}
$sql .= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'";
$sql .= " OR s.name_alias LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.tva_intra LIKE '".$this->db->escape($prefix.$filterkey)."%'";
$sql .= ")";
}
$sql .= $this->db->order("nom", "ASC");
@ -7970,6 +7971,21 @@ class Form
if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
print '<div id="'.$key.'list"'.(empty($conf->use_javascript_ajax) ? '' : ' style="display:none"').'>';
if (!empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
print '<br><form action="' . $_SERVER["PHP_SELF"] . '" method="POST" name="formlinkedbyref' . $key . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="action" value="addlinkbyref">';
print '<input type="hidden" name="addlink" value="' . $key . '">';
print '<table class="noborder">';
print '<tr>';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td><input type="text" name="reftolinkto" value="' . dol_escape_htmltag(GETPOST('reftolinkto', 'alpha')) . '">&nbsp;<input type="submit" class="button valignmiddle" value="' . $langs->trans('ToLink') . '">&nbsp;<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></td>';
print '</tr>';
print '</table>';
print '</form>';
}
$sql = $possiblelink['sql'];
$resqllist = $this->db->query($sql);
@ -8027,7 +8043,7 @@ class Form
print '</div>';
//$linktoelem.=($linktoelem?' &nbsp; ':'');
if ($num > 0) {
if ($num > 0 || !empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
$linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>';
// } else $linktoelem.=$langs->trans($possiblelink['label']);
} else {

View File

@ -1,5 +1,6 @@
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Copyright (C) 2015-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Josep Lluís Amador <joseplluis@lliuretic.cat>
*
* 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
@ -257,7 +258,7 @@ function updateTotal(days,mode)
result=parseTime(jQuery('.totalDay'+stringdays).text(),taskTime);
if (result >= 0)
{
totalhour = totalhour + taskTime.getHours();
totalhour = totalhour + taskTime.getHours() + result*24;
totalmin = totalmin + taskTime.getMinutes();
}
}

View File

@ -10204,7 +10204,7 @@ function newToken()
*/
function currentToken()
{
return $_SESSION['token'];
return isset($_SESSION['token']) ? $_SESSION['token'] : '';
}
/**

View File

@ -581,6 +581,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
$object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
if (!empty($object->context['comments'])) {
$object->actionmsg .= '<br>';
$object->actionmsg .= $langs->trans("Comment") . ': '.$object->context['comments'];
}
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_RECEIVE') {
// Load translation files required by the page

View File

@ -983,7 +983,9 @@ if (empty($reshook)) {
if ($action == 'commande') {
$methodecommande = GETPOST('methodecommande', 'int');
if ($methodecommande <= 0) {
if ($cancel) {
$action = '';
} elseif ($methodecommande <= 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("OrderMode")), null, 'errors');
$action = 'makeorder';
}
@ -1059,32 +1061,36 @@ if (empty($reshook)) {
// Set status of reception (complete, partial, ...)
if ($action == 'livraison' && $usercanreceived) {
$db->begin();
if ($cancel) {
$action = '';
} else {
$db->begin();
if (GETPOST("type") != '') {
$date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
if (GETPOST("type") != '') {
$date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
if ($result > 0) {
$langs->load("deliveries");
setEventMessages($langs->trans("DeliveryStateSaved"), null);
$action = '';
} elseif ($result == -3) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
if ($result > 0) {
$langs->load("deliveries");
setEventMessages($langs->trans("DeliveryStateSaved"), null);
$action = '';
} elseif ($result == -3) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Delivery")), null, 'errors');
}
} else {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Delivery")), null, 'errors');
}
if (!$error) {
$db->commit();
} else {
$db->rollback();
if (!$error) {
$db->commit();
} else {
$db->rollback();
}
}
}
@ -2652,7 +2658,11 @@ if ($action == 'create') {
print '</td></tr>';
print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="40" type="text" name="comment"></td></tr>';
print '<tr><td class="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Receive").'"></td></tr>';
print '<tr><td class="center" colspan="2">';
print '<input type="submit" name="receive" class="button" value="'.$langs->trans("Receive").'">';
print ' &nbsp; &nbsp; ';
print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print "</table>\n";
print "</form>\n";
print "<br>";

View File

@ -33,9 +33,10 @@
-- Missing in v14 or lower
-- v15
-- add action trigger
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('ORDER_SUPPLIER_CANCEL','Supplier order request canceled','Executed when a supplier order is canceled','order_supplier',13);
ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN ref_fourn varchar(128);
ALTER TABLE llx_product_customer_price MODIFY COLUMN ref_customer varchar(128);
-- -- add action trigger
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('ORDER_SUPPLIER_CANCEL','Supplier order request canceled','Executed when a supplier order is canceled','order_supplier',13);

View File

@ -28,7 +28,7 @@ create table llx_product_customer_price
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_product integer NOT NULL,
fk_soc integer NOT NULL,
ref_customer varchar(30),
ref_customer varchar(128),
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,

View File

@ -27,7 +27,7 @@ create table llx_product_fournisseur_price
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_product integer,
fk_soc integer,
ref_fourn varchar(30),
ref_fourn varchar(128),
desc_fourn text,
fk_availability integer,
price double(24,8) DEFAULT 0, -- price without tax for quantity

View File

@ -51,6 +51,9 @@ if (!empty($user->socid)) {
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('productcompositioncard', 'globalcard'));
$object = new Product($db);
$objectid = 0;
if ($id > 0 || !empty($ref)) {

View File

@ -59,6 +59,9 @@ if (!empty($user->socid)) {
$fieldvalue = (!empty($id) ? $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
$hookmanager->initHooks(array('productstatscard', 'globalcard'));
$tmp = dol_getdate(dol_now());
$currentyear = $tmp['year'];
if (empty($search_year)) {

View File

@ -511,7 +511,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
// Ref
$suggestedref = (GETPOST("ref") ? GETPOST("ref") : $defaultref);
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.dol_escape_htmltag($suggestedref).'">';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="25" type="text" name="ref" value="'.dol_escape_htmltag($suggestedref).'">';
print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
print '</td></tr>';
@ -796,7 +796,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
// Ref
$suggestedref = $object->ref;
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
print '<td><input size="12" name="ref" value="'.$suggestedref.'">';
print '<td><input size="25" name="ref" value="'.$suggestedref.'">';
print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
print '</td></tr>';