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

This commit is contained in:
Laurent Destailleur 2023-04-28 22:32:09 +02:00
commit f0dd47f8a3
39 changed files with 1307 additions and 100 deletions

View File

@ -222,7 +222,7 @@ class Members extends DolibarrApi
}
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as t";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent AS t LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_member as c";
}

View File

@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi
}
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type AS t LEFT JOIN ".MAIN_DB_PREFIX."adherent_type_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
$sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
// Add sql filters

View File

@ -121,7 +121,7 @@ class Boms extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -141,7 +141,7 @@ class Categories extends DolibarrApi
}
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as t";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie AS t LEFT JOIN ".MAIN_DB_PREFIX."categories_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
$sql .= ' WHERE t.entity IN ('.getEntity('category').')';
if (!empty($type)) {
$sql .= ' AND t.type='.array_search($type, Categories::$TYPES);

View File

@ -134,7 +134,7 @@ class AgendaEvents extends DolibarrApi
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
}
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm AS t LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields AS ef ON (ef.fk_object = t.id)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if (isModEnabled("societe")) {
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -181,7 +181,8 @@ class Proposals extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."propal as t";
$sql .= " FROM ".MAIN_DB_PREFIX."propal AS t LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -1402,6 +1402,8 @@ if (empty($reshook)) {
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) {

View File

@ -184,7 +184,7 @@ class Orders extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."commande as t";
$sql .= " FROM ".MAIN_DB_PREFIX."facture AS t LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -70,7 +70,7 @@ class BankAccounts extends DolibarrApi
throw new RestException(401);
}
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t";
$sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."bank_account AS t LEFT JOIN ".MAIN_DB_PREFIX."bank_account_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_account as c";
}

View File

@ -199,7 +199,7 @@ class Invoices extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."facture as t";
$sql .= " FROM ".MAIN_DB_PREFIX."facture AS t LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -125,7 +125,7 @@ class Contracts extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as t";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat AS t LEFT JOIN ".MAIN_DB_PREFIX."contrat_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -46,6 +46,13 @@ function reception_prepare_head(Reception $object)
$head[$h][2] = 'reception';
$h++;
if ($object->statut == Reception::STATUS_DRAFT) {
$head[$h][0] = DOL_URL_ROOT."/reception/dispatch.php?id=".$object->id;
$head[$h][1] = $langs->trans("DispatchCard");
$head[$h][2] = 'dispatch';
$h++;
}
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
$objectsrc = $object;
if ($object->origin == 'supplier_order' && $object->origin_id > 0) {

View File

@ -116,7 +116,7 @@ class Donations extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."don as t";
$sql .= " FROM ".MAIN_DB_PREFIX."don AS t LEFT JOIN ".MAIN_DB_PREFIX."don_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
$sql .= ' WHERE t.entity IN ('.getEntity('don').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) {

View File

@ -122,7 +122,7 @@ class Shipments extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as t";
$sql .= " FROM ".MAIN_DB_PREFIX."expedition AS t LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -109,7 +109,7 @@ class ExpenseReports extends DolibarrApi
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport AS t LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
$sql .= ' WHERE t.entity IN ('.getEntity('expensereport').')';
if ($user_ids) {
$sql .= " AND t.fk_user_author IN (".$this->db->sanitize($user_ids).")";

View File

@ -133,7 +133,7 @@ class Interventions extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as t";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter AS t LEFT JOIN ".MAIN_DB_PREFIX."fichinter_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -122,7 +122,7 @@ class SupplierInvoices extends DolibarrApi
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user";
}
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn AS t LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
// We need this table joined to the select in order to filter by sale
if (!DolibarrApiAccess::$user->rights->societe->client->voir || $search_sale > 0) {

View File

@ -120,7 +120,7 @@ class SupplierOrders extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur AS t LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -2110,9 +2110,10 @@ class CommandeFournisseur extends CommonOrder
* @param string $batch Lot number
* @param int $fk_commandefourndet Id of supplier order line
* @param int $notrigger 1 = notrigger
* @param int $fk_reception Id of reception to link
* @return int <0 if KO, >0 if OK
*/
public function dispatchProduct($user, $product, $qty, $entrepot, $price = 0, $comment = '', $eatby = '', $sellby = '', $batch = '', $fk_commandefourndet = 0, $notrigger = 0)
public function dispatchProduct($user, $product, $qty, $entrepot, $price = 0, $comment = '', $eatby = '', $sellby = '', $batch = '', $fk_commandefourndet = 0, $notrigger = 0, $fk_reception = 0)
{
global $conf, $langs;
@ -2142,9 +2143,9 @@ class CommandeFournisseur extends CommonOrder
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch";
$sql .= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet, status, comment, eatby, sellby, batch) VALUES";
$sql .= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet, status, comment, eatby, sellby, batch, fk_reception) VALUES";
$sql .= " ('".$this->id."','".$product."','".$qty."',".($entrepot > 0 ? "'".$entrepot."'" : "null").",'".$user->id."','".$this->db->idate($now)."','".$fk_commandefourndet."', ".$dispatchstatus.", '".$this->db->escape($comment)."', ";
$sql .= ($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ".($batch ? "'".$this->db->escape($batch)."'" : "null");
$sql .= ($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ".($batch ? "'".$this->db->escape($batch)."'" : "null").", ".($fk_reception > 0 ? "'".$this->db->escape($fk_reception)."'" : "null");
$sql .= ")";
dol_syslog(get_class($this)."::dispatchProduct", LOG_DEBUG);

View File

@ -134,7 +134,7 @@ if ($id > 0 || !empty($ref)) {
// Security check
$isdraft = (isset($object->statut) && ($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande', 'fk_soc', 'rowid', $isdraft);
$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande', 'fk_soc', 'rowid', $isdraft);
// Common permissions
$usercanread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);

View File

@ -94,7 +94,7 @@ if (empty($conf->reception->enabled)) {
}
// $id is id of a purchase order.
$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
if (!isModEnabled('stock')) {
accessforbidden();
@ -978,7 +978,8 @@ if ($id > 0 || !empty($ref)) {
// Qty to dispatch
print '<td class="right">';
print '<input id="qty'.$suffix.'" name="qty'.$suffix.'" type="text" class="width50 right" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).'">';
print '<a href="#" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
print '<input id="qty'.$suffix.'" name="qty'.$suffix.'" type="text" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).'">';
print '</td>';
print '<td>';
@ -1115,14 +1116,30 @@ if ($id > 0 || !empty($ref)) {
$("select[name^=entrepot_]").val(fk_default_warehouse).change();
});
jQuery("#autoreset").click(function() {';
$i = 0;
while ($i < $nbproduct) {
print ' jQuery("#qty_0_'.$i.'").val("");';
$i++;
}
print '
$("#autoreset").click(function() {
$(".qtydispatchinput").each(function(){
id = $(this).attr("id");
idtab = id.split("_");
if(idtab[1] == 0){
console.log(idtab);
$(this).val("");
$("#qty_dispatched_0_"+idtab[2]).val("0");
} else {
obj = $(this).parent().parent();
nameobj = obj.attr("name");
nametab = nameobj.split("_");
obj.remove();
$("tr[name^=\'"+nametab[0]+"_\'][name$=\'_"+nametab[2]+"\']:last .splitbutton").show();
}
});
});
$(".resetline").click(function(){
id = $(this).attr("id");
id = id.split("reset_");
console.log("Reset trigger for id = qty_"+id[1]);
$("#qty_"+id[1]).val("");
});
});
</script>';

View File

@ -65,8 +65,7 @@ if (empty($dolibarr_nocache)) {
* @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch)
* @param mode string 'qtymissing' will create new line with qty missing, 'lessone' will keep 1 in old line and the rest in new one
*/
function addDispatchLine(index, type, mode)
{
function addDispatchLine(index, type, mode) {
mode = mode || 'qtymissing'
var $row0 = $("tr[name='"+type+'_0_'+index+"']");
@ -80,20 +79,18 @@ function addDispatchLine(index, type, mode)
var qtyDispatched;
if (mode === 'lessone')
{
qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1;
if (mode === 'lessone') {
qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()) + 1;
}
else
{
qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + qty;
else {
qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()) + qty;
// If user did not reduced the qty to dispatch on old line, we keep only 1 on old line and the rest on new line
if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1;
qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()) + 1;
mode = 'lessone';
}
}
console.log("qtyDispatched="+qtyDispatched+" qtyOrdered="+qtyOrdered);
console.log("qtyDispatched=" + qtyDispatched + " qtyOrdered=" + qtyOrdered);
if (qty <= 1) {
window.alert("Remain quantity to dispatch is too low to be split");
@ -107,7 +104,7 @@ function addDispatchLine(index, type, mode)
}
//replace tr suffix nbr
$row.html($row.html().replace(/_0_/g,"_"+nbrTrs+"_"));
$row.html($row.html().replace(/_0_/g, "_" + nbrTrs + "_"));
// jquery's deep clone is incompatible with date pickers (the clone shares data with the original)
// so we destroy and rebuild the new date pickers
@ -121,27 +118,42 @@ function addDispatchLine(index, type, mode)
}, 0);
//create new select2 to avoid duplicate id of cloned one
$row.find("select[name='"+'entrepot_'+nbrTrs+'_'+index+"']").select2();
$row.find("select[name='" + 'entrepot_' + nbrTrs + '_' + index + "']").select2();
// TODO find solution to copy selected option to new select
// TODO find solution to keep new tr's after page refresh
//clear value
$row.find("input[name^='qty']").val('');
//change name of new row
$row.attr('name',type+'_'+nbrTrs+'_'+index);
$row.attr('name', type + '_' + nbrTrs + '_' + index);
//insert new row before last row
$("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row);
$("tr[name^='" + type + "_'][name$='_" + index + "']:last").after($row);
//remove cloned select2 with duplicate id.
$("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); // old way to find duplicated select2 component
$(".csswarehouse_"+nbrTrs+"_"+index+":first-child").parent("span.selection").parent(".select2").detach();
$("#s2id_entrepot_" + nbrTrs + '_' + index).detach(); // old way to find duplicated select2 component
$(".csswarehouse_" + nbrTrs + "_" + index + ":first-child").parent("span.selection").parent(".select2").detach();
/* Suffix of lines are: _ trs.length _ index */
$("#qty_"+nbrTrs+"_"+index).focus();
$("#qty_dispatched_0_"+index).val(oldlineqty);
//hide all buttons then show only the last one
$("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide();
$("tr[name^='"+type+"_'][name$='_"+index+"']:last .splitbutton").show();
$("tr[name^='" + type + "_'][name$='_" + index + "'] .splitbutton").hide();
$("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show();
$("#reset_" + (nbrTrs) + "_" + index).click(function () {
id = $(this).attr("id");
id = id.split("reset_");
idrow = id[1];
idlast = $("tr[name^='" + type + "_'][name$='_" + index + "']:last .qtydispatchinput").attr("id");
if (idlast == $("#qty_" + idrow).attr("id")) {
console.log("Remove trigger for tr name = " + type + "_" + idrow);
$('tr[name="' + type + '_' + idrow + '"').remove();
$("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show();
} else {
console.log("Reset trigger for id = #qty_" + idrow);
$("#qty_" + idrow).val("");
}
});
if (mode === 'lessone')
{
@ -150,13 +162,19 @@ function addDispatchLine(index, type, mode)
}
$("#qty_"+nbrTrs+"_"+index).val(newlineqty);
// Store arbitrary data for dispatch qty input field change event
$("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty);
$("#qty_"+(nbrTrs-1)+"_"+index).data('type', type);
$("#qty_"+(nbrTrs-1)+"_"+index).data('index', index);
$("#qty_" + (nbrTrs - 1) + "_" + index).data('qty', qty);
$("#qty_" + (nbrTrs - 1) + "_" + index).data('type', type);
$("#qty_" + (nbrTrs - 1) + "_" + index).data('index', index);
// Update dispatched qty when value dispatch qty input field changed
$("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty);
//$("#qty_" + (nbrTrs - 1) + "_" + index).change(this.onChangeDispatchLineQty);
//set focus on lot of new line (if it exists)
$("#lot_number_"+(nbrTrs)+"_"+index).focus();
$("#lot_number_" + (nbrTrs) + "_" + index).focus();
//Clean bad values
$("tr[name^='" + type + "_'][name$='_" + index + "']:last").data("remove", "remove");
$("#lot_number_" + (nbrTrs) + "_" + index).val("")
$("#idline_" + (nbrTrs) + "_" + index).val("-1")
$("#qty_" + (nbrTrs) + "_" + index).data('expected', "0");
$("#lot_number_" + (nbrTrs) + "_" + index).removeAttr("disabled");
}
}
@ -170,26 +188,28 @@ function addDispatchLine(index, type, mode)
* element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line)
*/
function onChangeDispatchLineQty() {
var index = $(this).data('index'),
type = $(this).data('type'),
qty = parseFloat($(this).data('qty')),
function onChangeDispatchLineQty(element) {
var type = $(element).data('type'),
qty = parseFloat($(element).data('expected')),
changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched;
id = $(element).attr("id");
id = id.split("_");
index = id[2];
if (index >= 0 && type && qty >= 0) {
nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length;
qtyChanged = parseFloat($(this).val()) - qty; // qty changed
qtyDispatching = parseFloat($("#qty_"+(nbrTrs-1)+"_"+index).val()); // qty currently being dispatched
qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered
qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched
nbrTrs = $("tr[name^='" + type + "_'][name$='_" + index + "']").length;
qtyChanged = parseFloat($(element).val()) - qty; // qty changed
qtyDispatching = parseFloat($(element).val()); // qty currently being dispatched
qtyOrdered = parseFloat($("#qty_ordered_0_" + index).val()); // qty ordered
qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()); // qty already dispatched
console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched);
console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: " + qtyDispatched);
if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) {
$("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged);
$("#qty_dispatched_0_" + index).val(qtyDispatched + qtyChanged);
} else {
$(this).val($(this).data('qty'));
$(element).val($(element).data('expected'));
}
$(this).data('qty', $(this).val());
$(element).data('expected', $(element).val());
}
}

View File

@ -93,9 +93,20 @@ $long_options = array(
function usage($program, $header)
{
echo $header."\n";
echo " php ".$program." [options] previous_version new_version [script options]\n";
echo " php ".$program." [options] [script options]\n";
echo "\n";
echo "Script options when using upgrade.php:\n";
echo "Script syntax when using step2.php:\n";
echo " php ".$program." [options] [action] [selectlang]\n";
echo "\n";
echo " action:\n";
echo " Specify the action to execute for the file among the following ones.\n";
echo " - set: Create tables, keys, functions and data for the instance.\n";
echo "\n";
echo " selectlang:\n";
echo " Setup the default lang to use, default to 'auto'.\n";
echo "\n";
echo "Script syntax when using upgrade.php:\n";
echo " php ".$program." [options] previous_version new_version [script options]\n";
echo "\n";
echo " dirmodule:\n";
echo " Specify dirmodule to provide a path for an external module\n";
@ -105,10 +116,11 @@ function usage($program, $header)
echo " Allow to run migration even if database version does\n";
echo " not match start version of migration.\n";
echo "\n";
echo "Script options when using upgrade2.php:\n";
echo "Script syntax when using upgrade2.php:\n";
echo " php ".$program." [options] previous_version new_version [module list]\n";
echo "\n";
echo " MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE:\n";
echo " Specify a list of module-name to enable, joined by comma.\n";
echo " MAIN_MODULE_NAME1,MAIN_MODULE_NAME2:\n";
echo " Specify a list of module-name to enable, in upper case, with MAIN_MODULE_ prefix, joined by comma.\n";
echo "\n";
echo "Options:\n";
echo " -c, --config <filename>:\n";
@ -134,19 +146,26 @@ if (php_sapi_name() === "cli") {
exit(0);
}
// Parse the arguments to find the options.
$args_options = array_filter(array_slice($argv, 0, $rest_index), function ($arg) {
return strlen($arg) >= 2 && $arg[0] == '-';
});
$parsed_options = array_map(function ($arg) {
if (strlen($arg) > 1)
return "--" . $arg;
return "-" . $arg;
}, array_keys($opts));
// Find options (dash-prefixed) that were not parsed.
$unknown_options = array_diff($args_options, $parsed_options);
// In the following test, only dash-prefixed arguments will trigger an
// error, given that scripts options can allow a variable number of
// additional non-prefixed argument and we mostly want to check for
// typo right now.
if ($rest_index < $argc && $argv[$rest_index][0] == "-") {
usage($argv[0], "Unknown option ".$argv[$rest_index]. ", usage:");
exit(1);
}
// Currently, scripts using inc.php will require addtional arguments,
// see help above for more details.
if ($rest_index > $argc - 2) {
usage($argv[0], "Missing mandatory arguments, usage:");
if (count($unknown_options) > 0) {
echo "Unknown option: ".array_values($unknown_options)[0]."\n";
usage($argv[0], "Usage:");
exit(1);
}

View File

@ -162,7 +162,7 @@ class KnowledgeManagement extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -51,4 +51,7 @@ NoMorePredefinedProductToDispatch=No more predefined products to dispatch
ReceptionExist=A reception exists
ReceptionBackToDraftInDolibarr=Reception %s back to draft
ReceptionClassifyClosedInDolibarr=Reception %s classified Closed
ReceptionUnClassifyCloseddInDolibarr=Reception %s re-open
ReceptionUnClassifyCloseddInDolibarr=Reception %s re-open
ResetQtyToDispatch=Reset all quantities to dispatch
ReceptionUpdated=Reception sucessfully updated
DispatchCard=Dispatch card

View File

@ -129,7 +129,7 @@ class MyModuleApi extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -119,7 +119,7 @@ class Mos extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -127,7 +127,7 @@ class PartnershipApi extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -873,7 +873,8 @@ class Products extends DolibarrApi
}
$sql = "SELECT t.rowid, t.ref, t.ref_ext";
$sql .= " FROM ".$this->db->prefix()."product as t";
$sql .= " FROM ".MAIN_DB_PREFIX."product AS t LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($category > 0) {
$sql .= ", ".$this->db->prefix()."categorie_product as c";
}

View File

@ -572,7 +572,7 @@ class Product extends CommonObject
*/
public function check()
{
if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
if (getDolGlobalInt('MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS')) {
$this->ref = trim($this->ref);
} else {
$this->ref = dol_sanitizeFileName(stripslashes($this->ref));
@ -608,7 +608,7 @@ class Product extends CommonObject
$error = 0;
// Clean parameters
if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
if (getDolGlobalInt('MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS')) {
$this->ref = trim($this->ref);
} else {
$this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref)));
@ -702,7 +702,7 @@ class Product extends CommonObject
if (empty($this->ref) || $this->ref == 'auto') {
// Load object modCodeProduct
$module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard');
$module = getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON', 'mod_codeproduct_leopard');
if ($module != 'mod_codeproduct_leopard') { // Do not load module file for leopard
if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') {
$module = substr($module, 0, dol_strlen($module) - 4);
@ -1008,7 +1008,7 @@ class Product extends CommonObject
}
// Clean parameters
if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
if (getDolGlobalInt('MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS')) {
$this->ref = trim($this->ref);
} else {
$this->ref = dol_string_nospecial(trim($this->ref));

View File

@ -104,7 +104,8 @@ class StockMovements extends DolibarrApi
}
$sql = "SELECT t.rowid";
$sql .= " FROM ".$this->db->prefix()."stock_mouvement as t";
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement AS t LEFT JOIN ".MAIN_DB_PREFIX."stock_mouvement_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
//$sql.= ' WHERE t.entity IN ('.getEntity('stock').')';
$sql .= ' WHERE 1 = 1';
// Add sql filters

View File

@ -104,7 +104,7 @@ class Warehouses extends DolibarrApi
}
$sql = "SELECT t.rowid";
$sql .= " FROM ".$this->db->prefix()."entrepot as t";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot AS t LEFT JOIN ".MAIN_DB_PREFIX."entrepot_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($category > 0) {
$sql .= ", ".$this->db->prefix()."categorie_societe as c";
}

View File

@ -127,7 +127,7 @@ class Tasks extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS t LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -121,7 +121,7 @@ class Receptions extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."reception as t";
$sql .= " FROM ".MAIN_DB_PREFIX."reception AS t LEFT JOIN ".MAIN_DB_PREFIX."reception_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
@ -709,7 +709,7 @@ class Receptions extends DolibarrApi
private function _validate($data)
{
$reception = array();
foreach (Receptions::$FIELDS as $field) {
foreach (Shipments::$FIELDS as $field) {
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}

File diff suppressed because it is too large Load Diff

View File

@ -165,7 +165,7 @@ class Recruitment extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
@ -272,7 +272,7 @@ class Recruitment extends DolibarrApi
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
$sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." AS t LEFT JOIN ".MAIN_DB_PREFIX.$tmpobject->table_element."_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -117,7 +117,7 @@ class Supplierproposals extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal AS t LEFT JOIN ".MAIN_DB_PREFIX."supplier_proposal_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -223,7 +223,7 @@ class Tickets extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket AS t LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale

View File

@ -82,7 +82,7 @@ class Users extends DolibarrApi
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
$sql = "SELECT t.rowid";
$sql .= " FROM ".$this->db->prefix()."user as t";
$sql .= " FROM ".MAIN_DB_PREFIX."user AS t LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
if ($category > 0) {
$sql .= ", ".$this->db->prefix()."categorie_user as c";
}
@ -535,7 +535,7 @@ class Users extends DolibarrApi
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
$sql = "SELECT t.rowid";
$sql .= " FROM ".$this->db->prefix()."usergroup as t";
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup AS t LEFT JOIN ".MAIN_DB_PREFIX."usergroup_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
$sql .= ' WHERE t.entity IN ('.getEntity('user').')';
if ($group_ids) {
$sql .= " AND t.rowid IN (".$this->db->sanitize($group_ids).")";