Merge remote-tracking branch 'upstream/3.9' into 3.9

Conflicts:
	htdocs/compta/localtax/quadri_detail.php
This commit is contained in:
Juanjo Menent 2016-05-26 10:46:44 +02:00
commit 071a230000
99 changed files with 532 additions and 618 deletions

View File

@ -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

View File

@ -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=<STDIN>;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -202,10 +202,9 @@ print "<td>" . $langs->trans("Selectchartofaccounts") . "</td>";
print "<td>";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT rowid, pcg_version, fk_pays, label, active";
$sql = "SELECT rowid, pcg_version, label, active";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
$sql .= " WHERE active = 1";
$sql .= " AND fk_pays = " . $mysoc->country_id;
dol_syslog('accountancy/admin/index.php:: $sql=' . $sql);
$resql = $db->query($sql);
@ -221,7 +220,7 @@ if ($resql) {
print '<option value="' . $row[0] . '"';
print $conf->global->CHARTOFACCOUNTS == $row[0] ? ' selected' : '';
print '>' . $row[1] . ' - ' . $row[3] . '</option>';
print '>' . $row[1] . ' - ' . $row[2] . '</option>';
$i ++;
}

View File

@ -1381,17 +1381,12 @@ else
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
}
/*
* Confirm add in spip
*/
// Confirm add in spip
if ($action == 'add_spip')
{
print $form->formconfirm("card.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
}
/*
* Confirm removed from spip
*/
// Confirm removed from spip
if ($action == 'del_spip')
{
print $form->formconfirm("card.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
@ -1556,8 +1551,16 @@ else
}
else
{
print $langs->trans("SubscriptionNotReceived");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
if (! $adht->cotisation)
{
print $langs->trans("SubscriptionNotRecorded");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
}
else
{
print $langs->trans("SubscriptionNotReceived");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
}
}
print '</td></tr>';

View File

@ -722,8 +722,16 @@ if ($rowid > 0)
}
else
{
print $langs->trans("SubscriptionNotReceived");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
if (! $adht->cotisation)
{
print $langs->trans("SubscriptionNotRecorded");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
}
else
{
print $langs->trans("SubscriptionNotReceived");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
}
}
print '</td></tr>';

View File

@ -223,7 +223,7 @@ asort($orders);
//var_dump($modules);
$nbofactivatedmodules=count($conf->modules);
$moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1));
$moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1), count($modules));
if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup');

View File

@ -62,7 +62,7 @@ if (GETPOST('submitproduct') && GETPOST('submitproduct'))
{
$producttmp->fetch(GETPOST('productid'));
$forbarcode=$producttmp->barcode;
$fk_barcode_type=$thirdpartytmp->barcode_type_code;
$fk_barcode_type=$producttmp->barcode_type;
if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;

View File

@ -1173,7 +1173,7 @@ if ($id > 0)
// Clone event
if($action == 'clone')
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneAction', $object->label), 'confirm_clone', $formquestion, 'yes', 1);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', $formquestion, 'yes', 1);
print $formconfirm;
}

View File

