Merge remote-tracking branch 'origin/3.6' into develop

Conflicts:
	.travis.yml
	ChangeLog
	htdocs/fourn/commande/fiche.php
	htdocs/install/mysql/migration/3.5.0-3.6.0.sql
	htdocs/product/stock/replenish.php
This commit is contained in:
Laurent Destailleur 2014-07-04 14:14:40 +02:00
commit e496823778
23 changed files with 576 additions and 519 deletions

View File

@ -99,9 +99,9 @@ script:
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/AllTests.php
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/BuildDocTest.php
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/WebservicesOtherTest.php
# - phpcs --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ htdocs/core/class/dolgraph.class.php
- phpcs --warning-severity=0 -s -p --extensions=php --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
# - phpcs --warning-severity=0 -s --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
# - phpcs -p --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ htdocs/core/class/dolgraph.class.php
- phpcs -p --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
# - phpcs -p --warning-severity=0 -s --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
- phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php
after_script:

View File

@ -97,6 +97,8 @@ For users:
- Fix: [ bug #1478 ] BILL_PAYED trigger action does not intercept failure under some circumstances
- Fix: [ bug #1479 ] Several customer invoice triggers do not intercept trigger action
- Fix: [ bug #1477 ] Several customer invoice triggers do not show trigger error messages
- Fix: [ bug #1471 ] Several PHP warnings when intercepting USER_CREATE trigger.
- Fix: [ bug #1517 ] Packages sizes.
For translators:
- Update language files.
@ -138,6 +140,7 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
***** ChangeLog for 3.5.4 compared to 3.5.3 *****
Fix: Hide title of event when agenda module disabled.
Fix: When using option MAIN_MAIL_ALLOW_SENDMAIL_F, a mail was sent to sender.
Fix: Question about warehouse must not be done when module stock is disabled.
Fix: Option STOCK_SUPPORTS_SERVICES was not correctly implemented

View File

@ -178,13 +178,20 @@ $var=!$var;
print '<tr '.$bc[$var].'><td width="300">&nbsp; => dol_get_first_day(1970,1,false)</td><td>'.dol_get_first_day(1970,1,false).' &nbsp; &nbsp; (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,false),'dayhour').')</td>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="300">&nbsp; => dol_get_first_day(1970,1,true)</td><td>'.dol_get_first_day(1970,1,true).' &nbsp; &nbsp; (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,true),'dayhour').')</td>';
// Parent company
/*
$var=!$var;
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CompanyTZ").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
$var=!$var;
print '<tr '.$bc[$var].'><td width="300">&nbsp; => '.$langs->trans("CompanyHour").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
*/
// Database timezone
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
{
$var=!$var;
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("MySQLTimeZone").' (database)</td><td>'; // Timezone server base
$sql="SHOW VARIABLES where variable_name = 'system_time_zone'";
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
print $form->textwithtooltip($obj->Value,$langs->trans('TZHasNoEffect'),2,1,img_info(''));
}
print '</td></tr>'."\n";
}
// Client
$var=!$var;
$tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst'];
@ -372,4 +379,4 @@ print '</table>';
llxFooter();
$db->close();
?>
?>

View File

@ -1071,11 +1071,14 @@ else
print "</div><br>";
print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'','');
if (! empty($conf->agenda->enabled))
{
print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'','');
print show_actions_todo($conf,$langs,$db,$objsoc,$object);
print show_actions_todo($conf,$langs,$db,$objsoc,$object);
print show_actions_done($conf,$langs,$db,$objsoc,$object);
print show_actions_done($conf,$langs,$db,$objsoc,$object);
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
// Copyright (C) 2011-2014 Laurent Destailleur <eldy@users.sourceforge.net>
// Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
//
// This program is free software; you can redistribute it and/or modify
@ -18,7 +18,8 @@
//
// \file htdocs/core/js/dst.js
// \brief File that include javascript functions for detect user tz, dst_observed, dst_first, dst_second
// \brief File that include javascript functions for detect user tz, tz_string, dst_observed, dst_first, dst_second,
// screenwidth and screenheight
//
$(document).ready(function () {
@ -39,22 +40,22 @@ $(document).ready(function () {
dst = "1"; // daylight savings time is observed
}
var now=new Date();
var tz=now.toTimeString().match(/\(.*\)/);
var tz=now.toTimeString().match(/\(.*\)/); // now.toTimeString may return "12:39:59 GMT+0200 (CEST)"
//alert('date=' + now + ' string=' + now.toTimeString());
var dst_first=DisplayDstSwitchDates('first');
var dst_second=DisplayDstSwitchDates('second');
//alert(dst);
$('#tz').val(std_time_offset); // returns TZ
// tz is null with IE
$('#tz').val(std_time_offset); // returns TZ
// tz is null with IE
if (tz != null) {
$('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string
}
$('#dst_observed').val(dst); // returns if DST is observed on summer
$('#dst_first').val(dst_first); // returns DST first switch in year
$('#dst_second').val(dst_second); // returns DST second switch in year
$('#dst_observed').val(dst); // returns if DST is observed on summer
$('#dst_first').val(dst_first); // returns DST first switch in year
$('#dst_second').val(dst_second); // returns DST second switch in year
// Detect and save screen resolution
$('#screenwidth').val($(window).width()); // returns width of browser viewport
$('#screenheight').val($(window).height()); // returns width of browser viewport
$('#screenwidth').val($(window).width()); // returns width of browser viewport
$('#screenheight').val($(window).height()); // returns width of browser viewport
});
function DisplayDstSwitchDates(firstsecond)

View File

@ -886,7 +886,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg)
|| preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg))
{
// This part of code should not be used.
// This part of code should not be used. TODO Remove this.
dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING);
// Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS'
$syear = (! empty($reg[1]) ? $reg[1] : '');
@ -904,7 +904,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
// Date is a timestamps
if ($time < 100000000000) // Protection against bad date values
{
$ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt);
$ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); // TODO Remove this
}
else $ret='Bad value '.$time.' for date';
}
@ -912,7 +912,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
if (preg_match('/__b__/i',$format))
{
// Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs.
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst);
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Remove this
if ($encodetooutput)
{
$monthtext=$outputlangs->transnoentities('Month'.$month);
@ -931,7 +931,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
}
if (preg_match('/__a__/i',$format))
{
$w=adodb_strftime('%w',$time+$offsettz+$offsetdst);
$w=adodb_strftime('%w',$time+$offsettz+$offsetdst); // TODO Remove this
$dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w);
$ret=str_replace('__A__',$dayweek,$ret);
$ret=str_replace('__a__',dol_substr($dayweek,0,3),$ret);
@ -1037,8 +1037,16 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
}
else if ($gm === 'user')
{
$default_timezone=(empty($_SESSION["dol_tz_string"])?'UTC':$_SESSION["dol_tz_string"]);
$localtz = new DateTimeZone($default_timezone);
// We use dol_tz_string first because it contains dst.
$default_timezone=(empty($_SESSION["dol_tz_string"])?@date_default_timezone_get():$_SESSION["dol_tz_string"]);
try {
$localtz = new DateTimeZone($default_timezone);
}
catch(Exception $e)
{
dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING);
$default_timezone=@date_default_timezone_get();
}
}
else $localtz = new DateTimeZone('UTC');
$dt = new DateTime(null,$localtz);

