diff --git a/dev/initdemo/savedemo.sh b/dev/initdemo/savedemo.sh index fd3f8caafd5..20aebb29b28 100755 --- a/dev/initdemo/savedemo.sh +++ b/dev/initdemo/savedemo.sh @@ -187,6 +187,7 @@ export list=" --ignore-table=$base.llx_bt_webseedfiles --ignore-table=$base.llx_c_civilite --ignore-table=$base.llx_c_dolicloud_plans + --ignore-table=$base.llx_c_pays --ignore-table=$base.llx_c_source --ignore-table=$base.llx_cabinetmed_c_banques --ignore-table=$base.llx_cabinetmed_c_ccam diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 733524e53c0..bdb43dd41d3 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -33,7 +33,7 @@ class Subscription extends CommonObject public $element='subscription'; public $table_element='subscription'; public $picto='payment'; - + var $datec; // Date creation var $datem; // Date modification var $dateh; // Subscription start date (date subscription) @@ -193,12 +193,11 @@ class Subscription extends CommonObject */ function delete($user) { - $accountline=new AccountLine($this->db); - // It subscription is linked to a bank transaction, we get it if ($this->fk_bank > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline=new AccountLine($this->db); $result=$accountline->fetch($this->fk_bank); } @@ -288,7 +287,7 @@ class Subscription extends CommonObject { return ''; } - + /** * Renvoi le libelle d'un statut donne * @@ -301,7 +300,7 @@ class Subscription extends CommonObject $langs->load("members"); return ''; } - + /** * Load information of the subscription object * diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 9fa30981a9f..e3b3d1ff3ee 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("companies"); $langs->load("bills"); @@ -815,7 +815,6 @@ if ($rowid > 0) if ($result) { $subscriptionstatic=new Subscription($db); - $accountstatic=new Account($db); $num = $db->num_rows($result); $i = 0; @@ -834,6 +833,8 @@ if ($rowid > 0) } print "\n"; + $accountstatic=new Account($db); + while ($i < $num) { $objp = $db->fetch_object($result); @@ -845,20 +846,23 @@ if ($rowid > 0) print ''.dol_print_date($db->jdate($objp->dateh),'day')."\n"; print ''.dol_print_date($db->jdate($objp->datef),'day')."\n"; print ''.price($objp->subscription).''; - if (! empty($conf->banque->enabled)) - { - print ''; - if ($objp->bid) - { - $accountstatic->label=$objp->label; - $accountstatic->id=$objp->baid; - $accountstatic->number=$objp->number; - $accountstatic->account_number=$objp->account_number; + if (! empty($conf->banque->enabled)) + { + print ''; + if ($objp->bid) + { + $accountstatic->label=$objp->label; + $accountstatic->id=$objp->baid; + $accountstatic->number=$objp->number; + $accountstatic->account_number=$objp->account_number; - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->fk_accountancy_journal); + if (! empty($conf->accounting->enabled)) + { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + } $accountstatic->ref=$objp->ref; print $accountstatic->getNomUrl(1); @@ -1092,12 +1096,12 @@ if ($rowid > 0) print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - $prodtmp=new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product - } + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + $prodtmp=new Product($db); + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product + } print '
'; } // Add invoice with payments @@ -1117,12 +1121,12 @@ if ($rowid > 0) print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - $prodtmp=new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product - } + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + $prodtmp=new Product($db); + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product + } print '
'; } print ''; diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index f86da6d8fcc..3fddfadefb4 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -25,7 +25,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} $langs->load("companies"); $langs->load("bills"); @@ -231,20 +233,20 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') if (! empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''.$langs->trans("BankTransactionLine").''; + { + print ''.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline=new AccountLine($db); + $result=$bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1,0,'showall'); } else { print $langs->trans("NoneF"); } - print ''; - } + print ''; + } } print ''; @@ -326,27 +328,26 @@ if ($rowid && $action != 'edit') // Amount print ''.$langs->trans("Label").''.$object->note.''; - // Bank line + // Bank line if (! empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''.$langs->trans("BankTransactionLine").''; + { + print ''.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1,0,'showall'); + $bankline=new AccountLine($db); + $result=$bankline->fetch($object->fk_bank); + print $bankline->getNomUrl(1,0,'showall'); } else { print $langs->trans("NoneF"); } - print ''; - } + print ''; + } } - print "\n"; print ''; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 4d22ec1f6a6..6b4bcaa74ae 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -304,22 +304,22 @@ if ($result) print dol_trunc($obj->note,32); print ''; - // Banque - if (! empty($conf->banque->enabled)) - { - if ($obj->fk_account) - { - $accountstatic->id=$obj->fk_account; - $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print ''.$accountstatic->getNomUrl(1).''; - } - else - { - print ""; - print "\n"; - } - } + // Banque + if (! empty($conf->banque->enabled)) + { + if ($obj->fk_account > 0) + { + $accountstatic->id=$obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print ''.$accountstatic->getNomUrl(1).''; + } + else + { + print ""; + print "\n"; + } + } // Date start print ''.dol_print_date($db->jdate($obj->dateadh),'day')."\n"; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 7a34d1a3a76..0127b8f15be 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -389,7 +389,7 @@ if ($socid > 0) $facturestatic->id=$obj->fk_facture_source; $facturestatic->ref=$obj->ref; $facturestatic->type=$obj->type; - print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1); + print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("ExcessReceived"),$obj->description).' '.$facturestatic->getNomURl(1); print ''; } else diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index a504a730976..3d67f2bfad1 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -135,7 +135,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; @@ -256,7 +256,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; @@ -470,7 +470,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cb1b1fd1e77..55b128bcb6a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2905,12 +2905,12 @@ else if ($id > 0 || ! empty($ref)) $resteapayer = 0; $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%'))"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'"; + $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'))"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); @@ -2933,9 +2933,9 @@ else if ($id > 0 || ! empty($ref)) // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if($object->type == 0) $type_fac = 'ExcessReceived'; - elseif($object->type == 2) $type_fac = 'CreditNote'; - elseif($object->type == 3) $type_fac = 'Deposit'; + if($object->type == Facture::TYPE_STANDARD) $type_fac = 'ExcessReceived'; + elseif($object->type == Facture::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; + elseif($object->type == Facture::TYPE_DEPOSIT) $type_fac = 'Deposit'; $text = $langs->trans('ConfirmConvertToReduc', strtolower($langs->transnoentities($type_fac))); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index d4432435704..37dedea8b6b 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -445,14 +445,14 @@ class DiscountAbsolute $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql.= ' AND f.type = 2'; + $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received } else if ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql.= ' AND f.type = 2'; + $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 99734a4541c..c29c0f9e924 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1232,6 +1232,12 @@ class Form $disabled=' disabled'; } + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) + { + $tmpfac = new Facture($this->db); + if ($tmpfac->fetch($obj->fk_facture_source) > 0) $desc=$desc.' - '.$tmpfac->ref; + } + print ''; $i++; } diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 9f8e64a7847..f725e23cad5 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -43,9 +43,80 @@ top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); else header('Cache-Control: no-cache'); + + + +// Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8) +$tradMonths=array( +dol_escape_js($langs->transnoentitiesnoconv("January")), +dol_escape_js($langs->transnoentitiesnoconv("February")), +dol_escape_js($langs->transnoentitiesnoconv("March")), +dol_escape_js($langs->transnoentitiesnoconv("April")), +dol_escape_js($langs->transnoentitiesnoconv("May")), +dol_escape_js($langs->transnoentitiesnoconv("June")), +dol_escape_js($langs->transnoentitiesnoconv("July")), +dol_escape_js($langs->transnoentitiesnoconv("August")), +dol_escape_js($langs->transnoentitiesnoconv("September")), +dol_escape_js($langs->transnoentitiesnoconv("October")), +dol_escape_js($langs->transnoentitiesnoconv("November")), +dol_escape_js($langs->transnoentitiesnoconv("December")) +); + +$tradMonthsShort=array( +$langs->trans("JanuaryMin"), +$langs->trans("FebruaryMin"), +$langs->trans("MarchMin"), +$langs->trans("AprilMin"), +$langs->trans("MayMin"), +$langs->trans("JuneMin"), +$langs->trans("JulyMin"), +$langs->trans("AugustMin"), +$langs->trans("SeptemberMin"), +$langs->trans("OctoberMin"), +$langs->trans("NovemberMin"), +$langs->trans("DecemberMin") +); + +$tradDays=array( +$langs->trans("Sunday"), +$langs->trans("Monday"), +$langs->trans("Tuesday"), +$langs->trans("Wednesday"), +$langs->trans("Thursday"), +$langs->trans("Friday"), +$langs->trans("Saturday") +); + +$tradDaysShort=array( +$langs->trans("ShortSunday"), +$langs->trans("ShortMonday"), +$langs->trans("ShortTuesday"), +$langs->trans("ShortWednesday"), +$langs->trans("ShortThursday"), +$langs->trans("ShortFriday"), +$langs->trans("ShortSaturday") +); + +$tradDaysMin=array( +$langs->trans("SundayMin"), +$langs->trans("MondayMin"), +$langs->trans("TuesdayMin"), +$langs->trans("WednesdayMin"), +$langs->trans("ThursdayMin"), +$langs->trans("FridayMin"), +$langs->trans("SaturdayMin") +); + ?> // Javascript libraries for Dolibarr ERP CRM (https://www.dolibarr.org) +// For jQuery date picker +var tradMonths = ; +var tradMonthsShort = ; +var tradDays = ; +var tradDaysShort = ; +var tradDaysMin = ; + /** * Set select2 translations (if module was loaded). diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c00249dc8c5..23726ad15e6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -54,16 +54,7 @@ if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -$langs->load('admin'); -$langs->load('orders'); -$langs->load('sendings'); -$langs->load('companies'); -$langs->load('bills'); -$langs->load('propal'); -$langs->load('supplier_proposal'); -$langs->load('deliveries'); -$langs->load('products'); -$langs->load('stocks'); +$langs->loadLangs(array('admin','orders','sendings','companies','bills','propal','supplier_proposal','deliveries','products','stocks','productbatch')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $id = GETPOST('id','int'); diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 84f74c30c54..2b39c18cbb2 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -1,5 +1,5 @@ // Copyright (C) 2014 Cedric GROSS -// Copyright (C) 2015 Francis Appels +// Copyright (C) 2017 Francis Appels // // 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 @@ -24,7 +24,7 @@ * addDispatchLine * Adds new table row for dispatching to multiple stock locations * - * @param index int index of produt line. 0 = first product line + * @param index int index of product line. 0 = first product line * @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 */ @@ -35,17 +35,17 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; if (mode === 'lessone') { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1; } else { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + qty; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + qty; } if (qtyDispatched < qtyOrdered) @@ -63,10 +63,10 @@ function addDispatchLine(index, type, mode) //insert new row before last row $("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row); //remove cloned select2 with duplicate id. - $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); + $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); /* Suffix of lines are: _ trs.length _ index */ $("#qty_"+nbrTrs+"_"+index).focus(); - $("#qty_dispatched_"+(nbrTrs)+"_"+index).val(qtyDispatched); + $("#qty_dispatched_0_"+index).val(qtyDispatched); //hide all buttons then show only the last one $("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide(); @@ -74,15 +74,51 @@ function addDispatchLine(index, type, mode) if (mode === 'lessone') { - $("#qty_"+(nbrTrs)+"_"+index).val(qty-1); - $("#qty_"+(nbrTrs-1)+"_"+index).val(1); + qty = 1; // keep 1 in old line + $("#qty_"+(nbrTrs-1)+"_"+index).val(qty); } - else - { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); - } - + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // 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); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } +} + +/** + * onChangeDispatchLineQty + * + * Change event handler for dispatch qty input field, + * recalculate qty dispatched when qty input has changed. + * If qty is more then qty ordered reset input qty to max qty to dispatch. + * + * 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')), + changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched; + + 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 + + console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + + if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { + $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); + } else { + $(this).val($(this).data('qty')); + } + $(this).data('qty', $(this).val()); + } } \ No newline at end of file diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 778ac05fdfb..7cff22df092 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -267,6 +267,7 @@ CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% CompanyHasNoRelativeDiscount=This customer has no relative discount by default CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for %s %s +CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for %s %s CompanyHasCreditNote=This customer still has credit notes for %s %s CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b2cbadd1ef..6321856bfb3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1329,10 +1329,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; // Add datepicker default options (needed by jquery datepicker!) - if (! defined('DISABLE_DATE_PICKER')) + /*if (! defined('DISABLE_DATE_PICKER')) { print ''."\n"; - } + }*/ // JS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 24b011dbd66..41c62ced1b8 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1447,9 +1447,13 @@ else print ''; print "\n"; + //$childids = $user->getAllChildIds(1); + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { + // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). + // However, he can see the valuation of timesheet of its subordinates even without these permissions. $langs->load("salaries"); // THM