@ -562,15 +562,6 @@ if (empty($reshook))
}
}
// Reopen proposal
else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
{
// prevent browser refresh from reopening proposal several times
if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) {
$object->reopen($user, 1);
}
}
// Close proposal
else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
{
@ -591,17 +582,6 @@ if (empty($reshook))
}
}
// Classify billed
else if ($action == 'classifybilled' && $user->rights->propal->cloturer)
{
$result=$object->cloture($user, 4, '');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
// Reopen proposal
else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
{
@ -617,20 +597,6 @@ if (empty($reshook))
}
}
// Close proposal
else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
{
if (! GETPOST('statut')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
if ($object->statut == Propal::STATUS_VALIDATED) {
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
}
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';

View File

@ -9,6 +9,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -985,6 +986,7 @@ class Commande extends CommonOrder
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date = dol_now();
$this->date_commande = dol_now();
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
@ -1253,7 +1255,7 @@ class Commande extends CommonOrder
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -1386,7 +1388,7 @@ class Commande extends CommonOrder
if (empty($tva_tx)) $tva_npr=0;
$localtax1_tx=get_localtax($tva_tx,1,$this->client,$mysoc,$tva_npr);
$localtax2_tx=get_localtax($tva_tx,2,$this->client,$mysoc,$tva_npr);
// multiprix
if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level)
$price = $prod->multiprices[$this->client->price_level];
@ -2447,7 +2449,7 @@ class Commande extends CommonOrder
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
{
global $conf, $mysoc;
global $conf, $mysoc, $langs;
dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -2481,7 +2483,7 @@ class Commande extends CommonOrder
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -2503,6 +2505,26 @@ class Commande extends CommonOrder
$line = new OrderLine($this->db);
$line->fetch($rowid);
if (!empty($line->fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($line->fk_product);
$product_type=$product->type;
if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
{
$this->error=$langs->trans('ErrorStockIsNotEnough');
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
$this->db->rollback();
unset($_POST['productid']);
unset($_POST['tva_tx']);
unset($_POST['price_ht']);
unset($_POST['qty']);
unset($_POST['buying_price']);
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
}
}
$staticline = clone $line;
$line->oldline = $staticline;
@ -2918,7 +2940,7 @@ class Commande extends CommonOrder
function LibStatut($statut,$billed,$mode,$donotshowbilled=0)
{
global $langs, $conf;
$billedtext = '';
if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):'');

View File

@ -429,15 +429,15 @@ if ($resql)
// Show shippable Icon (create subloop, so may be slow)
if ($conf->stock->enabled)
{
$notshippable=0;
$warning = 0;
$text_info='';
$text_warning='';
$nbprod=0;
$langs->load("stocks");
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3))
{
$notshippable=0;
$warning = 0;
$text_info='';
$text_warning='';
$nbprod=0;
$numlines = count($generic_commande->lines); // Loop on each line of order
for ($lig=0; $lig < $numlines; $lig++)
{

View File

@ -7,6 +7,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -986,6 +987,7 @@ class Account extends CommonObject
$sql = "SELECT COUNT(ba.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE ba.rappro > 0 and ba.clos = 0";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2";
$resql=$db->query($sql);
if ($resql)

View File

@ -14,6 +14,7 @@
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -2335,6 +2336,19 @@ class Facture extends CommonInvoice
$line = new FactureLigne($this->db);
$line->fetch($rowid);
if (!empty($line->fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($line->fk_product);
$product_type=$product->type;
if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) {
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
return -3;
}
}
$staticline = clone $line;
$line->oldline = $staticline;
@ -2362,7 +2376,7 @@ class Facture extends CommonInvoice
$this->line->date_start = $date_start;
$this->line->date_end = $date_end;
$this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
$this->line->total_tva = $total_tva;
$this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva);
$this->line->total_localtax1 = $total_localtax1;
$this->line->total_localtax2 = $total_localtax2;
$this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);

View File

@ -196,8 +196,8 @@ $total = 0;
$i=0;
// Load arrays of datas
$x_coll= local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell', $local);
$x_paye = local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy', $local);
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
echo '<table class="noborder" width="100%">';
@ -637,6 +637,5 @@ else
$i++;
}
$db->close();
llxFooter();
$db->close();

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -298,7 +298,7 @@ if ($id > 0)
$num = $db->num_rows($result);
$i = 0;
$urladd = "&amp;id=".$prev_id;
$urladd = "&amp;id=".$id;
print_barre_liste("", $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num);
print"\n<!-- debut table -->\n";

View File

@ -177,6 +177,8 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl
// SQL request
$catotal=0;
$catotal_ht=0;
$qtytotal=0;
if ($modecompta == 'CREANCES-DETTES')
{
@ -386,6 +388,8 @@ if ($modecompta == 'CREANCES-DETTES')
// Total
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print '<td align="right">'.price($qtytotal).'</td>';
print '<td>&nbsp;</td>';
print '<td align="right">'.price($catotal_ht).'</td>';
print '<td align="right">'.price($catotal).'</td>';
print '<td>&nbsp;</td>';

View File

@ -326,8 +326,7 @@ if (empty($reshook))
$label = $lines[$i]->product_label;
}
if ($conf->global->PRODUIT_DESC_IN_FORM)
$desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):'';
$desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):'';
}
else {
$desc = dol_htmlentitiesbr($lines[$i]->desc);
@ -358,7 +357,6 @@ if (empty($reshook))
$error++;
break;
}
}
}
}

View File

@ -4246,7 +4246,7 @@ abstract class CommonObject
$productFournisseur = new ProductFournisseur($this->db);
if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0)
{
$buyPrice = $productFournisseur->fourn_price;
$buyPrice = $productFournisseur->fourn_unitprice;
}
else if ($result < 0)
{

View File

@ -2351,10 +2351,10 @@ class Form
$form.= $opt;
$i++;
}
$form.= '</select>';
$this->db->free($result);
}
$form.= '</select>';
$this->db->free($result);
return $form;
}
else

View File

@ -805,6 +805,7 @@ class FormOther
$select_week .= '<option value="'.$key.'">';
}
$select_week .= $val;
$select_week .= '</option>';
}
$select_week .= '</select>';
return $select_week;
@ -844,6 +845,7 @@ class FormOther
$select_month .= '<option value="'.$key.'">';
}
$select_month .= $val;
$select_month .= '</option>';
}
$select_month .= '</select>';
return $select_month;

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
@ -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

View File

@ -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__);

View File

@ -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))

View File

@ -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&amp;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&amp;leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);

View File

@ -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'):''));

View File

@ -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');

View File

@ -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)."<br />";
}
print "<div class=\"error\" style=\"font-size:15px;background-color:#FFB3B3;\">";
print $langs->trans("LINE_NOT_ADDED")."<br />";
print $mesg;
print "</div>";
}
else
{
if ($mesg) print "<div class=\"error\" style=\"font-size:16px;background-color:red;\">".$mesg."</div>";
}
}
// 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 '</td>';
}
print '<td style="text-align:center;">'.$langs->trans("TF_".strtoupper($objp->type_fees_libelle)).'</td>';
print '<td style="text-align:center;">'.$langs->trans("TF_".strtoupper(empty($objp->type_fees_libelle)?'OTHER':$objp->type_fees_libelle)).'</td>';
print '<td style="text-align:left;">'.$objp->comments.'</td>';
print '<td style="text-align:right;">'.vatrate($objp->vatrate,true).'</td>';
print '<td style="text-align:right;">'.price($objp->value_unit).'</td>';

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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;

View File

@ -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));

View File

@ -7,7 +7,7 @@
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
*
@ -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)
{

View File

@ -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";

View File

@ -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

View File

@ -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');

View File

@ -3,6 +3,7 @@
* Copyright (C) 2012-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2016 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
*
* 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();

View File

@ -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;

View File

@ -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&eacute;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);

View File

@ -199,6 +199,6 @@ OppStatusQUAL=المؤهل العلمى
OppStatusPROPO=مقترح
OppStatusNEGO=Negociation
OppStatusPENDING=بانتظار
OppStatusWIN=فاز
OppStatusWON=فاز
OppStatusLOST=ضائع
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualificació
OppStatusPROPO=Pressupost
OppStatusNEGO=Negociació
OppStatusPENDING=Pendent
OppStatusWIN=Guanyat
OppStatusWON=Guanyat
OppStatusLOST=Perdut
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualifikation
OppStatusPROPO=Angebot
OppStatusNEGO=Verhandlung
OppStatusPENDING=Anstehend
OppStatusWIN=Gewonnen
OppStatusWON=Gewonnen
OppStatusLOST=Verloren
Budget=Budget

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -190,6 +190,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Cualificación
OppStatusPROPO=Presupuesto
OppStatusNEGO=Negociación
OppStatusPENDING=Pendiente
OppStatusWIN=Ganado
OppStatusWON=Ganado
OppStatusLOST=Perdido
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposition
OppStatusNEGO=Négociation
OppStatusPENDING=En attente
OppStatusWIN=Gagné
OppStatusWON=Gagné
OppStatusLOST=Perdu
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualificazione
OppStatusPROPO=Proposta
OppStatusNEGO=Negoziazione
OppStatusPENDING=In attesa
OppStatusWIN=Vinto
OppStatusWON=Vinto
OppStatusLOST=Perso
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Kvalifikācija
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Kvalifikasjon
OppStatusPROPO=Tilbud
OppStatusNEGO=Forhandling
OppStatusPENDING=Venter
OppStatusWIN=Vunnet
OppStatusWON=Vunnet
OppStatusLOST=Tapt
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Kwalifikacja
OppStatusPROPO=Wniosek
OppStatusNEGO=Negocjacje
OppStatusPENDING=W oczekiwaniu
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Zagubiony
Budget=Budget

View File

@ -125,5 +125,5 @@ OppStatusQUAL=Qualificação
OppStatusPROPO=Proposta
OppStatusNEGO=Negociação
OppStatusPENDING=Pendente
OppStatusWIN=Ganhou
OppStatusWON=Ganhou
OppStatusLOST=Perdido

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Calificare
OppStatusPROPO=Ofertă
OppStatusNEGO=Negociere
OppStatusPENDING=In asteptarea
OppStatusWIN=Castigat
OppStatusWON=Castigat
OppStatusLOST=Pierdut
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Kvalifikacija
OppStatusPROPO=Ponuda
OppStatusNEGO=Pregovaranje
OppStatusPENDING=Na čekanju
OppStatusWIN=Dobijeno
OppStatusWON=Dobijeno
OppStatusLOST=Izgubljeno
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Nitelendirme
OppStatusPROPO=Teklif
OppStatusNEGO=Pazarlık
OppStatusPENDING=Beklemede
OppStatusWIN=Kazanç
OppStatusWON=Kazanç
OppStatusLOST=Kayıp
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -199,6 +199,6 @@ OppStatusQUAL=Qualification
OppStatusPROPO=Proposal
OppStatusNEGO=Negociation
OppStatusPENDING=Pending
OppStatusWIN=Won
OppStatusWON=Won
OppStatusLOST=Lost
Budget=Budget

View File

@ -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');

View File

@ -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");

View File

@ -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();

View File

@ -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)
{

View File

@ -265,7 +265,7 @@ if ($id > 0 || ! empty($ref))
print load_fiche_titre($langs->trans("ProductParentList"),'','').'<br>';
print '<table class="centpercent noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('ParentProduct').'</td>';
print '<td>'.$langs->trans('ParentProducts').'</td>';
print '<td>'.$langs->trans('Label').'</td>';
print '<td>'.$langs->trans('Qty').'</td>';
print '</td>';

View File

@ -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

View File

@ -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;

View File

@ -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&oacute;dulo_Stocks';
@ -677,7 +678,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
print '</tr>';
}
$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 '<tr '.$bc[$var].'>';
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>';
print '<td align="right">'.$stock_real.($stock_real < 0 ?' '.img_warning():'').'</td>';
// PMP
print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>';
// Value purchase

View File

@ -96,7 +96,7 @@ class FormResource
}
// Construct $out and $outarray
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'."\n";
$out.= '<select id="'.$htmlname.'" class="flat minwidth200" name="'.$htmlname.'">'."\n";
if ($showempty) $out.= '<option value="-1"></option>'."\n";
$num = count($resourcestat->lines);

View File

@ -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';

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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"];