View File

@ -1290,7 +1290,7 @@ elseif (! empty($object->id))
//Local taxes
if($mysoc->localtax1_assuj=="1") $nbrow++;
if($mysoc->localtax2_assuj=="1") $nbrow++;
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/liste.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
@ -1518,7 +1518,7 @@ elseif (! empty($object->id))
print '<td align="right">'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($object->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
@ -1732,15 +1732,14 @@ elseif (! empty($object->id))
// Add free products/services form
global $forceall, $senderissupplier, $dateSelector;
$forceall=1; $senderissupplier=1; $dateSelector=0;
$var = true;
// Add free products/services
$object->formAddObjectLine(1, $societe, $mysoc);
$var = true;
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
// Add free products/services
$object->formAddObjectLine(1, $societe, $mysoc);
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
print '</table>';
@ -1966,7 +1965,7 @@ elseif (! empty($object->id))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->client->default_lang;
// Build document if it not exists
if (! $file || ! is_readable($file))
{

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,15 @@
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_expedition MODIFY COLUMN height float;
ALTER TABLE llx_expedition MODIFY COLUMN width float;
ALTER TABLE llx_expedition MODIFY COLUMN size float;
ALTER TABLE llx_expedition MODIFY COLUMN weight float;
ALTER TABLE llx_societe DROP COLUMN datea;
ALTER TABLE llx_holiday ADD COLUMN fk_user_create integer;
@ -1200,4 +1209,5 @@ ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, c
-- Fix: Missing instruction not correctly done into 3.5
-- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_mode_reglement DROP NOT NULL;
-- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_cond_reglement DROP NOT NULL;
-- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_cond_reglement DROP NOT NULL;

View File

@ -41,13 +41,13 @@ create table llx_expedition
fk_shipping_method integer,
tracking_number varchar(50),
fk_statut smallint DEFAULT 0,
height integer, -- height
width integer, -- with
height float, -- height
width float, -- with
size_units integer, -- unit of all sizes (height, width, depth)
size integer, -- depth
size float, -- depth
weight_units integer, -- unit of weight
weight integer, -- weight
weight float, -- weight
note_private text,
note_public text,
model_pdf varchar(255)

View File

@ -65,6 +65,8 @@ ShowPreview=Show preview
PreviewNotAvailable=Preview not available
ThemeCurrentlyActive=Theme currently active
CurrentTimeZone=TimeZone PHP (server)
MySQLTimeZone=TimeZone MySql (database)
TZHasNoEffect=Dates are stored and returned by database server as if they were kept as submited string. The timezone has effect only when using UNIX_TIMESTAMP function (that should not be used by Dolibarr, so database TZ should have no effect, even if changed after data was entered).
Space=Space
Table=Table
Fields=Fields
@ -1515,4 +1517,4 @@ ECMSetup = GED Setup
ECMAutoTree = Automatic tree folder and document
Format=Format
Format=Format

View File

@ -62,8 +62,8 @@ OrderStatusNotReadyToDispatch=Order has not yet or no more a status that allows
StockDiffPhysicTeoric=Reason for difference stock physical and theoretical
NoPredefinedProductToDispatch=No predefined products for this object. So no dispatching in stock is required.
DispatchVerb=Dispatch
StockLimitShort=Limit
StockLimit=Stock limit for alerts
StockLimitShort=Limit for alert
StockLimit=Stock limit for alert
PhysicalStock=Physical stock
RealStock=Real Stock
VirtualStock=Virtual stock

View File

@ -87,7 +87,7 @@ MyInformations=My data
ExportDataset_user_1=Dolibarr's users and properties
DomainUser=Domain user %s
Reactivate=Reactivate
CreateInternalUserDesc=This form allows you to creat an user internal to your company/foundation. To creat an external user (customer, supplier, ...), use button 'Create Dolibarr user' from third party's contact card.
CreateInternalUserDesc=This form allows you to create an user internal to your company/foundation. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card.
InternalExternalDesc=An <b>internal</b> user is a user that is part of your company/foundation.<br>An <b>external</b> user is a customer, supplier or other.<br><br>In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display)
PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group.
Inherited=Inherited

View File

@ -447,6 +447,9 @@ if (! defined('NOLOGIN'))
$dol_authmode=$conf->authmode; // This properties is defined only when logged, to say what mode was successfully used
$dol_tz=$_POST["tz"];
$dol_tz_string=$_POST["tz_string"];
$dol_tz_string=preg_replace('/\s*\(.+\)$/','',$dol_tz_string);
$dol_tz_string=preg_replace('/,/' ,'/',$dol_tz_string);
$dol_tz_string=preg_replace('/\s/','_',$dol_tz_string);
$dol_dst=0;
if (isset($_POST["dst_first"]) && isset($_POST["dst_second"]))
{

View File

@ -1677,17 +1677,19 @@ class Product extends CommonObject
$sql.= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql.= ", ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
$sql.= ", ".MAIN_DB_PREFIX."expedition as e";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE e.rowid = ed.fk_expedition";
$sql.= " AND c.rowid = cd.fk_commande";
$sql.= " AND e.fk_soc = s.rowid";
$sql.= " AND e.entity = ".$conf->entity;
$sql.= " AND ed.fk_origin_line = cd.rowid";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND e.fk_soc = ".$socid;
if ($filtrestatut <> '') $sql.= " AND e.fk_statut in (".$filtrestatut.")";
if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")";
$result = $this->db->query($sql);
if ( $result )
@ -1706,6 +1708,48 @@ class Product extends CommonObject
}
}
/**
* Charge tableau des stats réception fournisseur pour le produit/service
*
* @param int $socid Id societe pour filtrer sur une societe
* @param int $filtrestatut Id statut pour filtrer sur un statut
* @return array Tableau des stats
*/
function load_stats_reception($socid=0,$filtrestatut='')
{
global $conf,$user;
$sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,";
$sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.rowid = fd.fk_commande";
$sql.= " AND cf.fk_soc = s.rowid";
$sql.= " AND cf.entity = ".$conf->entity;
$sql.= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid;
if ($filtrestatut <> '') $sql.= " AND cf.fk_statut in (".$filtrestatut.")";
$result = $this->db->query($sql);
if ( $result )
{
$obj=$this->db->fetch_object($result);
$this->stats_reception['suppliers']=$obj->nb_customers;
$this->stats_reception['nb']=$obj->nb;
$this->stats_reception['rows']=$obj->nb_rows;
$this->stats_reception['qty']=$obj->qty?$obj->qty:0;
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/**
* Charge tableau des stats contrat pour le produit/service
*
@ -2868,6 +2912,7 @@ class Product extends CommonObject
}
}
$this->db->free($result);
$this->load_virtual_stock();
return 1;
}
else
@ -2877,6 +2922,47 @@ class Product extends CommonObject
}
}
/**
* Load information about virtual stock of a product
*
* @return int < 0 if KO, > 0 if OK
*/
function load_virtual_stock()
{
global $conf;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
{
$stock_commande_client=$stock_commande_fournisseur=0;
$stock_sending_client=$stock_reception_fournisseur=0;
if (! empty($conf->commande->enabled))
{
$result=$this->load_stats_commande(0,'1,2');
if ($result < 0) dol_print_error($db,$this->error);
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled))
{
$result=$this->load_stats_sending(0,'1,2');
if ($result < 0) dol_print_error($db,$this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$this->load_stats_commande_fournisseur(0,'3');
if ($result < 0) dol_print_error($db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0,'3');
if ($result < 0) dol_print_error($db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
}
$this->stock_theorique=$this->stock_reel-($stock_commande_client-$stock_sending_client)+($stock_commande_fournisseur-$stock_reception_fournisseur);
//echo $this->stock_theorique.' = '.$this->stock_reel.' - ('.$stock_commande_client.' - '.$stock_sending_client.') + ('.$stock_commande_fournisseur.' - '.$stock_reception_fournisseur.')';
}
}
/**
* Deplace fichier uploade sous le nom $files dans le repertoire sdir

View File

@ -118,7 +118,7 @@ if ($id > 0 || ! empty($ref))
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, c.rowid, c.total_ht as total_ht, c.ref,";
$sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid";
$sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.qty";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
@ -148,6 +148,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"c.date_commande","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -170,6 +171,7 @@ if ($id > 0 || ! empty($ref))
print "<td>".$objp->code_client."</td>\n";
print "<td align=\"center\">";
print dol_print_date($db->jdate($objp->date_commande))."</td>";
print "<td align=\"center\">".$objp->qty."</td>\n";
print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
print '<td align="right">'.$commandestatic->LibStatut($objp->statut,$objp->facture,5).'</td>';
print "</tr>\n";

View File

@ -111,7 +111,7 @@ if ($id > 0 || ! empty($ref))
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";
$sql.= " c.rowid, c.total_ht as total_ht, c.ref,";
$sql.= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid";
$sql.= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.qty";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
@ -141,6 +141,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"c.date_commande","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -165,6 +166,7 @@ if ($id > 0 || ! empty($ref))
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'</a></td>';
print "<td>".$objp->code_client."</td>\n";
print '<td align="center">'.dol_print_date($db->jdate($objp->date_commande))."</td>";
print "<td align=\"center\">".$objp->qty."</td>\n";
print '<td align="right">'.price($objp->total_ht)."</td>\n";
print '<td align="right">'.$commandestatic->getLibStatut(4).'</td>';
print "</tr>\n";

View File

@ -122,7 +122,7 @@ if ($id > 0 || ! empty($ref))
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";
$sql.= " f.facnumber, f.total as total_ht,";
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
@ -152,6 +152,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -174,6 +175,7 @@ if ($id > 0 || ! empty($ref))
print "<td>".$objp->code_client."</td>\n";
print "<td align=\"center\">";
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
print "<td align=\"center\">".$objp->qty."</td>\n";
print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
print "</tr>\n";

View File

@ -123,7 +123,7 @@ if ($id > 0 || ! empty($ref))
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, f.ref, f.total_ht as total_ht,";
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
@ -153,6 +153,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -175,6 +176,7 @@ if ($id > 0 || ! empty($ref))
print "<td>".$objp->code_client."</td>\n";
print "<td align=\"center\">";
print dol_print_date($db->jdate($objp->datef))."</td>";
print "<td align=\"center\">".$objp->qty."</td>\n";
print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
print '<td align="right">'.$supplierinvoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
print "</tr>\n";

View File

@ -113,7 +113,7 @@ if ($id > 0 || ! empty($ref))
$sql = "SELECT DISTINCT s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.total_ht as amount,";
$sql.= "p.datep, p.fk_statut as statut";
$sql.= "p.datep, p.fk_statut as statut, d.qty";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ",".MAIN_DB_PREFIX."propal as p";
@ -141,6 +141,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.rowid","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$product->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DatePropal"),$_SERVER["PHP_SELF"],"p.datep","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$product->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"p.total","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -162,6 +163,7 @@ if ($id > 0 || ! empty($ref))
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'</a></td>';
print '<td align="center">';
print dol_print_date($db->jdate($objp->datep))."</td>";
print "<td align=\"center\">".$objp->qty."</td>\n";
print '<td align="right">'.price($objp->amount).'</td>'."\n";
print '<td align="right">'.$propalstatic->LibStatut($objp->statut,5).'</td>';
print '</tr>'."\n";

View File

@ -321,23 +321,6 @@ if ($id > 0 || $ref)
// If stock if stock increment is done on real sending
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
{
$stock_commande_client=$stock_commande_fournisseur=0;
if (! empty($conf->commande->enabled))
{
$result=$product->load_stats_commande(0,'1,2');
if ($result < 0) dol_print_error($db,$product->error);
$stock_commande_client=$product->stats_commande['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$product->load_stats_commande_fournisseur(0,'3');
if ($result < 0) dol_print_error($db,$product->error);
$stock_commande_fournisseur=$product->stats_commande_fournisseur['qty'];
}
$product->stock_theorique=$product->stock_reel-($stock_commande_client+$stock_sending_client)+$stock_commande_fournisseur;
// Stock theorique
print '<tr><td>'.$langs->trans("VirtualStock").'</td>';
print "<td>".$product->stock_theorique;
@ -360,7 +343,7 @@ if ($id > 0 || $ref)
if (! empty($conf->commande->enabled))
{
if ($found) print '<br>'; else $found=1;
print $langs->trans("CustomersOrdersRunning").': '.($stock_commande_client+$stock_sending_client);
print $langs->trans("CustomersOrdersRunning").': '.($product->stats_commande['qty']-$product->stats_sendings['qty']);
$result=$product->load_stats_commande(0,'0');
if ($result < 0) dol_print_error($db,$product->error);
print ' ('.$langs->trans("Draft").': '.$product->stats_commande['qty'].')';
@ -372,7 +355,7 @@ if ($id > 0 || $ref)
if (! empty($conf->fournisseur->enabled))
{
if ($found) print '<br>'; else $found=1;
print $langs->trans("SuppliersOrdersRunning").': '.$stock_commande_fournisseur;
print $langs->trans("SuppliersOrdersRunning").': '.($product->stats_commande_fournisseur['qty']-$product->stats_reception['qty']);
$result=$product->load_stats_commande_fournisseur(0,'0,1,2');
if ($result < 0) dol_print_error($db,$product->error);
print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')';

View File

@ -64,7 +64,7 @@ if (!$sortorder) {
$limit = $conf->liste_limit;
$offset = $limit * $page ;
// Force limit to non (currently solution to solve loosing selection when using pagination. No pagination on this page)
// Force limit to no (currently solution to solve loosing selection when using pagination. No pagination on this page)
$limit = 0;
@ -189,9 +189,10 @@ if ($action == 'order' && isset($_POST['valid']))
$form = new Form($db);
$virtualdiffersfromphysical=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
) $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
{
$virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
}
$usevirtualstock=-1;
if ($virtualdiffersfromphysical)
@ -205,8 +206,8 @@ $title = $langs->trans('Status');
$sql = 'SELECT p.rowid, p.ref, p.label, p.price,';
$sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,';
$sql.= ' p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,';
$sql.= ' p.desiredstock,';
$sql.= ' p.tms as datem, p.duration, p.tobuy,';
$sql.= ' p.desiredstock, p.seuil_stock_alerte as alertstock,';
$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique';
$sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p';
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s';
@ -244,47 +245,76 @@ $sql.= ' AND p.tobuy = 1';
if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"';
$sql.= ' GROUP BY p.rowid, p.ref, p.label, p.price';
$sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms';
$sql.= ', p.duration, p.tobuy, p.seuil_stock_alerte';
$sql.= ', p.desiredstock, s.fk_product';
$sql.= ', p.duration, p.tobuy';
$sql.= ', p.desiredstock, p.seuil_stock_alerte';
$sql.= ', s.fk_product';
if($usevirtualstock) {
$sqlCommandesCli = "(SELECT SUM(cd.qty) as qty";
if ($usevirtualstock)
{
$sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty";
$sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sqlCommandesCli.= ", ".MAIN_DB_PREFIX."commande as c";
$sqlCommandesCli.= " WHERE c.rowid = cd.fk_commande";
$sqlCommandesCli.= " AND c.entity = ".$conf->entity;
$sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)";
$sqlCommandesCli.= " WHERE c.entity = ".$conf->entity;
$sqlCommandesCli.= " AND cd.fk_product = p.rowid";
$sqlCommandesCli.= " AND c.fk_statut in (1,2))";
$sqlCommandesCli.= " AND c.fk_statut IN (1,2))";
$sqlCommandesFourn = "(SELECT SUM(cd.qty) as qty";
$sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed.qty) IS NULL", "0", "SUM(ed.qty)")." as qty";
$sqlExpeditionsCli.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)";
$sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)";
$sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)";
$sqlExpeditionsCli.= " WHERE e.entity = ".$conf->entity;
$sqlExpeditionsCli.= " AND cd.fk_product = p.rowid";
$sqlExpeditionsCli.= " AND c.fk_statut IN (1,2))";
$sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty";
$sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd";
$sqlCommandesFourn.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande";
$sqlCommandesFourn.= " AND c.entity = ".$conf->entity;
$sqlCommandesFourn.= " AND cd.fk_product = p.rowid";
$sqlCommandesFourn.= " AND c.fk_statut in (3))";
$sqlCommandesFourn.= " AND c.fk_statut IN (3,4))";
$sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')';
$sql.= ' - '.$db->ifsql($sqlCommandesCli.' IS NULL', '0', $sqlCommandesCli).' + '.$db->ifsql($sqlCommandesFourn.' IS NULL', '0', $sqlCommandesFourn);
$sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty";
$sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)";
$sqlReceptionFourn.= " WHERE cf.entity = ".$conf->entity;
$sqlReceptionFourn.= " AND fd.fk_product = p.rowid";
$sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))";
$sql.= ' HAVING ((('.$db->ifsql("p.desiredstock IS NULL", "0", "p.desiredstock").' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')';
$sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))';
$sql.= ' OR (p.seuil_stock_alerte >= 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')';
$sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))';
if ($salert == 'on') // Option to see when stock is lower than alert
{
$sql.= ' AND (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')';
$sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))';
$alertchecked = 'checked="checked"';
}
} else {
$sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')';
$sql.= ' AND p.desiredstock > 0';
}
if ($salert == 'on') // Option to see when stock is lower than alert
{
$sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL';
$alertchecked = 'checked="checked"';
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset);
$sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))';
$sql.= ' OR (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))';
dol_syslog('Execute request', LOG_DEBUG);
if ($salert == 'on') // Option to see when stock is lower than alert
{
$sql.= ' AND (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))';
$alertchecked = 'checked="checked"';
}
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit, $offset);
//print $sql;
$resql = $db->query($sql);
if (empty($resql))
{
dol_print_error($db);
exit;
}
//print $sql;
$num = $db->num_rows($resql);
$i = 0;
@ -338,7 +368,7 @@ if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
$filters = '&sref=' . $sref . '&snom=' . $snom;
$filters .= '&fourn_id=' . $fourn_id;
$filters .= (isset($type)?'&type=' . $type:'');
$filters .= '&salert=' . $salert;
$filters .= '&=' . $salert;
$filters .= '&mode=' . $mode;
print_barre_liste(
$texte,
@ -359,6 +389,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">'
'<input type="hidden" name="type" value="' . $type . '">'.
'<input type="hidden" name="linecount" value="' . $num . '">'.
'<input type="hidden" name="action" value="order">'.
'<input type="hidden" name="mode" value="' . $mode . '">'.
'<table class="liste" width="100%">';
@ -367,121 +398,42 @@ $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert;
$param .= '&sref=' . $sref;
$param .= '&mode=' . $mode;
// Lines of title
print '<tr class="liste_titre"><td><input type="checkbox" onClick="toggle(this)" /></td>';
print_liste_field_titre(
$langs->trans('Ref'),
$_SERVER["PHP_SELF"],
'p.ref',
$param,
'',
'',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('Label'),
$_SERVER["PHP_SELF"],
'p.label',
$param,
'',
'',
$sortfield,
$sortorder
);
if (!empty($conf->service->enabled) && $type == 1)
{
print_liste_field_titre(
$langs->trans('Duration'),
$_SERVER["PHP_SELF"],
'p.duration',
$param,
'',
'align="center"',
$sortfield,
$sortorder
);
}
print_liste_field_titre(
$langs->trans('DesiredStock'),
$_SERVER["PHP_SELF"],
'p.desiredstock',
$param,
'',
'align="right"',
$sortfield,
$sortorder
);
$stocklabel = $langs->trans('Stock');
if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock');
if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock');
print_liste_field_titre(
$stocklabel,
$_SERVER["PHP_SELF"],
'stock_physique',
$param,
'',
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('Ordered'),
$_SERVER["PHP_SELF"],
'',
$param,
'',
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('StockToBuy'),
$_SERVER["PHP_SELF"],
'',
$param,
'',
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('Supplier'),
$_SERVER["PHP_SELF"],
'',
$param,
'',
'align="right"',
$sortfield,
$sortorder
);
// Lines of title
print '<tr class="liste_titre"><td><input type="checkbox" onClick="toggle(this)" /></td>';
print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', $param, '', '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', $param, '', '', $sortfield, $sortorder);
if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans('Duration'), $_SERVER["PHP_SELF"], 'p.duration', $param, '', 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('DesiredStock'), $_SERVER["PHP_SELF"], 'p.desiredstock', $param, '', 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('StockLimitShort'), $_SERVER["PHP_SELF"], 'p.seuil_stock_alerte', $param, '', 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $param, '', 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Ordered'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('StockToBuy'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Supplier'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
print '</tr>';
// Lignes des champs de filtre
print '<tr class="liste_titre">'.
'<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre">'.
'<input class="flat" type="text" name="sref" size="8" value="'.dol_escape_htmltag($sref).'">'.
'</td>'.
'<td class="liste_titre">'.
'<input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).'">'.
'</td>';
if (!empty($conf->service->enabled) && $type == 1)
{
print '<td class="liste_titre">&nbsp;</td>';
}
'<td class="liste_titre"><input class="flat" type="text" name="sref" size="8" value="'.dol_escape_htmltag($sref).'"></td>'.
'<td class="liste_titre"><input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).'"></td>';
if (!empty($conf->service->enabled) && $type == 1) print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" name="salert" ' . $alertchecked . '></td>'.
'<td class="liste_titre" align="right">&nbsp;</td>'.
'<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" id="salert" name="salert" ' . $alertchecked . '></td>'.
'<td class="liste_titre" align="right">&nbsp;</td>'.
'<td class="liste_titre">&nbsp;</td>'.
'<td class="liste_titre" align="right">'.
'<input class="liste_titre" name="button_search" type="image" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'.
'<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'.
'</td>'.
'</tr>';
'</td>';
print '</tr>';
$prod = new Product($db);
@ -492,6 +444,9 @@ while ($i < ($limit ? min($num, $limit) : $num))
if (! empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0)
{
$prod->fetch($objp->rowid);
$prod->load_stock();
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS))
{
@ -508,59 +463,43 @@ while ($i < ($limit ? min($num, $limit) : $num))
if (!empty($objtp->label)) $objp->label = $objtp->label;
}
}
$form = new Form($db);
$var =! $var;
$prod->ref = $objp->ref;
$prod->id = $objp->rowid;
$prod->type = $objp->fk_product_type;
// Get number already ordered.
$ordered = ordered($prod->id);
// Defined current stock number and warning if required
if ($usevirtualstock)
{
// If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock.
$prod->fetch($prod->id);
$result=$prod->load_stats_commande(0, '1,2');
if ($result < 0) {
dol_print_error($db, $prod->error);
}
$stock_commande_client = $prod->stats_commande['qty'];
$result=$prod->load_stats_commande_fournisseur(0, '3');
if ($result < 0) {
dol_print_error($db,$prod->error);
}
$stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty'];
$stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur;
$stock = $prod->stock_theorique;
}
else
{
$stock = $objp->stock_physique;
$stock = $prod->stock_reel;
}
$ordered = $prod->stats_commande_fournisseur['qty']-$prod->stats_reception['qty'];
$warning='';
if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte))
if ($objp->alertstock && ($stock < $objp->alertstock))
{
$warning = img_warning($langs->trans('StockTooLow')) . ' ';
}
//depending on conf, use either physical stock or
//virtual stock to compute the stock to buy value
$stocktobuy = max($objp->desiredstock - $stock - $ordered, 0);
/*
$stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0);
$disabled = '';
if($ordered > 0)
{
if ($ordered + $stock >= $objp->desiredstock)
{
$picto = img_picto('', 'ok', '');
if($ordered > 0) {
$compare = $usevirtualstock ? $stock : $stock + $ordered;
if($compare >= $objp->desiredstock) {
$picto = img_picto('', './img/yes', '', 1);
$disabled = 'disabled="disabled"';
}
else {
$picto = img_picto($langs->trans("NotEnough"), 'warning', '');
$picto = img_picto('', './img/no', '', 1);
}
} else {
$picto = img_picto('', 'info', '');
}*/
$picto = img_picto('', './img/no', '', 1);
}
print '<tr '.$bc[$var].'>';
@ -589,6 +528,9 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Desired stock
print '<td align="right">' . $objp->desiredstock . '</td>';
// Limit stock for alerr
print '<td align="right">' . $objp->alertstock . '</td>';
// Current stock
print '<td align="right">'. $warning . $stock. '</td>';

View File

@ -238,8 +238,8 @@ if ($action == 'add' && $canadduser)
{
$langs->load("errors");
$db->rollback();
if (is_array($object->errors) && count($object->errors)) $message='<div class="error">'.join('<br>',$langs->trans($object->errors)).'</div>';
else $message='<div class="error">'.$langs->trans($object->error).'</div>';
if (is_array($object->errors) && count($object->errors)) setEventMessage($object->errors,'errors');
else setEventMessage($object->error);
$action="create"; // Go back to create page
}
@ -909,7 +909,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
// Multicompany
if (! empty($conf->multicompany->enabled))
{
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc))
{
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity);