diff --git a/ChangeLog b/ChangeLog index 84d05ba8ea7..ef52f808ec7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,71 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. +***** ChangeLog for 3.9.1 compared to 3.9.* ***** +FIX: #3815 Call to undefined function local_by_date() +FIX: #4424 Missing email of user popup in supplier orders area +FIX: #4442 Missing translation in Banks menu +FIX: #4737 Bank transacion type selector translation is cropped +FIX: #4742 Able to delete a supplier invoice with a registered payment +FIX: #4743 UI glitch in project summary page +FIX: #4747 Missing UI background when registering a supplier invoice payment +FIX: #4748 Supplier invoice payment confirmation amount is not translated +FIX: #4766 VAT not shown in supplier invoice popup +FIX: #4784 +FIX: #4809 Duplicate functions with different content +FIX: #4812 +FIX: #4839 +FIX: #4851 Project selector in supplier invoices shows the project label twice +FIX: #4870 +FIX: #4874 SQL error when listing users +FIX: #4880 +FIX: #4961 +FIX: #4989 +FIX: If oauth has never been activated two tables are missing and printing is not working +FIX: A not enabled field for list must not into fields to add +FIX: Bad color of message password changed +FIX: Bad error and style message when changing its own login +FIX: Bad function name call on delete +FIX: Bad include and param for project numbering module call +FIX: bad translation language loaded FIX: When changing thirdparty on event card, the showempty option of contact was lost. FIX: Bad placeholder shown on combo to select a thirdparty. +FIX: Bad vat definition when using POS module +FIX: Box disabled because bugged +FIX: Can not select a commercial on the creation of a third +FIX: Check of EAN13 barcode when mask was set to use 13 digits instead of 12 +FIX: correct display of minimum buying price +FIX: Creation of thumb image for size "small" was not done. +FIX: Damn, where was the project ref ? +FIX: Default vat is not set correctly when an error occured and we use VAT identified by a code. +FIX: dont retrieve new buying price on margin display +FIX: Duplicate records into export +FIX: Each time we edit a line, we loose the unit price. +FIX: Email templates not compatible with Multicompany +FIX: Export must use a left join to not loose lines +FIX: fetchAllEMailTemplate +FIX: Filter/search on extrafields on lists +FIX: finished parameters not used +FIX: Generated thumbs must always use the png format so using thumbs can work. +FIX: Hook resprint be printed +FIX: image extension must be in lower case +FIX: Missing clean of criteria +FIX: Missing database escaping on supplier price insert/update +FIX: Missing function +FIX: Multiprice generator didn't recalculate prices if only the price_base_type property changes +FIX: Not removing code into vatrate. +FIX: Not showing sellprice properly on product list +FIX: Parsing of amount to pay vat +FIX: PHPCS +FIX: PMP is deprecated at warehouse level +FIX: real min buying price +FIX: Same term to create than other objects +FIX: Some records were lost into margin per product report +FIX: systematic rounding causes prices to be updated without reason +FIX: Template email must take care of positino column +FIX: VAT rate can be negative. Example spain selling to morroco. +FIX: When cloning an order the order result from clone must be now +FIX: When using option Price per level, when adding a predefined product, the vat for customer was not correctly set. + + ***** ChangeLog for 3.9.0 compared to 3.8.* ***** For users: NEW: A new and more modern look for "eldy" theme. @@ -1045,6 +1110,11 @@ Dolibarr better: - Replaced USER_UPDATE_SESSION trigger with an updateSession hook may break modules using it. + +***** ChangeLog for 3.6.7 compared to 3.6.6 ***** +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: CVE CVE-2015-8685 + ***** ChangeLog for 3.6.6 compared to 3.6.5 ***** FIX: #3734 Do not show empty links of deleted source objects in stock movement list FIX: #4081 Added missing translation @@ -1297,6 +1367,17 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f - Remove add_photo_web() that is not used anymore by core code. +***** ChangeLog for 3.5.8 compared to 3.5.7 ***** +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: bad calculation for stock value +FIX: bad stock valo +FIX: change order date on clone (as everywhere else) +FIX: CVE CVE-2015-8685 +FIX: The hours of date filter aren't correct +FIX: #3442 Remove useless syslog +FIX: #3448 Pass expected date format +FIX: #3471 3.5 Rounding issue when dispatching non-integer + ***** ChangeLog for 3.5.7 compared to 3.5.6 ***** Fix: Paypal link were broken due to SSL v3 closed. Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index b8c4f2fb475..8a70ea73f2c 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -379,7 +379,7 @@ if ($nboftargetok) { print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n"; $ret=`git tag -a -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD" 2>&1`; - if ($ret =~ /already exists/) + if ($ret =~ /(already exists|existe déjà)/) { print "WARNING: Tag ".$MAJOR.'.'.$MINOR.'.'.$BUILD." already exists. Overwrite (y/N) ? "; $QUESTIONOVERWRITETAG=; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 03cb46adf0d..92b3ec7adc0 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -202,10 +202,9 @@ print "" . $langs->trans("Selectchartofaccounts") . ""; print ""; print ''; - - $this->db->free($result); } + + $form.= ''; + $this->db->free($result); return $form; } else diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 078dc01d96f..d5ce5679dd3 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -805,6 +805,7 @@ class FormOther $select_week .= ''; } $select_week .= ''; return $select_week; @@ -844,6 +845,7 @@ class FormOther $select_month .= ''; } $select_month .= ''; return $select_month; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 6054a32c692..93b4b480dde 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2011 Regis Houssin - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García @@ -178,342 +178,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction } } -/** - * Gets LocalTaxes to collect for the given year (and given quarter or month) - * The function gets the LocalTaxes in split results, as the LocalTaxes declaration asks - * to report the amounts for different LocalTaxes rates as different lines. - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Quarter - * @param string $date_start Start date - * @param string $date_end End date - * @param int $modetax 0 or 1 (option on debit) - * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) - * @param int $local 1 for LocalTax1, 2 for LocalTax2 - * @param int $m Month - * @return array List of quarters with LocalTaxes - */ -function local_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $local, $m=0) -{ - global $conf; - - $list=array(); - - if ($direction == 'sell') - { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='facnumber'; - $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; - } - if ($direction == 'buy') - { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; - $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; - } - - // BIENS - - // Define sql request - $sql=''; - if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services - { - - // Count on delivery date (use invoice date as delivery is unknown) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx,"; - $sql.= " d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - if ($y && $m) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; - } - else if ($y) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; - } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - - } - else // Option on delivery for goods (payments) and payments for services - { - // Count on delivery date (use invoice date as delivery is unknown) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - if ($y && $m) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; - } - else if ($y) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; - } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - - } - - if (! $sql) return -1; - - dol_syslog("Tax.lib.php::vat_by_date sql=".$sql); - - $resql = $db->query($sql); - if ($resql) - { - $lt=-1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; - if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; - - if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { - $oldrowid=$assoc['rowid']; - $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; - } - - $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; - $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; - - $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; - $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); - - $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; - $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; - $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; - $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; - - $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; - - $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; - $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; - $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; - - $lt = $assoc['localtax_tx']; - } - } - else - { - dol_print_error($db); - return -3; - } - - // CAS DES SERVICES - - // Define sql request - $sql=''; - if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services - { - - // Count on invoice date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture; - if ($y && $m) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; - } - else if ($y) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; - } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - - } - else // Option vat on delivery for goods (payments) and payments for services - { - - // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity = " . $conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture;; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; - if ($y && $m) - { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; - } - else if ($y) - { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; - } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= ".$db->idate($date_start)." AND pa.datep <= ".$db->idate($date_end); - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; - - } - - if (! $sql) - { - dol_syslog("Tax.lib.php::local_by_date no accountancy module enabled".$sql,LOG_ERR); - return -1; - } - - dol_syslog("Tax.lib.php::local_by_date sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $lt = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; - if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; - - if ($assoc['rowid'] != $oldrowid) - { - $oldrowid=$assoc['rowid']; - $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; - } - - $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; - $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; - - $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; - $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); - - $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; - $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; - $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; - $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; - - $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; - - $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; - $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; - $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; - - $lt = $assoc['localtax_tx']; - } - } - else - { - dol_print_error($db); - return -3; - } - - return $list; - - -} - - /** * Gets VAT to collect for the given year (and given quarter or month) * The function gets the VAT in split results, as the VAT declaration asks diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 86b8a58e68f..2e37f989b0a 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -206,7 +206,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); -- Accounting Expert -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '(! empty($conf->accounting->enabled) || $user->rights->accounting->ventilation->read || $user->rights->accounting->ventilation->dispatch || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->ventilation->read || $user->rights->accounting->ventilation->dispatch || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Dispatch insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->ventilation->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->ventilation->dispatch', '', 0, 2, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index ae173504ed6..359faa930b4 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -110,7 +110,8 @@ class MenuManager // Modules system tools // TODO Find a way to add parent menu only if child menu exists. For the moment, no other method than hard coded methods. - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->barcode->enabled) // TODO We should enabled module system tools entry without hardcoded test, but when at least one modules bringing such entries are on + // TODO We should enabled module system tools entry without hardcoded test, but when at least one modules bringing such entries are on + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->barcode->enabled) || ! empty($conf->cron->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS)) { if (empty($user->societe_id)) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fafebe3ca18..06e4ceab5b8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -544,14 +544,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Modules system tools - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->barcode->enabled) // TODO We should enabled module system tools entry without hardcoded test, but when at least one modules bringing such entries are on + // TODO We should enabled module system tools entry without hardcoded test, but when at least one modules bringing such entries are on + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->barcode->enabled) || ! empty($conf->cron->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS)) // Some external modules may need to force to have this entry on. { if (empty($user->societe_id)) { $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, $user->admin, '', $mainmenu, 'modulesadmintools'); // Special case: This entry can't be embedded into modules because we need it for both module service and products and we don't want duplicate lines. - if ((empty($leftmenu) || $leftmenu=="modulesadmintools") && $user->admin) + if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && (empty($leftmenu) || $leftmenu=="modulesadmintools") && $user->admin) { $langs->load("products"); $newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin); diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 5177e108f40..3911c4d6be2 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -64,53 +64,53 @@ class printing_printgcp extends PrintingDriver $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $this->db = $db; - $this->google_id = $conf->global->OAUTH_GOOGLE_ID; - $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; - // Token storage - $storage = new DoliStorage($this->db, $this->conf); - //$storage->clearToken('Google'); - // Setup the credentials for the requests - $credentials = new Credentials( - $this->google_id, - $this->google_secret, - $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' - ); - $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); - $serviceFactory = new \OAuth\ServiceFactory(); - $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); - $token_ok=true; - try { - $token = $storage->retrieveAccessToken('Google'); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $token_ok = false; - } - //var_dump($this->errors);exit; - $expire = false; - // Is token expired or will token expire in the next 30 seconds - if ($token_ok) { - $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); - } - - // Token expired so we refresh it - if ($token_ok && $expire) { - try { - // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois - $refreshtoken = $token->getRefreshToken(); - $token = $apiService->refreshAccessToken($token); - $token->setRefreshToken($refreshtoken); - $storage->storeAccessToken('Google', $token); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } if (!$conf->oauth->enabled) { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'ModuleAuthNotActive', 'type'=>'info'); } else { + $this->google_id = $conf->global->OAUTH_GOOGLE_ID; + $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; + // Token storage + $storage = new DoliStorage($this->db, $this->conf); + //$storage->clearToken('Google'); + // Setup the credentials for the requests + $credentials = new Credentials( + $this->google_id, + $this->google_secret, + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' + ); + $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); + $serviceFactory = new \OAuth\ServiceFactory(); + $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); + $token_ok=true; + try { + $token = $storage->retrieveAccessToken('Google'); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $token_ok = false; + } + //var_dump($this->errors);exit; + + $expire = false; + // Is token expired or will token expire in the next 30 seconds + if ($token_ok) { + $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); + } + + // Token expired so we refresh it + if ($token_ok && $expire) { + try { + // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois + $refreshtoken = $token->getRefreshToken(); + $token = $apiService->refreshAccessToken($token); + $token->setRefreshToken($refreshtoken); + $storage->storeAccessToken('Google', $token); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 373cb5f2666..143e86330ee 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -864,16 +864,14 @@ class Expedition extends CommonObject $product=new Product($this->db); $result=$product->fetch($fk_product); - $product_type=$product->type; if ($entrepot_id > 0) { - $product->load_stock(); - $product_stock = $product->stock_warehouse[$entrepot_id]->real; + $product->load_stock(); + $product_stock = $product->stock_warehouse[$entrepot_id]->real; } - else - { - $product_stock = $product->stock_reel; - } - + else + $product_stock = $product->stock_reel; + + $product_type=$product->type; if ($product_type == 0 && $product_stock < $qty) { $this->error=$langs->trans('ErrorStockIsNotEnough'); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 48de12a678c..f3174935cd5 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -333,7 +333,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -390,6 +390,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id else { $mesg=$mailfile->error; + setEventMessages($mesg, null, 'errors'); } // END - Send mail } @@ -438,7 +439,7 @@ if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $u if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -542,7 +543,7 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -583,7 +584,6 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user else { setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - $mesg="Impossible d'envoyer l'email."; } // END - Send mail } @@ -627,7 +627,7 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_ if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -667,6 +667,7 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_ else { $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); } // END - Send mail } @@ -756,7 +757,7 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -806,9 +807,8 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) endif; else: - - $mesg="Impossible d'envoyer l'email."; - + $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); endif; // END - Send mail } @@ -921,7 +921,7 @@ if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes") $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - $result=$object->deleteline(GETPOST("rowid")); + $result=$object->deleteline(GETPOST("rowid"), $user); if ($result >= 0) { if ($result > 0) @@ -961,7 +961,6 @@ if ($action == "updateligne" ) $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees'); - $object_ligne->vatrate = price2num(GETPOST('vatrate')); $projet_id = $fk_projet; $comments = GETPOST('comments'); $qty = GETPOST('qty'); @@ -983,6 +982,7 @@ if ($action == "updateligne" ) if (! $error) { + // TODO Use update method of ExpenseReportLine $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id); if ($result >= 0) { @@ -1078,29 +1078,6 @@ $formfile = new FormFile($db); $formproject = new FormProjets($db); $projecttmp = new Project($db); -if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) -{ - if(!empty($_GET['mesg'])) - { - $text_mesg = explode(",",$_GET['mesg']); - - foreach($text_mesg as $text) - { - $mesg.= "- ".$langs->trans($text)."
"; - } - - print "
"; - print $langs->trans("LINE_NOT_ADDED")."
"; - print $mesg; - print "
"; - } - else - { - if ($mesg) print "
".$mesg."
"; - } -} - - // Create if ($action == 'create') { @@ -1625,7 +1602,7 @@ else $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; $sql.= ' WHERE fde.fk_expensereport = '.$object->id; @@ -1691,7 +1668,7 @@ else } print ''; } - print ''.$langs->trans("TF_".strtoupper($objp->type_fees_libelle)).''; + print ''.$langs->trans("TF_".strtoupper(empty($objp->type_fees_libelle)?'OTHER':$objp->type_fees_libelle)).''; print ''.$objp->comments.''; print ''.vatrate($objp->vatrate,true).''; print ''.price($objp->value_unit).''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 0a85f720c13..b8856907b84 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2015 Laurent Destailleur * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -140,6 +141,7 @@ class ExpenseReport extends CommonObject $sql.= ",paid"; $sql.= ",note_public"; $sql.= ",note_private"; + $sql.= ",entity"; $sql.= ") VALUES("; $sql.= "'(PROV)'"; $sql.= ", ".$this->total_ht; @@ -156,6 +158,7 @@ class ExpenseReport extends CommonObject $sql.= ", 0"; $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); + $sql.= ", ".$conf->entity; $sql.= ")"; dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); @@ -746,7 +749,7 @@ class ExpenseReport extends CommonObject $sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql.= ' p.ref as ref_projet, p.title as title_projet'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid'; $sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id; @@ -776,7 +779,7 @@ class ExpenseReport extends CommonObject $deplig->total_tva = $objp->total_tva; $deplig->total_ttc = $objp->total_ttc; - $deplig->type_fees_code = $objp->code_type_fees; + $deplig->type_fees_code = empty($objp->code_type_fees)?'TF_OTHER':$objp->code_type_fees; $deplig->type_fees_libelle = $objp->libelle_type_fees; $deplig->tva_tx = $objp->tva_tx; $deplig->vatrate = $objp->tva_tx; @@ -850,12 +853,9 @@ class ExpenseReport extends CommonObject { global $conf,$langs; + $this->oldref = $this->ref; $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; - // Sélection du numéro de ref suivant - $ref_next = $this->getNextNumRef(); - $ref_number_int = ($this->ref+1)-1; - // Sélection de la date de début de la NDF $sql = 'SELECT date_debut'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -864,21 +864,59 @@ class ExpenseReport extends CommonObject $objp = $this->db->fetch_object($result); $this->date_debut = $this->db->jdate($objp->date_debut); - // Création du ref_number suivant - if($ref_next) + $update_number_int = false; + + // Create next ref if ref is PROVxx + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { - $prefix="ER"; - if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; - $this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d'); + // Sélection du numéro de ref suivant + $ref_next = $this->getNextNumRef(); + $ref_number_int = ($this->ref+1)-1; + $update_number_int = true; + // Création du ref_number suivant + if($ref_next) + { + $prefix="ER"; + if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; + $this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d'); + } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // We rename directory in order to avoid losing the attachments + $oldref = dol_sanitizeFileName($this->oldref); + $newref = dol_sanitizeFileName($this->ref); + $dirsource = $conf->expensereport->dir_output.'/'.$oldref; + $dirdest = $conf->expensereport->dir_output.'/'.$newref; + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->expensereport->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } } if ($this->fk_statut != 2) { $now = dol_now(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.", date_valid='".$this->db->idate($now)."',"; - $sql.= " ref_number_int = ".$ref_number_int; + $sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.", date_valid='".$this->db->idate($now)."'"; + if ($update_number_int) { + $sql.= ", ref_number_int = ".$ref_number_int; + } $sql.= ' WHERE rowid = '.$this->id; $resql=$this->db->query($sql); @@ -1265,7 +1303,9 @@ class ExpenseReport extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.rowid = ".$projet_id; $result = $this->db->query($sql); - $objp_projet = $this->db->fetch_object($result); + if ($result) { + $objp_projet = $this->db->fetch_object($result); + } $ligne->projet_ref = $objp_projet->ref_projet; $ligne->projet_title = $objp_projet->title_projet; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index bf7357fb2e1..59c489a957a 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.0'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.2'); if (! defined('EURO')) define('EURO',chr(128)); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8617748d369..a276a4b4e87 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2015 Ferran Marcet * @@ -652,7 +652,16 @@ class FactureFournisseur extends CommonInvoice dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (!$resql) { + $error++; + + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->errors[] = $langs->trans('ErrorRefAlreadyExists'); + } else { + $this->errors[] = "Error ".$this->db->lasterror(); + } + } if (! $error) { diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index fd44b987f94..58eb540d890 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -386,6 +386,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid"; $sql.= " WHERE l.fk_commande = ".$commande->id; + if(empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND l.product_type = 0"; $sql.= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql.= " ORDER BY p.ref, p.label"; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 9801c168be3..97c2d782afb 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -238,8 +238,11 @@ if (empty($reshook)) // Set supplier ref if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); - if ($result < 0) dol_print_error($db, $object->error); + $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); + + if ($object->update($user) < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // payments conditions diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index aba66991eec..e64ced4d6b9 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -225,10 +225,19 @@ if ($search_amount_all_tax != '') $sql .= natural_search('fac.total_ttc', $search_amount_all_tax, 1); } -if ($search_status != '') +if ($search_status != '' && $search_status>=0) { $sql.= " AND fac.fk_statut = ".$search_status; } +if ($filter && $filter != -1) +{ + $aFilter = explode(',', $filter); + foreach ($aFilter as $fil) + { + $filt = explode(':', $fil); + $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); + } +} $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -266,7 +275,7 @@ if ($resql) if ($search_amount_no_tax) $param.='&search_amount_no_tax='.urlencode($search_amount_no_tax); if ($search_amount_all_tax) $param.='&search_amount_all_tax='.urlencode($search_amount_all_tax); if ($filter && $filter != -1) $param.='&filtre='.urlencode($filter); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($search_status >= 0) $param.="&search_status=".$search_status; print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->name.":""),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy'); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 4e5706f94c6..94704451df7 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2012-2014 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Juanjo Menent * * 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 @@ -117,7 +118,7 @@ class Holiday extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $langs; + global $conf; $error=0; $now=dol_now(); @@ -137,7 +138,8 @@ class Holiday extends CommonObject $sql.= "statut,"; $sql.= "fk_validator,"; $sql.= "fk_type,"; - $sql.= "fk_user_create"; + $sql.= "fk_user_create,"; + $sql.= "entity"; $sql.= ") VALUES ("; $sql.= "'".$this->fk_user."',"; $sql.= " '".$this->db->idate($now)."',"; @@ -148,7 +150,8 @@ class Holiday extends CommonObject $sql.= " '1',"; $sql.= " '".$this->fk_validator."',"; $sql.= " '".$this->fk_type."',"; - $sql.= " ".$user->id; + $sql.= " ".$user->id.","; + $sql.= " ".$conf->entity; $sql.= ")"; $this->db->begin(); diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 9d77a87fd7c..74f89441f64 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -607,3 +607,6 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (14 INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1482, 148, '7','0','VAT reduced rate',1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1483, 148, '5','0','VAT super-reduced rate', 1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1484, 148, '0','0','VAT Rate 0', 1); + +-- VMYSQL4.1 ALTER TABLE llx_c_type_resource CHANGE COLUMN rowid rowid integer NOT NULL AUTO_INCREMENT; + diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index fafe5a4ad9f..6b9ea2a16f7 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -57,7 +57,33 @@ delete from llx_adherent_extrafields where fk_object not in (select rowid from l delete from llx_product_extrafields where fk_object not in (select rowid from llx_product); --delete from llx_societe_commerciaux where fk_soc not in (select rowid from llx_societe); + +-- Clean stocks + +-- Reference for qty is llx_product_stock (detail in llx_product_batch may be not complete) +-- qty in llx_product may be not up to date update llx_product_batch set batch = '' where batch = 'Non défini'; +update llx_product_batch set batch = '' where batch = 'Non défini'; + +DELETE FROM llx_product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM llx_product_batch as pb); + +-- Merge splitted lines into one in table llx_product_batch +DROP TABLE tmp_llx_product_batch; +DROP TABLE tmp_llx_product_batch2; +CREATE TABLE tmp_llx_product_batch AS select fk_product_stock, eatby, sellby, batch, SUM(qty) as qty, COUNT(rowid) as nb FROM llx_product_batch GROUP BY fk_product_stock, eatby, sellby, batch HAVING COUNT(rowid) > 1; +CREATE TABLE tmp_llx_product_batch2 AS select pb.rowid, pb.fk_product_stock, pb.eatby, pb.sellby, pb.batch, pb.qty from llx_product_batch as pb, tmp_llx_product_batch as tpb where pb.fk_product_stock = tpb.fk_product_stock and COALESCE(pb.eatby, '') = COALESCE(tpb.eatby,'') and COALESCE(pb.sellby, '') = COALESCE(tpb.sellby, '') and pb.batch = tpb.batch; +--select * from tmp_llx_product_batch; +--select * from tmp_llx_product_batch2; +DELETE FROM llx_product_batch WHERE rowid IN (select rowid FROM tmp_llx_product_batch2); +INSERT INTO llx_product_batch(fk_product_stock, eatby, sellby, batch, qty) SELECT fk_product_stock, eatby, sellby, batch, qty FROM tmp_llx_product_batch; + +DELETE FROM llx_product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM llx_product_batch as pb); +DELETE FROM llx_product_batch WHERE qty = 0; + + +-- Stock calculation on product +UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid); + -- Fix: delete category child with no category parent. drop table tmp_categorie; @@ -112,9 +138,6 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, position) values insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 50, 'AC_OTH', 'system', 'Other' ,NULL, 5); --- Stock calculation on product -UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid); - -- VMYSQL4.1 DELETE T1 FROM llx_boxes_def as T1, llx_boxes_def as T2 where T1.entity = T2.entity AND T1.file = T2.file AND T1.note = T2.note and T1.rowid > T2.rowid; -- VPGSQL8.2 DELETE FROM llx_boxes_def as T1 WHERE rowid NOT IN (SELECT min(rowid) FROM llx_boxes_def GROUP BY file, entity, note); diff --git a/htdocs/langs/ar_SA/projects.lang b/htdocs/langs/ar_SA/projects.lang index bdd7967374a..ab322a4bd05 100644 --- a/htdocs/langs/ar_SA/projects.lang +++ b/htdocs/langs/ar_SA/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=المؤهل العلمى OppStatusPROPO=مقترح OppStatusNEGO=Negociation OppStatusPENDING=بانتظار -OppStatusWIN=فاز +OppStatusWON=فاز OppStatusLOST=ضائع Budget=Budget diff --git a/htdocs/langs/bn_BD/projects.lang b/htdocs/langs/bn_BD/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/bn_BD/projects.lang +++ b/htdocs/langs/bn_BD/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/bs_BA/projects.lang b/htdocs/langs/bs_BA/projects.lang index 0b25f6ea67a..fdfcbd408e5 100644 --- a/htdocs/langs/bs_BA/projects.lang +++ b/htdocs/langs/bs_BA/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/ca_ES/projects.lang b/htdocs/langs/ca_ES/projects.lang index 5c2f18593cb..91c1a7cc9db 100644 --- a/htdocs/langs/ca_ES/projects.lang +++ b/htdocs/langs/ca_ES/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualificació OppStatusPROPO=Pressupost OppStatusNEGO=Negociació OppStatusPENDING=Pendent -OppStatusWIN=Guanyat +OppStatusWON=Guanyat OppStatusLOST=Perdut Budget=Budget diff --git a/htdocs/langs/cs_CZ/projects.lang b/htdocs/langs/cs_CZ/projects.lang index 14b67dbb918..cdc3743aee4 100644 --- a/htdocs/langs/cs_CZ/projects.lang +++ b/htdocs/langs/cs_CZ/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/da_DK/projects.lang b/htdocs/langs/da_DK/projects.lang index 0c7ed16673b..618a6e5dc47 100644 --- a/htdocs/langs/da_DK/projects.lang +++ b/htdocs/langs/da_DK/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/de_DE/projects.lang b/htdocs/langs/de_DE/projects.lang index 15fc4080190..c1d58f6d3d6 100644 --- a/htdocs/langs/de_DE/projects.lang +++ b/htdocs/langs/de_DE/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualifikation OppStatusPROPO=Angebot OppStatusNEGO=Verhandlung OppStatusPENDING=Anstehend -OppStatusWIN=Gewonnen +OppStatusWON=Gewonnen OppStatusLOST=Verloren Budget=Budget diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 392050c6cd5..bfbe32b803e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -321,8 +321,8 @@ PaymentConditionPT_5050=50%% in advance, 50%% on delivery FixAmount=Fix amount VarAmount=Variable amount (%% tot.) # PaymentType -PaymentTypeVIR=Bank deposit -PaymentTypeShortVIR=Bank deposit +PaymentTypeVIR=Bank transfer +PaymentTypeShortVIR=Bank transfer PaymentTypePRE=Bank's order PaymentTypeShortPRE=Bank's order PaymentTypeLIQ=Cash diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 1844a22c227..500f25e4ae8 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -124,6 +124,7 @@ Int=Int DateAndTime=Date and time PublicMemberCard=Member public card MemberNotOrNoMoreExpectedToSubscribe=Member not or no more expected to subscribe +SubscriptionNotRecorded=Subscription not recorded AddSubscription=Create subscription ShowSubscription=Show subscription MemberModifiedInDolibarr=Member modified in Dolibarr diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 278fa9c77b7..329ab278329 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -157,11 +157,13 @@ StatsByNumberOfEntities=Statistics in number of referring entities NumberOfProposals=Number of proposals on last 12 month NumberOfCustomerOrders=Number of customer orders on last 12 month NumberOfCustomerInvoices=Number of customer invoices on last 12 month +NumberOfSupplierProposals=Number of supplier proposals on last 12 month NumberOfSupplierOrders=Number of supplier orders on last 12 month NumberOfSupplierInvoices=Number of supplier invoices on last 12 month NumberOfUnitsProposals=Number of units on proposals on last 12 month NumberOfUnitsCustomerOrders=Number of units on customer orders on last 12 month NumberOfUnitsCustomerInvoices=Number of units on customer invoices on last 12 month +NumberOfUnitsSupplierProposals=Number of units on supplier proposals on last 12 month NumberOfUnitsSupplierOrders=Number of units on supplier orders on last 12 month NumberOfUnitsSupplierInvoices=Number of units on supplier invoices on last 12 month EMailTextInterventionValidated=The intervention %s has been validated. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 9298bdc9669..291f04f1c7e 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -130,6 +130,7 @@ AssociatedProductsAbility=Activate the package feature AssociatedProducts=Package product AssociatedProductsNumber=Number of products composing this package product ParentProductsNumber=Number of parent packaging product +ParentProducts=Parent products IfZeroItIsNotAVirtualProduct=If 0, this product is not a package product IfZeroItIsNotUsedByVirtualProduct=If 0, this product is not used by any package product EditAssociate=Associate diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 979fd4670bb..c68bd370f5a 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -190,6 +190,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget \ No newline at end of file diff --git a/htdocs/langs/es_ES/projects.lang b/htdocs/langs/es_ES/projects.lang index b0965bd080c..3a9fd407875 100644 --- a/htdocs/langs/es_ES/projects.lang +++ b/htdocs/langs/es_ES/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Cualificación OppStatusPROPO=Presupuesto OppStatusNEGO=Negociación OppStatusPENDING=Pendiente -OppStatusWIN=Ganado +OppStatusWON=Ganado OppStatusLOST=Perdido Budget=Budget diff --git a/htdocs/langs/et_EE/projects.lang b/htdocs/langs/et_EE/projects.lang index 7c53e51f80d..31f516ada14 100644 --- a/htdocs/langs/et_EE/projects.lang +++ b/htdocs/langs/et_EE/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/eu_ES/projects.lang b/htdocs/langs/eu_ES/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/eu_ES/projects.lang +++ b/htdocs/langs/eu_ES/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/fi_FI/projects.lang b/htdocs/langs/fi_FI/projects.lang index fea93953f69..50177fda449 100644 --- a/htdocs/langs/fi_FI/projects.lang +++ b/htdocs/langs/fi_FI/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index b95fbb3cd56..6389d10abbf 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposition OppStatusNEGO=Négociation OppStatusPENDING=En attente -OppStatusWIN=Gagné +OppStatusWON=Gagné OppStatusLOST=Perdu Budget=Budget diff --git a/htdocs/langs/he_IL/projects.lang b/htdocs/langs/he_IL/projects.lang index fb939aef169..ee8785e6397 100644 --- a/htdocs/langs/he_IL/projects.lang +++ b/htdocs/langs/he_IL/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/hr_HR/projects.lang b/htdocs/langs/hr_HR/projects.lang index 7dae3662584..bd83a40224d 100644 --- a/htdocs/langs/hr_HR/projects.lang +++ b/htdocs/langs/hr_HR/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/hu_HU/projects.lang b/htdocs/langs/hu_HU/projects.lang index 9ab8ab13b05..20a6f143d2a 100644 --- a/htdocs/langs/hu_HU/projects.lang +++ b/htdocs/langs/hu_HU/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/id_ID/projects.lang b/htdocs/langs/id_ID/projects.lang index 83a284cc58c..13798a28b3c 100644 --- a/htdocs/langs/id_ID/projects.lang +++ b/htdocs/langs/id_ID/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/is_IS/projects.lang b/htdocs/langs/is_IS/projects.lang index d41a345caf3..517ab7e2e84 100644 --- a/htdocs/langs/is_IS/projects.lang +++ b/htdocs/langs/is_IS/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/it_IT/projects.lang b/htdocs/langs/it_IT/projects.lang index 9954fb68fd2..8599f5089b5 100644 --- a/htdocs/langs/it_IT/projects.lang +++ b/htdocs/langs/it_IT/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualificazione OppStatusPROPO=Proposta OppStatusNEGO=Negoziazione OppStatusPENDING=In attesa -OppStatusWIN=Vinto +OppStatusWON=Vinto OppStatusLOST=Perso Budget=Budget diff --git a/htdocs/langs/ka_GE/projects.lang b/htdocs/langs/ka_GE/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/ka_GE/projects.lang +++ b/htdocs/langs/ka_GE/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/kn_IN/projects.lang b/htdocs/langs/kn_IN/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/kn_IN/projects.lang +++ b/htdocs/langs/kn_IN/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/ko_KR/projects.lang b/htdocs/langs/ko_KR/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/ko_KR/projects.lang +++ b/htdocs/langs/ko_KR/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/lo_LA/projects.lang b/htdocs/langs/lo_LA/projects.lang index 56cc02c9e82..52ca66a2763 100644 --- a/htdocs/langs/lo_LA/projects.lang +++ b/htdocs/langs/lo_LA/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/lt_LT/projects.lang b/htdocs/langs/lt_LT/projects.lang index 6398f58b129..bc9adc0ef7f 100644 --- a/htdocs/langs/lt_LT/projects.lang +++ b/htdocs/langs/lt_LT/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/lv_LV/projects.lang b/htdocs/langs/lv_LV/projects.lang index d04ece7b84f..000139e853c 100644 --- a/htdocs/langs/lv_LV/projects.lang +++ b/htdocs/langs/lv_LV/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Kvalifikācija OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/mk_MK/projects.lang b/htdocs/langs/mk_MK/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/mk_MK/projects.lang +++ b/htdocs/langs/mk_MK/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/nb_NO/projects.lang b/htdocs/langs/nb_NO/projects.lang index c57648d77d1..c69d3c47ee4 100644 --- a/htdocs/langs/nb_NO/projects.lang +++ b/htdocs/langs/nb_NO/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Kvalifikasjon OppStatusPROPO=Tilbud OppStatusNEGO=Forhandling OppStatusPENDING=Venter -OppStatusWIN=Vunnet +OppStatusWON=Vunnet OppStatusLOST=Tapt Budget=Budget diff --git a/htdocs/langs/nl_NL/projects.lang b/htdocs/langs/nl_NL/projects.lang index 93514bd4108..8cf1a0d4684 100644 --- a/htdocs/langs/nl_NL/projects.lang +++ b/htdocs/langs/nl_NL/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/pl_PL/projects.lang b/htdocs/langs/pl_PL/projects.lang index 1479193a7cc..429a664d293 100644 --- a/htdocs/langs/pl_PL/projects.lang +++ b/htdocs/langs/pl_PL/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Kwalifikacja OppStatusPROPO=Wniosek OppStatusNEGO=Negocjacje OppStatusPENDING=W oczekiwaniu -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Zagubiony Budget=Budget diff --git a/htdocs/langs/pt_BR/projects.lang b/htdocs/langs/pt_BR/projects.lang index f8ae458330b..ab92118d1e4 100644 --- a/htdocs/langs/pt_BR/projects.lang +++ b/htdocs/langs/pt_BR/projects.lang @@ -125,5 +125,5 @@ OppStatusQUAL=Qualificação OppStatusPROPO=Proposta OppStatusNEGO=Negociação OppStatusPENDING=Pendente -OppStatusWIN=Ganhou +OppStatusWON=Ganhou OppStatusLOST=Perdido diff --git a/htdocs/langs/pt_PT/projects.lang b/htdocs/langs/pt_PT/projects.lang index c6bc715fada..2df744a5013 100644 --- a/htdocs/langs/pt_PT/projects.lang +++ b/htdocs/langs/pt_PT/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/ro_RO/projects.lang b/htdocs/langs/ro_RO/projects.lang index 301c6242d24..c6fc6cb74e0 100644 --- a/htdocs/langs/ro_RO/projects.lang +++ b/htdocs/langs/ro_RO/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Calificare OppStatusPROPO=Ofertă OppStatusNEGO=Negociere OppStatusPENDING=In asteptarea -OppStatusWIN=Castigat +OppStatusWON=Castigat OppStatusLOST=Pierdut Budget=Budget diff --git a/htdocs/langs/ru_RU/projects.lang b/htdocs/langs/ru_RU/projects.lang index 27c4995d20d..bdee2d2d019 100644 --- a/htdocs/langs/ru_RU/projects.lang +++ b/htdocs/langs/ru_RU/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/sk_SK/projects.lang b/htdocs/langs/sk_SK/projects.lang index 6453fec2772..579d69f1323 100644 --- a/htdocs/langs/sk_SK/projects.lang +++ b/htdocs/langs/sk_SK/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/sl_SI/projects.lang b/htdocs/langs/sl_SI/projects.lang index 81c1c01c46d..38c773a95bb 100644 --- a/htdocs/langs/sl_SI/projects.lang +++ b/htdocs/langs/sl_SI/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/sq_AL/projects.lang b/htdocs/langs/sq_AL/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/sq_AL/projects.lang +++ b/htdocs/langs/sq_AL/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/sr_RS/projects.lang b/htdocs/langs/sr_RS/projects.lang index 8ba6046454e..553b7ec80af 100644 --- a/htdocs/langs/sr_RS/projects.lang +++ b/htdocs/langs/sr_RS/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Kvalifikacija OppStatusPROPO=Ponuda OppStatusNEGO=Pregovaranje OppStatusPENDING=Na čekanju -OppStatusWIN=Dobijeno +OppStatusWON=Dobijeno OppStatusLOST=Izgubljeno Budget=Budget diff --git a/htdocs/langs/sv_SE/projects.lang b/htdocs/langs/sv_SE/projects.lang index 77be1874eb2..a75da531dd3 100644 --- a/htdocs/langs/sv_SE/projects.lang +++ b/htdocs/langs/sv_SE/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/sw_SW/projects.lang b/htdocs/langs/sw_SW/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/sw_SW/projects.lang +++ b/htdocs/langs/sw_SW/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/tr_TR/projects.lang b/htdocs/langs/tr_TR/projects.lang index dbdfcadfce7..b4a54871c5a 100644 --- a/htdocs/langs/tr_TR/projects.lang +++ b/htdocs/langs/tr_TR/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Nitelendirme OppStatusPROPO=Teklif OppStatusNEGO=Pazarlık OppStatusPENDING=Beklemede -OppStatusWIN=Kazanç +OppStatusWON=Kazanç OppStatusLOST=Kayıp Budget=Budget diff --git a/htdocs/langs/uk_UA/projects.lang b/htdocs/langs/uk_UA/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/uk_UA/projects.lang +++ b/htdocs/langs/uk_UA/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/uz_UZ/projects.lang b/htdocs/langs/uz_UZ/projects.lang index b4a21befd80..982ec36b26b 100644 --- a/htdocs/langs/uz_UZ/projects.lang +++ b/htdocs/langs/uz_UZ/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/vi_VN/projects.lang b/htdocs/langs/vi_VN/projects.lang index 174b4a88dc1..7af08a9a5bc 100644 --- a/htdocs/langs/vi_VN/projects.lang +++ b/htdocs/langs/vi_VN/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/zh_CN/projects.lang b/htdocs/langs/zh_CN/projects.lang index bbd8b5cf27d..070c15647e6 100644 --- a/htdocs/langs/zh_CN/projects.lang +++ b/htdocs/langs/zh_CN/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/langs/zh_TW/projects.lang b/htdocs/langs/zh_TW/projects.lang index 2599ab48413..2519f38c954 100644 --- a/htdocs/langs/zh_TW/projects.lang +++ b/htdocs/langs/zh_TW/projects.lang @@ -199,6 +199,6 @@ OppStatusQUAL=Qualification OppStatusPROPO=Proposal OppStatusNEGO=Negociation OppStatusPENDING=Pending -OppStatusWIN=Won +OppStatusWON=Won OppStatusLOST=Lost Budget=Budget diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 41dcd6285c5..7b3d7a71db6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -516,7 +516,7 @@ if (! defined('NOLOGIN')) exit; } - $resultFetchUser=$user->fetch('', $login, '', 0, ($entitytotest ? $entitytotest : -1)); + $resultFetchUser=$user->fetch('', $login, '', 1, ($entitytotest ? $entitytotest : -1)); if ($resultFetchUser <= 0) { dol_syslog('User not found, connexion refused'); diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index ecfe319828a..7dd0168c77a 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -227,7 +227,7 @@ if (! isset($_SESSION['mois'])) $_SESSION['mois']= date('n'); if (! isset($_SESSION['annee'])) $_SESSION['annee']= date('Y'); //mise a jour des valeurs de session si bouton retour a aujourd'hui -if ((!issetAndNoEmpty('choixjourajout')) && !issetAndNoEmpty('choixjourretrait') || issetAndNoEmpty('retourmois')){ +if (!issetAndNoEmpty('choixjourajout') && !issetAndNoEmpty('choixjourretrait') && (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))) { $_SESSION["jour"]=date("j"); $_SESSION["mois"]=date("n"); $_SESSION["annee"]=date("Y"); diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c17fdb65aea..05efcc24a0e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -183,7 +183,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) if (empty($mode) || $mode == 1) { $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); } $db->close(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1939299cf63..ba2eac00cd9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -666,25 +666,45 @@ class Product extends CommonObject $org->fetch($this->id); $this->oldcopy=$org; } - // test if batch management is activated on existing product + + // Test if batch management is activated on existing product + // If yes, we create missing entries into product_batch if ($this->hasbatch() && !$this->oldcopy->hasbatch()) { + $valueforundefinedlot = 'Undefined'; + + dol_syslog("Flag batch of product id=".$this->id." is set to ON, so we will create missing records into product_batch"); + $this->load_stock(); - foreach ($this->stock_warehouse as $idW => $ObjW) + foreach ($this->stock_warehouse as $idW => $ObjW) // For each warehouse where we have stocks defined for this product (for each lines in product_stock) { $qty_batch = 0; - foreach ($ObjW->detail_batch as $detail) + foreach ($ObjW->detail_batch as $detail) // Each lines of detail in product_batch of the current $ObjW = product_stock { + if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') + { + // We discard this line, we will create it later + $sqlclean="DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; + $result = $this->db->query($sqlclean); + if (! $result) + { + dol_print_error($this->db); + exit; + } + continue; + } + $qty_batch += $detail->qty; } - // Quantities in batch details are not same same as stock quantity - // So we add a default batch record + // Quantities in batch details are not same as stock quantity, + // so we add a default batch record to complete and get same qty in parent and child table if ($ObjW->real <> $qty_batch) { $ObjBatch = new Productbatch($this->db); - $ObjBatch->batch = $langs->trans('BatchDefaultNumber'); - $ObjBatch->qty = $ObjW->real - $qty_batch; + $ObjBatch->batch = $valueforundefinedlot; + $ObjBatch->qty = ($ObjW->real - $qty_batch); $ObjBatch->fk_product_stock = $ObjW->id; + if ($ObjBatch->create($user,1) < 0) { $error++; @@ -693,6 +713,7 @@ class Product extends CommonObject } } } + // For automatic creation if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); @@ -2259,6 +2280,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture', 1).")"; @@ -2291,6 +2313,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture_fourn"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")"; @@ -2323,6 +2346,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = d.fk_propal"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; @@ -2334,6 +2358,38 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode); } + /** + * Return nb of units or proposals in which product is included + * + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + */ + function get_nb_propalsupplier($socid, $mode, $filteronproducttype=-1) + { + global $conf; + global $user; + + $sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')"; + if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; + $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.rowid = d.fk_supplier_proposal"; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + else $sql.=" AND d.fk_product > 0"; + if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; + $sql.= " AND p.fk_soc = s.rowid"; + $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; + $sql.= " GROUP BY date_format(p.date_valid,'%Y%m')"; + $sql.= " ORDER BY date_format(p.date_valid,'%Y%m') DESC"; + + return $this->_get_stats($sql,$mode); + } + /** * Return nb of units or orders in which product is included * @@ -2353,6 +2409,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; @@ -2383,6 +2440,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")"; @@ -2948,9 +3006,9 @@ class Product extends CommonObject /** * Return all direct parent products fo current product - * + * * @return array prod - * @see getFather + * @deprecated See getFather */ function getParent() { @@ -2982,9 +3040,10 @@ class Product extends CommonObject * * @param int $id Id of product to search childs of * @param int $firstlevelonly Return only direct child + * @param int $level Level of recursing call (start to 1) * @return array Prod */ - function getChildsArbo($id, $firstlevelonly=0) + function getChildsArbo($id, $firstlevelonly=0, $level=1) { $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; @@ -2993,13 +3052,18 @@ class Product extends CommonObject $sql.= " AND pa.fk_product_pere = ".$id; $sql.= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens - dol_syslog(get_class($this).'::getChildsArbo', LOG_DEBUG); + dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); + + // Protection against infinite loop + if ($level > 30) return array(); + $res = $this->db->query($sql); if ($res) { $prods = array(); while ($rec = $this->db->fetch_array($res)) { + // TODO Add check to not add ne record if already added $prods[$rec['rowid']]= array( 0=>$rec['id'], 1=>$rec['qty'], @@ -3011,7 +3075,7 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - $listofchilds=$this->getChildsArbo($rec['id']); + $listofchilds=$this->getChildsArbo($rec['id'], 0, $level + 1); foreach($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; @@ -3036,10 +3100,12 @@ class Product extends CommonObject */ function get_sousproduits_arbo() { - $parent = $this->getParent(); + //$parent = $this->getParent(); + $parent[$this->label]=array(0 => $this->id); + foreach($parent as $key => $value) // key=label, value[0]=id { - foreach($this->getChildsArbo($value[0]) as $keyChild => $valueChild) + foreach($this->getChildsArbo($value[0]) as $keyChild => $valueChild) // Warning. getChildsArbo can gell getChildsArbo recursively. { $parent[$key][$keyChild] = $valueChild; } @@ -3687,7 +3753,7 @@ class Product extends CommonObject } } - if ($size==1 || $size='small') + if ($size==1 || $size=='small') { if ($nbbyrow > 0) { diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index f4b3f575eba..ee99226f2e4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -265,7 +265,7 @@ if ($id > 0 || ! empty($ref)) print load_fiche_titre($langs->trans("ProductParentList"),'','').'
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 44871a70bcd..f094826ef82 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -235,7 +235,8 @@ if ($object->id) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - $filearray = dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); + + $filearray = array_merge($filearray,dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1)); } // For each file build select list with PDF extention diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 49b700b46ca..d98d8ed31c6 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -210,15 +210,20 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') 'propal' =>array('modulepart'=>'productstats_proposals', 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))), + 'proposalssuppliers'=>array('modulepart'=>'productstats_proposalssuppliers', + 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', + 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals"):$langs->transnoentitiesnoconv("NumberOfSupplierProposals"))), + 'orders' =>array('modulepart'=>'productstats_orders', 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))), - 'invoices' =>array('modulepart'=>'productstats_invoices', - 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))), 'orderssuppliers'=>array('modulepart'=>'productstats_orderssuppliers', 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))), + + 'invoices' =>array('modulepart'=>'productstats_invoices', + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', + 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))), 'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))), @@ -243,11 +248,12 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') } else { - if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode,((string) $type != '' ? $type : -1)); - if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode,((string) $type != '' ? $type : -1)); - if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode,((string) $type != '' ? $type : -1)); - if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode,((string) $type != '' ? $type : -1)); - if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'proposalssuppliers') $graph_data = $object->get_nb_propalsupplier($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode,((string) $type != '' ? $type : -1)); // TODO Save cachefile $graphfiles[$key]['file'] } @@ -289,6 +295,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue; if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue; if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue; + if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue; if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue; if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 42fadf54923..e6477fadf69 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -185,7 +185,7 @@ if ($action == "correct_stock" && ! $cancel) // Transfer stock from a warehouse to another warehouse if ($action == "transfert_stock" && ! $cancel) { - if (! (GETPOST("id_entrepot_source",'int') > 0) || ! (GETPOST("id_entrepot_destination",'int') > 0)) + if (! (GETPOST("id_entrepot",'int') > 0) || ! (GETPOST("id_entrepot_destination",'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; @@ -197,7 +197,7 @@ if ($action == "transfert_stock" && ! $cancel) $error++; $action='transfert'; } - if (GETPOST("id_entrepot_source",'int') == GETPOST("id_entrepot_destination",'int')) + if (GETPOST("id_entrepot",'int') == GETPOST("id_entrepot_destination",'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; @@ -255,7 +255,7 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=GETPOST('id_entrepot_source','int'); + $srcwarehouseid=GETPOST('id_entrepot','int'); $batch=GETPOST('batch_number'); $eatby=$d_eatby; $sellby=$d_sellby; @@ -292,7 +292,7 @@ if ($action == "transfert_stock" && ! $cancel) // Remove stock $result1=$object->correct_stock( $user, - GETPOST("id_entrepot_source"), + GETPOST("id_entrepot"), GETPOST("nbpiece"), 1, GETPOST("label"), @@ -391,6 +391,7 @@ if ($id > 0 || $ref) { $object = new Product($db); $result = $object->fetch($id,$ref); + $object->load_stock(); $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; @@ -677,7 +678,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) print ''; } -$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.pmp, ps.rowid as product_stock_id"; +$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; @@ -703,9 +704,10 @@ if ($resql) $entrepotstatic->id=$obj->rowid; $entrepotstatic->libelle=$obj->label; $entrepotstatic->lieu=$obj->lieu; + $stock_real = round($obj->reel, 10); print ''; print ''; - print ''; + print ''; // PMP print ''; // Value purchase diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 4128de6fead..18119b0cf17 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -96,7 +96,7 @@ class FormResource } // Construct $out and $outarray - $out.= ''."\n"; if ($showempty) $out.= ''."\n"; $num = count($resourcestat->lines); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2f73685fcb3..0e7e375ac2f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -975,7 +975,7 @@ class Societe extends CommonObject global $langs; global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4)) return -1; $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; $sql .= ', s.status'; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0314ce7b928..f474c4463d8 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -103,7 +103,7 @@ $useboldtitle=1; if (! isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY=$colorbackbody; if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1='120,130,170'; if (! isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1=$colorbacktitle1; -if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER=='238,246,252'; +if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER='238,246,252'; if (! isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB=$colortexttitlenotab; if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK=$colortextlink; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 85f340b1cb1..1ee07e0a7af 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -207,7 +207,10 @@ class User extends CommonObject } else // The fetch was forced on an entity { - $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; + if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) + $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database + else + $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; } if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 6f5e79b9d60..716db97b911 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -64,6 +64,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$hookmanager->initHooks(array('groupcard','globalcard')); /** * Action remove group diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 2e3314fff12..43facbb24fa 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -374,7 +374,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $product->load_stock(); $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos/"; + $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/"; $dir = $dir . '/'. $pdir; if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"];
'.$langs->trans('ParentProduct').''.$langs->trans('ParentProducts').''.$langs->trans('Label').''.$langs->trans('Qty').'
'.$entrepotstatic->getNomUrl(1).''.$obj->reel.($obj->reel<0?' '.img_warning():'').''.$stock_real.($stock_real < 0 ?' '.img_warning():'').''.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'