Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
813f55e50b
@ -31,6 +31,7 @@ For users:
|
||||
- New: Created {line_price_ht_locale}, {line_price_vat_locale} and {line_price_ttc_locale} ODT tags.
|
||||
- New: Add filter on project status into task list. By default, only "opened" project are visible.
|
||||
- New: Status "validated" for project are renamed into "opened".
|
||||
- New: Add barcode fields into user database.
|
||||
- Fix: Project Task numbering customs rule works.
|
||||
|
||||
TODO
|
||||
@ -90,11 +91,11 @@ Fix: Enable extrafields for customer order, proposal and invoice lines. This fea
|
||||
Fix: user right on Holiday for month report nor working.
|
||||
Fix: [ bug #1250 ] "Supplier Ref. product" sidebar search box does not work
|
||||
Fix: Bad space in predefined messages.
|
||||
Fix: Signature was not added for email sent from thirdparty page.
|
||||
Fix: [ bug #1256 ] Signature was not added for email sent from thirdparty page.
|
||||
Fix: Action event SHIPPING_VALIDATE is not implemented
|
||||
Fix: The customer code was set to uppercase when using numbering module leopard. We
|
||||
must keep data safe of any change.
|
||||
Fix: Loading actions extrafields fails.
|
||||
Fix: [ bug #1291 ] Loading actions extrafields fails.
|
||||
Fix: [ bug #1123 ] Paid deposit invoices are always shown as partially paid when fully paid
|
||||
Fix: Corrected project contact types translation.
|
||||
Fix: [ bug #1206 ] PMP price is bad calculated.
|
||||
@ -102,6 +103,7 @@ Fix: [ bug #520 ] Product statistics and detailed lists are wrong.
|
||||
Fix: [ bug #1240 ] traduction.
|
||||
Fix: [ bug #1238 ] When creating accompte with a %, free product are used for calculation.
|
||||
Fix: [ bug #1280 ] service with not end of date was tagged as expired.
|
||||
Fix: [ bug #1295 ] Error when creating an agenda extrafield with a number as reference
|
||||
|
||||
***** ChangeLog for 3.5 compared to 3.4.* *****
|
||||
For users:
|
||||
|
||||
@ -758,5 +758,15 @@ SSLCertificateKeyFile "WAMPROOT/myserver.key"
|
||||
#ExpiresByType application/javascript A2592000
|
||||
|
||||
|
||||
# To protect Dolibarr with HTTP Auth
|
||||
#<Location /dolibarr>
|
||||
# Options +Indexes
|
||||
# AuthUserFile /var/www/.htpasswd
|
||||
# AuthName "Zone authent basic Dolibarr"
|
||||
# AuthType Basic
|
||||
# require user test
|
||||
#</Location>
|
||||
|
||||
|
||||
# Declare alias for Dolibarr, PHPMyAdmin and other softwares
|
||||
Include "WAMPROOT/alias/*.conf"
|
||||
|
||||
@ -261,7 +261,7 @@ if ($object->id > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -137,7 +137,7 @@ if ($object->id > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -128,7 +128,7 @@ if ($object->id)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -160,7 +160,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -167,7 +167,7 @@ if ($object->id)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ if ($object->id)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -262,7 +262,9 @@ if ($action == 'add' && $user->rights->contrat->creer)
|
||||
// Define output language
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
$prod = new Product($db, $lines[$i]->fk_product);
|
||||
$prod = new Product($db);
|
||||
$prod->id=$lines[$i]->fk_product;
|
||||
$prod->getMultiLangs();
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
|
||||
@ -481,6 +481,8 @@ class FormOther
|
||||
{
|
||||
$var = !$var;
|
||||
|
||||
//var_dump($selectedtask."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);
|
||||
|
||||
// Break on a new project
|
||||
if ($parent == 0)
|
||||
{
|
||||
@ -508,10 +510,10 @@ class FormOther
|
||||
}
|
||||
|
||||
// Print task
|
||||
if ($lines[$i]->id > 0)
|
||||
if ($lines[$i]->id >= 0)
|
||||
{
|
||||
print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"';
|
||||
if ($lines[$i]->id == $selectedtask) print ' selected="selected"';
|
||||
if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) print ' selected="selected"';
|
||||
print '>';
|
||||
print $langs->trans("Project").' '.$lines[$i]->projectref;
|
||||
if (empty($lines[$i]->public))
|
||||
|
||||
@ -957,7 +957,7 @@ class DoliDBMysql extends DoliDB
|
||||
{
|
||||
// cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra
|
||||
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
|
||||
$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
|
||||
$sql= "ALTER TABLE ".$table." ADD `".$field_name."` ";
|
||||
$sql.= $field_desc['type'];
|
||||
if(preg_match("/^[^\s]/i",$field_desc['value']))
|
||||
if (! in_array($field_desc['type'],array('date','datetime')))
|
||||
|
||||
@ -960,7 +960,7 @@ class DoliDBMysqli extends DoliDB
|
||||
{
|
||||
// cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra
|
||||
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
|
||||
$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
|
||||
$sql= "ALTER TABLE ".$table." ADD `".$field_name."` ";
|
||||
$sql.= $field_desc['type'];
|
||||
if(preg_match("/^[^\s]/i",$field_desc['value']))
|
||||
if (! in_array($field_desc['type'],array('date','datetime')))
|
||||
|
||||
@ -390,7 +390,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0)
|
||||
|
||||
$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$(document).ready(function() {
|
||||
var input = '.json_encode($input).';
|
||||
var url = \''.DOL_URL_ROOT.'/core/ajax/constantonoff.php\';
|
||||
var code = \''.$code.'\';
|
||||
|
||||
@ -285,7 +285,6 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
|
||||
print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n";
|
||||
|
||||
// Project
|
||||
if ($showproject)
|
||||
{
|
||||
// Project ref
|
||||
@ -299,7 +298,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
if ($showlineingray) print '</i>';
|
||||
print "</td>";
|
||||
|
||||
// Status
|
||||
// Project status
|
||||
print '<td>';
|
||||
$projectstatic->statut=$lines[$i]->projectstatus;
|
||||
print $projectstatic->getLibStatut(2);
|
||||
@ -389,7 +388,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
if (! $showlineingray) $inc++;
|
||||
|
||||
$level++;
|
||||
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, 0, $showalsopublicproj);
|
||||
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
|
||||
$level--;
|
||||
$total += $lines[$i]->duration;
|
||||
}
|
||||
@ -400,7 +399,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
}
|
||||
}
|
||||
|
||||
if ($total>0)
|
||||
if ($total>0 && $level==0)
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total">'.$langs->trans("Total").'</td>';
|
||||
@ -410,9 +409,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
if ($addordertick) print '<td class="hideonsmartphone"></td>';
|
||||
print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total, 'allhourmin').'</td>';
|
||||
print '<td></td>';
|
||||
if ($addordertick) print '<td class="hideonsmartphone"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +219,11 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
$object = new $origin($db);
|
||||
$object->fetch($origin_id);
|
||||
$object->fetch_thirdparty();
|
||||
$prod = new Product($db, $objp->fk_product);
|
||||
|
||||
$prod = new Product($db);
|
||||
$prod->id=$objp->fk_product;
|
||||
$prod->getMultiLangs();
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
|
||||
@ -153,7 +153,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($action == 'cloture')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id,$langs->trans("CloseShipment"),$langs->trans("ConfirmCloseShipment"),"confirm_cloture");
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Onglet commande
|
||||
@ -409,7 +409,11 @@ if ($id > 0 || ! empty($ref))
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
$commande->fetch_thirdparty();
|
||||
$prod = new Product($db, $objp->fk_product);
|
||||
|
||||
$prod = new Product($db);
|
||||
$prod->id=$objp->fk_product;
|
||||
$prod->getMultiLangs();
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
|
||||
@ -128,7 +128,7 @@ if ($object->id)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -226,7 +226,9 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
||||
// Define output language
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
$prod = new Product($db, $lines[$i]->fk_product);
|
||||
$prod = new Product($db);
|
||||
$prod->id=$lines[$i]->fk_product;
|
||||
$prod->getMultiLangs();
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
|
||||
@ -183,7 +183,7 @@ if ($object->id > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('UnkownError');
|
||||
print $langs->trans('ErrorUnknown');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -991,11 +991,13 @@ ALTER TABLE llx_product_customer_price ADD UNIQUE INDEX uk_customer_price_fk_pro
|
||||
ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product(rowid) ON DELETE CASCADE;
|
||||
ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE llx_user ADD COLUMN barcode varchar(255) DEFAULT NULL;
|
||||
ALTER TABLE llx_user ADD COLUMN fk_barcode_type integer DEFAULT 0;
|
||||
|
||||
create table llx_product_customer_price_log
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
datec datetime,
|
||||
fk_product integer NOT NULL,
|
||||
fk_soc integer NOT NULL,
|
||||
@ -1015,43 +1017,43 @@ create table llx_product_customer_price_log
|
||||
--Batch number managment
|
||||
ALTER TABLE llx_product ADD COLUMN tobatch tinyint DEFAULT 0 NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `llx_product_batch` (
|
||||
`rowid` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`fk_product_stock` int(11) NOT NULL,
|
||||
`eatby` datetime DEFAULT NULL,
|
||||
`sellby` datetime DEFAULT NULL,
|
||||
`batch` varchar(30) DEFAULT NULL,
|
||||
`qty` double NOT NULL DEFAULT '0',
|
||||
`import_key` varchar(14) DEFAULT NULL,
|
||||
KEY `ix_fk_product_stock` (`fk_product_stock`)
|
||||
CREATE TABLE IF NOT EXISTS llx_product_batch (
|
||||
rowid int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
fk_product_stock int(11) NOT NULL,
|
||||
eatby datetime DEFAULT NULL,
|
||||
sellby datetime DEFAULT NULL,
|
||||
batch varchar(30) DEFAULT NULL,
|
||||
qty double NOT NULL DEFAULT '0',
|
||||
import_key varchar(14) DEFAULT NULL,
|
||||
KEY ix_fk_product_stock (fk_product_stock)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `llx_expeditiondet_batch` (
|
||||
`rowid` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`fk_expeditiondet` int(11) NOT NULL,
|
||||
`eatby` date DEFAULT NULL,
|
||||
`sellby` date DEFAULT NULL,
|
||||
`batch` varchar(30) DEFAULT NULL,
|
||||
`qty` double NOT NULL DEFAULT '0',
|
||||
`fk_origin_stock` int(11) NOT NULL,
|
||||
KEY `ix_fk_expeditiondet` (`fk_expeditiondet`)
|
||||
CREATE TABLE IF NOT EXISTS llx_expeditiondet_batch (
|
||||
rowid int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_expeditiondet int(11) NOT NULL,
|
||||
eatby date DEFAULT NULL,
|
||||
sellby date DEFAULT NULL,
|
||||
batch varchar(30) DEFAULT NULL,
|
||||
qty double NOT NULL DEFAULT '0',
|
||||
fk_origin_stock int(11) NOT NULL,
|
||||
KEY ix_fk_expeditiondet (fk_expeditiondet)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--Salary payment in tax module
|
||||
CREATE TABLE IF NOT EXISTS `llx_payment_salary` (
|
||||
`rowid` integer AUTO_INCREMENT PRIMARY KEY,
|
||||
`tms` timestamp,
|
||||
`fk_user` integer NOT NULL,
|
||||
`datep` date,
|
||||
`datev` date,
|
||||
`amount` real NOT NULL DEFAULT 0,
|
||||
`label` varchar(255),
|
||||
`datesp` date, -- date de début de la période
|
||||
`dateep` date, -- date de fin de la période
|
||||
`entity` integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
`note` text,
|
||||
`fk_bank` integer,
|
||||
`fk_user_creat` integer,
|
||||
`fk_user_modif` integer
|
||||
CREATE TABLE IF NOT EXISTS llx_payment_salary (
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_user integer NOT NULL,
|
||||
datep date,
|
||||
datev date,
|
||||
amount real NOT NULL DEFAULT 0,
|
||||
label varchar(255),
|
||||
datesp date, -- date de début de la période
|
||||
dateep date, -- date de fin de la période
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
note text,
|
||||
fk_bank integer,
|
||||
fk_user_creat integer,
|
||||
fk_user_modif integer
|
||||
)ENGINE=innodb;
|
||||
@ -43,21 +43,21 @@ create table llx_product
|
||||
price_min double(24,8) DEFAULT 0,
|
||||
price_min_ttc double(24,8) DEFAULT 0,
|
||||
price_base_type varchar(3) DEFAULT 'HT',
|
||||
tva_tx double(6,3),
|
||||
recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT
|
||||
tva_tx double(6,3), -- Default VAT rate of product
|
||||
recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT
|
||||
localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1
|
||||
localtax2_tx double(6,3) DEFAULT 0, -- Spanish local VAT 2
|
||||
fk_user_author integer,
|
||||
tosell tinyint DEFAULT 1,
|
||||
tobuy tinyint DEFAULT 1,
|
||||
tobatch tinyint DEFAULT 0 NOT NULL,
|
||||
fk_product_type integer DEFAULT 0, -- Type 0 for regular product, 1 for service, 9 for other (used by external module)
|
||||
tosell tinyint DEFAULT 1, -- Product you sell
|
||||
tobuy tinyint DEFAULT 1, -- Product you buy
|
||||
tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch or eat-by management
|
||||
fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module)
|
||||
duration varchar(6),
|
||||
seuil_stock_alerte integer DEFAULT 0,
|
||||
barcode varchar(255) DEFAULT NULL,
|
||||
fk_barcode_type integer DEFAULT 0,
|
||||
accountancy_code_sell varchar(15), -- Selling accountancy code
|
||||
accountancy_code_buy varchar(15), -- Buying accountancy code
|
||||
accountancy_code_sell varchar(15), -- Selling accountancy code
|
||||
accountancy_code_buy varchar(15), -- Buying accountancy code
|
||||
partnumber varchar(32), -- Not used. Used by external modules.
|
||||
weight float DEFAULT NULL,
|
||||
weight_units tinyint DEFAULT NULL,
|
||||
@ -71,7 +71,7 @@ create table llx_product
|
||||
pmp double(24,8) DEFAULT 0 NOT NULL,
|
||||
canvas varchar(32) DEFAULT NULL,
|
||||
finished tinyint DEFAULT NULL,
|
||||
hidden tinyint DEFAULT 0, -- Need permission see also hidden products
|
||||
hidden tinyint DEFAULT 0, -- Not used. Deprecated.
|
||||
import_key varchar(14), -- Import key
|
||||
desiredstock integer DEFAULT 0
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -64,5 +64,7 @@ create table llx_user
|
||||
photo varchar(255), -- filename or url of photo
|
||||
lang varchar(6),
|
||||
color varchar(6),
|
||||
barcode varchar(255) DEFAULT NULL,
|
||||
fk_barcode_type integer DEFAULT 0,
|
||||
accountancy_code varchar(24) NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -7,7 +7,7 @@ DIRECTION=ltr
|
||||
FONTFORPDF=helvetica
|
||||
FONTSIZEFORPDF=10
|
||||
SeparatorDecimal=,
|
||||
SeparatorThousand=None
|
||||
SeparatorThousand=
|
||||
FormatDateShort=%d/%m/%Y
|
||||
FormatDateShortInput=%d/%m/%Y
|
||||
FormatDateShortJava=dd/MM/yyyy
|
||||
|
||||
@ -34,7 +34,7 @@ ErrorFailedToOpenFile=Failed to open file %s
|
||||
ErrorCanNotCreateDir=Can not create dir %s
|
||||
ErrorCanNotReadDir=Can not read dir %s
|
||||
ErrorConstantNotDefined=Parameter %s not defined
|
||||
ErrorUnknown=Unkown error
|
||||
ErrorUnknown=Unknown error
|
||||
ErrorSQL=SQL Error
|
||||
ErrorLogoFileNotFound=Logo file '%s' was not found
|
||||
ErrorGoToGlobalSetup=Go to 'Company/Foundation' setup to fix this
|
||||
|
||||
@ -5,3 +5,7 @@ ProductStatusNotOnBatch= Not Managed
|
||||
ProductStatusOnBatchShort= Managed
|
||||
ProductStatusNotOnBatchShort= Not Managed
|
||||
Batch=Batch
|
||||
atleast1batchfield= Eat-by date or Sell-by date or Batch number
|
||||
batch_number= Batch number
|
||||
l_eatby= Eat-by date
|
||||
l_sellby= Sell-by date
|
||||
|
||||
@ -5,3 +5,8 @@ ProductStatusNotOnBatch= Non gérer
|
||||
ProductStatusOnBatchShort= Gérer
|
||||
ProductStatusNotOnBatchShort= Non gérer
|
||||
Batch=Lot
|
||||
atleast1batchfield= DLC ou DLUO ou Numéro de lot
|
||||
batch_number= Numéro de lot
|
||||
l_eatby= DLC
|
||||
l_sellby= DLUO
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
* \brief File of class to manage predefined products or services
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -2796,7 +2797,7 @@ class Product extends CommonObject
|
||||
{
|
||||
$this->stock_reel = 0;
|
||||
|
||||
$sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp";
|
||||
$sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp, ps.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."entrepot as w";
|
||||
$sql.= " WHERE w.entity IN (".getEntity('warehouse', 1).")";
|
||||
@ -2817,6 +2818,7 @@ class Product extends CommonObject
|
||||
$this->stock_warehouse[$row->fk_entrepot] = new stdClass();
|
||||
$this->stock_warehouse[$row->fk_entrepot]->real = $row->reel;
|
||||
$this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp;
|
||||
if ($this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1);
|
||||
$this->stock_reel+=$row->reel;
|
||||
$i++;
|
||||
}
|
||||
@ -3320,5 +3322,47 @@ class Product extends CommonObject
|
||||
{
|
||||
return ($this->status_batch == 1 ? true : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust stock in a warehouse for product with batch number
|
||||
*
|
||||
* @param User $user user asking change
|
||||
* @param int $id_entrepot id of warehouse
|
||||
* @param double $nbpiece nb of units
|
||||
* @param int $movement 0 = add, 1 = remove
|
||||
* @param string $label Label of stock movement
|
||||
* @param double $price Price to use for stock eval
|
||||
* @param date $dlc eat-by date
|
||||
* @param date $dluo sell-by date
|
||||
* @param string $lot Lot number
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $dlc='', $dluo='',$lot='')
|
||||
{
|
||||
if ($id_entrepot)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
$op[0] = "+".trim($nbpiece);
|
||||
$op[1] = "-".trim($nbpiece);
|
||||
|
||||
$movementstock=new MouvementStock($this->db);
|
||||
$result=$movementstock->_create($user,$this->id,$id_entrepot,$op[$movement],$movement,$price,$label,'',$dlc,$dluo,$lot);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
526
htdocs/product/class/productbatch.class.php
Normal file
526
htdocs/product/class/productbatch.class.php
Normal file
@ -0,0 +1,526 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file product/class/productbatch.class.php
|
||||
* \ingroup productbatch
|
||||
* \brief Manage record and specific data for batch number management
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||
|
||||
|
||||
/**
|
||||
* Manage record for batch number management
|
||||
*/
|
||||
class Productbatch extends CommonObject
|
||||
{
|
||||
var $element='productbatch'; //!< Id that identify managed objects
|
||||
private static $_table_element='product_batch'; //!< Name of table without prefix where object is stored
|
||||
|
||||
var $id;
|
||||
|
||||
var $tms='';
|
||||
var $fk_product_stock;
|
||||
var $sellby='';
|
||||
var $eatby='';
|
||||
var $batch='';
|
||||
var $qty;
|
||||
var $import_key;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
function create($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
$this->clean_param();
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.self::$_table_element." (";
|
||||
$sql.= "fk_product_stock,";
|
||||
$sql.= "sellby,";
|
||||
$sql.= "eatby,";
|
||||
$sql.= "batch,";
|
||||
$sql.= "qty,";
|
||||
$sql.= "import_key";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= " ".(! isset($this->fk_product_stock)?'NULL':$this->fk_product_stock).",";
|
||||
$sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':$this->db->idate($this->sellby)).",";
|
||||
$sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':$this->db->idate($this->eatby)).",";
|
||||
$sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").",";
|
||||
$sql.= " ".(! isset($this->qty)?'NULL':$this->qty).",";
|
||||
$sql.= " ".(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'")."";
|
||||
|
||||
|
||||
$sql.= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
if (! $error)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element);
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " t.fk_product_stock,";
|
||||
$sql.= " t.sellby,";
|
||||
$sql.= " t.eatby,";
|
||||
$sql.= " t.batch,";
|
||||
$sql.= " t.qty,";
|
||||
$sql.= " t.import_key";
|
||||
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t";
|
||||
$sql.= " WHERE t.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
$this->fk_product_stock = $obj->fk_product_stock;
|
||||
$this->sellby = $this->db->jdate($obj->sellby);
|
||||
$this->eatby = $this->db->jdate($obj->eatby);
|
||||
$this->batch = $obj->batch;
|
||||
$this->qty = $obj->qty;
|
||||
$this->import_key = $obj->import_key;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user=0, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
$this->clean_param();
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.self::$_table_element." SET";
|
||||
$sql.= " fk_product_stock=".(isset($this->fk_product_stock)?$this->fk_product_stock:"null").",";
|
||||
$sql.= " sellby=".(dol_strlen($this->sellby)!=0 ? "'".$this->db->idate($this->sellby)."'" : 'null').",";
|
||||
$sql.= " eatby=".(dol_strlen($this->eatby)!=0 ? "'".$this->db->idate($this->eatby)."'" : 'null').",";
|
||||
$sql.= " batch=".(isset($this->batch)?"'".$this->db->escape($this->batch)."'":"null").",";
|
||||
$sql.= " qty=".(isset($this->qty)?$this->qty:"null").",";
|
||||
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null")."";
|
||||
$sql.= " WHERE rowid=".$this->id." AND tms='".$this->db->idate($this->tms)."'";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element."";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load an object from its id and create a new one in database
|
||||
*
|
||||
* @param int $fromid Id of object to clone
|
||||
* @return int New id of clone
|
||||
*/
|
||||
function createFromClone($fromid)
|
||||
{
|
||||
global $user,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$object=new Productbatch($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$object->fetch($fromid);
|
||||
$object->id=0;
|
||||
$object->statut=0;
|
||||
|
||||
// Clear fields
|
||||
// ...
|
||||
|
||||
// Create clone
|
||||
$result=$object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$object->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// End
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function initAsSpecimen()
|
||||
{
|
||||
$this->id=0;
|
||||
|
||||
$this->tms='';
|
||||
$this->fk_product_stock='';
|
||||
$this->sellby='';
|
||||
$this->eatby='';
|
||||
$this->batch='';
|
||||
$this->import_key='';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean fields (triming)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function clean_param() {
|
||||
if (isset($this->fk_product_stock)) $this->fk_product_stock=(int) trim($this->fk_product_stock);
|
||||
if (isset($this->batch)) $this->batch=trim($this->batch);
|
||||
if (isset($this->qty)) $this->qty=(float) trim($this->qty);
|
||||
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first detail record that match eather eat-by or sell-by or batch within given warehouse
|
||||
*
|
||||
* @param int $fk_product_stock id product_stock for objet
|
||||
* @param date $eatby eat-by date for objet
|
||||
* @param date $sellby sell-by date for objet
|
||||
* @param string $batch_number batch number for objet
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function find($fk_product_stock=0, $eatby='',$sellby='',$batch_number='')
|
||||
{
|
||||
global $langs;
|
||||
$where = array();
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " t.fk_product_stock,";
|
||||
$sql.= " t.sellby,";
|
||||
$sql.= " t.eatby,";
|
||||
$sql.= " t.batch,";
|
||||
$sql.= " t.qty,";
|
||||
$sql.= " t.import_key";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t";
|
||||
$sql.= " WHERE fk_product_stock=".$fk_product_stock;
|
||||
|
||||
if (! empty($eatby)) array_push($where," eatby = '".$this->db->idate($eatby)."'");
|
||||
if (! empty($sellby)) array_push($where," sellby = '".$this->db->idate($sellby)."'");
|
||||
if (! empty($batch_number)) $sql.= " AND batch = '".$this->db->escape($batch_number)."'";
|
||||
|
||||
if (! empty($where)) $sql.= " AND (".implode(" OR ",$where).")";
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
$this->fk_product_stock = $obj->fk_product_stock;
|
||||
$this->sellby = $this->db->jdate($obj->sellby);
|
||||
$this->eatby = $this->db->jdate($obj->eatby);
|
||||
$this->batch = $obj->batch;
|
||||
$this->qty = $obj->qty;
|
||||
$this->import_key = $obj->import_key;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return all batch detail records for given product and warehouse
|
||||
*
|
||||
* @param obj $db database object
|
||||
* @param int $fk_product_stock id product_stock for objet
|
||||
* @param int $with_qty doesn't return line with 0 quantity
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public static function findAll($db,$fk_product_stock,$with_qty=0)
|
||||
{
|
||||
global $langs;
|
||||
$ret = array();
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " t.fk_product_stock,";
|
||||
$sql.= " t.sellby,";
|
||||
$sql.= " t.eatby,";
|
||||
$sql.= " t.batch,";
|
||||
$sql.= " t.qty,";
|
||||
$sql.= " t.import_key";
|
||||
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t";
|
||||
$sql.= " WHERE fk_product_stock=".$fk_product_stock;
|
||||
|
||||
if ($with_qty) $sql.= " AND qty<>0";
|
||||
dol_syslog("productbatch::findAll sql=".$sql, LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i=0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$tmp = new productbatch($db);
|
||||
$tmp->id = $obj->rowid;
|
||||
$tmp->tms = $db->jdate($obj->tms);
|
||||
$tmp->fk_product_stock = $obj->fk_product_stock;
|
||||
$tmp->sellby = $db->jdate($obj->sellby);
|
||||
$tmp->eatby = $db->jdate($obj->eatby);
|
||||
$tmp->batch = $obj->batch;
|
||||
$tmp->qty = $obj->qty;
|
||||
$tmp->import_key = $obj->import_key;
|
||||
|
||||
array_push($ret,$tmp);
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error="Error ".$db->lasterror();
|
||||
dol_syslog("productbatch::find_all ".$error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -147,7 +147,7 @@ if ($object->id)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("UnkownError");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||
*
|
||||
* 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
|
||||
@ -55,9 +56,13 @@ class MouvementStock
|
||||
* @param int $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
|
||||
* @param string $label Label of stock movement
|
||||
* @param string $datem Force date of movement
|
||||
* @param date $eatby eat-by date
|
||||
* @param date $sellby sell-by date
|
||||
* @param string $batch batch number
|
||||
* @param boolean $skip_sellby If set to true, stock mouvement is done without impacting batch record
|
||||
* @return int <0 if KO, 0 if fk_product is null, >0 if OK
|
||||
*/
|
||||
function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='')
|
||||
function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='',$eatby='',$sellby='',$batch='',$skip_sellby=false)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -132,6 +137,7 @@ class MouvementStock
|
||||
$num = 1;
|
||||
$oldqtywarehouse = $obj->reel;
|
||||
$oldpmpwarehouse = $obj->pmp;
|
||||
$fk_product_stock = $obj->rowid;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
@ -193,7 +199,17 @@ class MouvementStock
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::_create ".$this->error, LOG_ERR);
|
||||
$error = -3;
|
||||
} else if(empty($fk_product_stock)){
|
||||
$fk_product_stock = $this->db->last_insert_id(MAIN_DB_PREFIX."product_stock");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update detail stock for sell-by date
|
||||
if (($product->hasbatch()) && (! $error) && (! $skip_sellby)){
|
||||
$param_batch=array('fk_product_stock' =>$fk_product_stock, 'eatby'=>$eatby,'sellby'=>$sellby,'batchnumber'=>$batch);
|
||||
$result=$this->_create_batch($param_batch, $qty);
|
||||
if ($result<0) $error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@ -314,9 +330,21 @@ class MouvementStock
|
||||
*/
|
||||
function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='')
|
||||
{
|
||||
return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, $datem);
|
||||
return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, $datem,'','','',true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease stock for batch record
|
||||
*
|
||||
* @param int $id_stock_dluo Id product_dluo
|
||||
* @param int $qty Quantity
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function livraison_batch($id_stock_dluo, $qty)
|
||||
{
|
||||
$ret=$this->_create_batch($id_stock_dluo, (0 - $qty));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase stock for product and subproducts
|
||||
@ -327,11 +355,14 @@ class MouvementStock
|
||||
* @param int $qty Quantity
|
||||
* @param int $price Price
|
||||
* @param string $label Label of stock movement
|
||||
* @param date $eatby eat-by date
|
||||
* @param date $sellby sell-by date
|
||||
* @param string $batch batch number
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function reception($user, $fk_product, $entrepot_id, $qty, $price=0, $label='')
|
||||
function reception($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $eatby='', $sellby='', $batch='')
|
||||
{
|
||||
return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label);
|
||||
return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, '', $eatby, $sellby, $batch);
|
||||
}
|
||||
|
||||
|
||||
@ -384,6 +415,59 @@ class MouvementStock
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update batch record
|
||||
*
|
||||
* @param variant $dluo Could be either int if id of product_batch or array with at leat fk_product_stock
|
||||
* @param int $qty Quantity of product with batch number
|
||||
* @return int <0 if KO, else return productbatch id
|
||||
*/
|
||||
function _create_batch($dluo, $qty ) {
|
||||
$pdluo=New Productbatch($this->db);
|
||||
|
||||
//Try to find an existing record with batch same batch number or id
|
||||
if (is_numeric($dluo)) {
|
||||
$result=$pdluo->fetch($dluo);
|
||||
} else if (is_array($dluo)) {
|
||||
if (isset($dluo['fk_product_stock'])) {
|
||||
$vfk_product_stock=$dluo['fk_product_stock'];
|
||||
$veatby = $dluo['eatby'];
|
||||
$vsellby = $dluo['sellby'];
|
||||
$vbatchnumber = $dluo['batchnumber'];
|
||||
$result = $pdluo->find($vfk_product_stock,$veatby,$vsellby,$vbatchnumber);
|
||||
} else {
|
||||
dol_syslog(get_class($this)."::_create_batch array param dluo must contain at least key fk_product_stock".$error, LOG_ERR);
|
||||
$result = -1;
|
||||
}
|
||||
} else {
|
||||
dol_syslog(get_class($this)."::_create_batch error invalid param dluo".$error, LOG_ERR);
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
//batch record found so we update it
|
||||
if ($result>0) {
|
||||
if ($pdluo->id >0) {
|
||||
$pdluo->qty +=$qty;
|
||||
if ($pdluo->qty == 0) {
|
||||
$result=$pdluo->delete(0,1);
|
||||
} else {
|
||||
$result=$pdluo->update(0,1);
|
||||
}
|
||||
} else {
|
||||
$pdluo->fk_product_stock=$vfk_product_stock;
|
||||
$pdluo->qty = $qty;
|
||||
$pdluo->eatby = $veatby;
|
||||
$pdluo->sellby = $vsellby;
|
||||
$pdluo->batch = $vbatchnumber;
|
||||
$result=$pdluo->create(0,1);
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador.gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Cédric Gross <c.gross@kreiz-it.fr>
|
||||
*
|
||||
* 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
|
||||
@ -32,11 +33,14 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load("orders");
|
||||
$langs->load("bills");
|
||||
$langs->load("stocks");
|
||||
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
|
||||
|
||||
|
||||
$action=GETPOST("action");
|
||||
$cancel=GETPOST('cancel');
|
||||
@ -99,14 +103,42 @@ if ($action == "correct_stock" && ! $cancel)
|
||||
$action='correction';
|
||||
}
|
||||
|
||||
if (! empty($conf->productbatch->enabled))
|
||||
{
|
||||
$product = new Product($db);
|
||||
$result=$product->fetch($id);
|
||||
|
||||
if ($product->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) {
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("atleast1batchfield")), 'errors');
|
||||
$error++;
|
||||
$action='correction';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$priceunit=price2num(GETPOST("price"));
|
||||
if (is_numeric(GETPOST("nbpiece")) && $id)
|
||||
{
|
||||
if (empty($product)) {
|
||||
$product = new Product($db);
|
||||
$result=$product->fetch($id);
|
||||
|
||||
}
|
||||
if ($product->hasbatch()) {
|
||||
$d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']);
|
||||
$d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
|
||||
$result=$product->correct_stock_batch(
|
||||
$user,
|
||||
GETPOST("id_entrepot"),
|
||||
GETPOST("nbpiece"),
|
||||
GETPOST("mouvement"),
|
||||
GETPOST("label"),
|
||||
$priceunit,
|
||||
$d_eatby,
|
||||
$d_sellby,
|
||||
GETPOST('batch_number')
|
||||
); // We do not change value of stock for a correction
|
||||
} else {
|
||||
$result=$product->correct_stock(
|
||||
$user,
|
||||
GETPOST("id_entrepot"),
|
||||
@ -115,6 +147,7 @@ if ($action == "correct_stock" && ! $cancel)
|
||||
GETPOST("label"),
|
||||
$priceunit
|
||||
); // We do not change value of stock for a correction
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -246,6 +279,12 @@ if ($id > 0 || $ref)
|
||||
print $product->getLibStatut(2,1);
|
||||
print '</td></tr>';
|
||||
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("l_sellby").')</td><td>';
|
||||
print $product->getLibStatut(2,2);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// PMP
|
||||
print '<tr><td>'.$langs->trans("AverageUnitPricePMP").'</td>';
|
||||
print '<td>'.price($product->pmp).' '.$langs->trans("HT").'</td>';
|
||||
@ -405,7 +444,7 @@ if ($id > 0 || $ref)
|
||||
|
||||
// Warehouse
|
||||
print '<tr>';
|
||||
print '<td width="20%" class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td width="20%" class="fieldrequired" colspan="2">'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td width="20%">';
|
||||
print $formproduct->selectWarehouses(($_GET["dwid"]?$_GET["dwid"]:GETPOST('id_entrepot')),'id_entrepot','',1);
|
||||
print '</td>';
|
||||
@ -419,13 +458,26 @@ if ($id > 0 || $ref)
|
||||
|
||||
// Label
|
||||
print '<tr>';
|
||||
print '<td width="20%">'.$langs->trans("Label").'</td>';
|
||||
print '<td width="20%" colspan="2">'.$langs->trans("Label").'</td>';
|
||||
print '<td colspan="2">';
|
||||
print '<input type="text" name="label" size="40" value="'.GETPOST("label").'">';
|
||||
print '</td>';
|
||||
print '<td width="20%">'.$langs->trans("UnitPurchaseValue").'</td><td width="20%"><input class="flat" name="price" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
//eat-by date
|
||||
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) {
|
||||
print '<tr>';
|
||||
print '<td width="15%">'.$langs->trans("l_eatby").'</td><td width="15%">';
|
||||
$form->select_date('','eatby','','',1,"");
|
||||
print '</td>';
|
||||
print '<td width="15%">'.$langs->trans("l_sellby").'</td><td width="15%">';
|
||||
$form->select_date('','sellby','','',1,"");
|
||||
print '</td>';
|
||||
print '<td width="15%">'.$langs->trans("batch_number").'</td><td width="15%">';
|
||||
print '<input type="text" name="batch_number" size="40" value="'.GETPOST("batch_number").'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"> ';
|
||||
@ -513,7 +565,7 @@ if (empty($action) && $product->id)
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&action=correction">'.$langs->trans("StockCorrection").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->stock->mouvement->creer)
|
||||
if (($user->rights->stock->mouvement->creer) && !$product->hasbatch())
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&action=transfert">'.$langs->trans("StockMovement").'</a>';
|
||||
}
|
||||
@ -528,15 +580,22 @@ if (empty($action) && $product->id)
|
||||
* Contenu des stocks
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="40%">'.$langs->trans("Warehouse").'</td>';
|
||||
print '<tr class="liste_titre"><td width="40%" colspan="4">'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td align="right">'.$langs->trans("NumberOfUnit").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AverageUnitPricePMPShort").'</td>';
|
||||
print '<td align="right">'.$langs->trans("EstimatedStockValueShort").'</td>';
|
||||
print '<td align="right">'.$langs->trans("SellPriceMin").'</td>';
|
||||
print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>';
|
||||
print '</tr>';
|
||||
if ( (! empty($conf->productbatch->enabled)) && $product->hasbatch()) {
|
||||
print '<tr class="liste_titre"><td width="10%"></td><td align="right" width="10%">'.$langs->trans("l_eatby").'</td>';
|
||||
print '<td align="right" width="10%">'.$langs->trans("l_sellby").'</td>';
|
||||
print '<td align="right" width="10%">'.$langs->trans("batch_number").'</td>';
|
||||
print '<td align="right" colspan="5"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp";
|
||||
$sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp, ps.rowid as product_stock_id";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= " WHERE ps.reel != 0";
|
||||
@ -561,7 +620,7 @@ if ($resql)
|
||||
$entrepotstatic->id=$obj->rowid;
|
||||
$entrepotstatic->libelle=$obj->label;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$entrepotstatic->getNomUrl(1).'</td>';
|
||||
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
|
||||
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>';
|
||||
// PMP
|
||||
print '<td align="right">'.(price2num($obj->pmp)?price2num($obj->pmp,'MU'):'').'</td>'; // Ditto : Show PMP from movement or from product
|
||||
@ -579,12 +638,24 @@ if ($resql)
|
||||
if (price2num($obj->pmp)) $totalwithpmp += $obj->reel;
|
||||
$totalvalue = $totalvalue + price2num($obj->pmp*$obj->reel,'MU'); // Ditto : Show PMP from movement or from product
|
||||
$totalvaluesell = $totalvaluesell + price2num($product->price*$obj->reel,'MU'); // Ditto : Show PMP from movement or from product
|
||||
//Batch Detail
|
||||
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) {
|
||||
$details=Productbatch::findAll($db,$obj->product_stock_id);
|
||||
if ($details<0) dol_print_error($db);
|
||||
foreach ($details as $pdluo) {
|
||||
print "\n".'<tr><td width="10%"></td><td width="10%" align="right">'. dol_print_date($pdluo->eatby,'day') .'</td>';
|
||||
print '<td align="right" width="10%">'. dol_print_date($pdluo->sellby,'day') .'</td>';
|
||||
print '<td align="right" width="10%">'.$pdluo->batch.'</td>';
|
||||
print '<td align="right" width="10%">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>';
|
||||
print '<td colspan="4" width="50%"></td></tr>';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
print '<tr class="liste_total"><td align="right" class="liste_total">'.$langs->trans("Total").':</td>';
|
||||
print '<tr class="liste_total"><td align="right" class="liste_total" colspan="4">'.$langs->trans("Total").':</td>';
|
||||
print '<td class="liste_total" align="right">'.$total.'</td>';
|
||||
print '<td class="liste_total" align="right">';
|
||||
print ($totalwithpmp?price($totalvalue/$totalwithpmp):' ');
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
|
||||
$langs->load("projects");
|
||||
@ -81,7 +82,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("ThirdParties"),"index.php","s.nom","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ThirdParties"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
@ -132,25 +133,14 @@ else
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div></div></div>';
|
||||
|
||||
|
||||
// Tasks for all resources of all opened projects and time spent for each task/resource
|
||||
print '<div class="fichecenter">';
|
||||
print '<BR>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
|
||||
print '<th>'.$langs->trans('Projects').'</th>';
|
||||
print '<th>'.$langs->trans('Task').'</th>';
|
||||
print '<th>'.$langs->trans('DateStart').'</th>';
|
||||
print '<th>'.$langs->trans('DateEnd').'</th>';
|
||||
print '<th>'.$langs->trans('WorkloadOccupation').'</th>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, tasktime.task_duration";
|
||||
$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
|
||||
@ -160,6 +150,7 @@ $sql.= " WHERE p.entity = ".$conf->entity;
|
||||
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
$sql.= " AND p.fk_statut=1";
|
||||
$sql.= " GROUP BY p.title, p.rowid, t.label, t.rowid, u.rowid, t.planned_workload, t.dateo, t.datee";
|
||||
$sql.= " ORDER BY u.rowid, t.dateo, t.datee";
|
||||
|
||||
$userstatic=new User($db);
|
||||
@ -171,32 +162,66 @@ if ( $resql )
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
if ($num > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
/* print '<tr '.$bc[0].'>';
|
||||
print '<td colspan="9">';
|
||||
print $langs->trans("TooManyDataPleaseUseMoreFilters");
|
||||
print '</td></tr>';*/
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
$username='';
|
||||
$userstatic->fetch($obj->userid);
|
||||
if (!empty($userstatic->id)) {
|
||||
$username = $userstatic->getNomUrl(0,0);
|
||||
print_fiche_titre($langs->trans("TimeSpent"),'','').'<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
|
||||
print '<th>'.$langs->trans('Projects').'</th>';
|
||||
print '<th>'.$langs->trans('Task').'</th>';
|
||||
print '<th>'.$langs->trans('DateStart').'</th>';
|
||||
print '<th>'.$langs->trans('DateEnd').'</th>';
|
||||
print '<th>'.$langs->trans('TimeSpent').'</th>';
|
||||
print '</tr>';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
$username='';
|
||||
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
|
||||
{
|
||||
$result=$userstatic->fetch($obj->userid);
|
||||
if (! $result) $userstatic->id=0;
|
||||
}
|
||||
if ($userstatic->id) $username = $userstatic->getNomUrl(0,0);
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td>'.$username.'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->projectid.'">'.$obj->title.'</a></td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';
|
||||
/* I disable this because information is wrong. This percent has no meaning for a particular resource. What do we want ?
|
||||
* Percent of completion ?
|
||||
* If we want to show completion, we must remove "user" into list,
|
||||
if (empty($obj->planned_workload)) {
|
||||
$percentcompletion = $langs->trans("Unknown");
|
||||
} else {
|
||||
$percentcompletion = intval($obj->task_duration*100/$obj->planned_workload);
|
||||
}*/
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
|
||||
//print $percentcompletion.' %';
|
||||
print convertSecondToTime($obj->timespent, 'all');
|
||||
print '</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td>'.$username.'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->projectid.'">'.$obj->title.'</a></td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';
|
||||
if (empty($obj->planned_workload)) {
|
||||
$percentcompletion = '0';
|
||||
} else {
|
||||
$percentcompletion = intval(($obj->task_duration*100)/$obj->planned_workload);
|
||||
}
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">'.$percentcompletion.' %</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
@ -205,12 +230,12 @@ else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
print "</table></div>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
?>
|
||||
@ -47,17 +47,15 @@ $object = new Project($db);
|
||||
$taskstatic = new Task($db);
|
||||
$extrafields_project = new ExtraFields($db);
|
||||
$extrafields_task = new ExtraFields($db);
|
||||
if ($ref)
|
||||
if ($id > 0 || $ref)
|
||||
{
|
||||
$object->fetch(0,$ref);
|
||||
$object->fetch($id,$ref);
|
||||
$id=$object->id;
|
||||
}
|
||||
$ref=$object->ref;
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
if (!empty($id)) {
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element);
|
||||
$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element);
|
||||
|
||||
}
|
||||
|
||||
// Security check
|
||||
@ -295,7 +293,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
|
||||
|
||||
// List of projects
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfTask").'</td><td>';
|
||||
print $formother->selectProjectTasks('',$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1);
|
||||
print $formother->selectProjectTasks(GETPOST('task_parent'),$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
|
||||
@ -351,11 +349,11 @@ else
|
||||
{
|
||||
/*
|
||||
* Fiche projet en mode visu
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
|
||||
@ -424,12 +422,12 @@ else
|
||||
if (count($tasksarray) > 0)
|
||||
{
|
||||
// Show all lines in taskarray (recursive function to go down on tree)
|
||||
$j=0;
|
||||
$j=0; $level=0;
|
||||
$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $id, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="'.(! empty($object->id) ? "5" : "4").'">'.$langs->trans("NoTasks").'</td></tr>';
|
||||
print '<tr><td colspan="9">'.$langs->trans("NoTasks").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
|
||||
@ -60,12 +60,12 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
|
||||
$timespent_durationmin = GETPOST('timespent_durationmin','int');
|
||||
if (empty($timespent_durationhour) && empty($timespent_durationmin))
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>';
|
||||
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")),'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($_POST["userid"]))
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorUserNotAffectedToTask').'</div>';
|
||||
setEventMessage($langs->trans('ErrorUserNotAffectedToTask'),'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -82,11 +82,12 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
|
||||
$result=$object->addTimeSpent($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
|
||||
setEventMessage($langs->trans("RecordSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
|
||||
setEventMessage($langs->trans($object->error),'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -101,7 +102,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
|
||||
|
||||
if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"]))
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>';
|
||||
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")),'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -120,11 +121,12 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
|
||||
$result=$object->updateTimeSpent($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
|
||||
setEventMessage($langs->trans("RecordSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
|
||||
setEventMessage($langs->trans($object->error),'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -141,7 +143,8 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->c
|
||||
if (!$result)
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
|
||||
setEventMessage($langs->trans($object->error),'errors');
|
||||
$error++;
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,9 +178,10 @@ class UserGroup extends CommonObject
|
||||
* Return array of users id for group this->id (or all if this->id not defined)
|
||||
*
|
||||
* @param string $excludefilter Filter to exclude
|
||||
* @param int $mode 0=Return array of user instance, 1=Return array of users id only
|
||||
* @return array Array of users
|
||||
*/
|
||||
function listUsersForGroup($excludefilter='')
|
||||
function listUsersForGroup($excludefilter='', $mode=0)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
@ -211,11 +212,15 @@ class UserGroup extends CommonObject
|
||||
{
|
||||
if (! array_key_exists($obj->rowid, $ret))
|
||||
{
|
||||
$newuser=new User($this->db);
|
||||
$newuser->fetch($obj->rowid);
|
||||
$ret[$obj->rowid]=$newuser;
|
||||
if ($mode != 1)
|
||||
{
|
||||
$newuser=new User($this->db);
|
||||
$newuser->fetch($obj->rowid);
|
||||
$ret[$obj->rowid]=$newuser;
|
||||
}
|
||||
else $ret[$obj->rowid]=$obj->rowid;
|
||||
}
|
||||
if (! empty($obj->usergroup_entity))
|
||||
if ($mode != 1 && ! empty($obj->usergroup_entity))
|
||||
{
|
||||
$ret[$obj->rowid]->usergroup_entity[]=$obj->usergroup_entity;
|
||||
}
|
||||
@ -744,4 +749,4 @@ class UserGroup extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
@ -76,13 +76,16 @@ class AllTests
|
||||
$suite->addTestSuite('JsonLibTest');
|
||||
require_once dirname(__FILE__).'/ImagesLibTest.php';
|
||||
$suite->addTestSuite('ImagesLibTest');
|
||||
require_once dirname(__FILE__).'/FunctionsTest.php';
|
||||
$suite->addTestSuite('FunctionsTest');
|
||||
require_once dirname(__FILE__).'/Functions2Test.php';
|
||||
$suite->addTestSuite('Functions2Test');
|
||||
require_once dirname(__FILE__).'/FunctionsLibTest.php';
|
||||
$suite->addTestSuite('FunctionsLibTest');
|
||||
require_once dirname(__FILE__).'/Functions2LibTest.php';
|
||||
$suite->addTestSuite('Functions2LibTest');
|
||||
require_once dirname(__FILE__).'/XCalLibTest.php';
|
||||
$suite->addTestSuite('XCalLibTest');
|
||||
|
||||
require_once dirname(__FILE__).'/LangTest.php';
|
||||
$suite->addTestSuite('LangTest');
|
||||
|
||||
require_once dirname(__FILE__).'/SecurityTest.php';
|
||||
$suite->addTestSuite('SecurityTest');
|
||||
|
||||
@ -168,6 +171,9 @@ class AllTests
|
||||
require_once dirname(__FILE__).'/ScriptsTest.php';
|
||||
$suite->addTestSuite('ScriptsTest');
|
||||
|
||||
require_once dirname(__FILE__).'/FormAdminTest.php';
|
||||
$suite->addTestSuite('FormAdminTest');
|
||||
|
||||
require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer
|
||||
$suite->addTestSuite('ModulesTest');
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file test/phpunit/FunctionsTest.php
|
||||
* \file test/phpunit/Functions2LibTest.php
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
@ -48,7 +48,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class Functions2Test extends PHPUnit_Framework_TestCase
|
||||
class Functions2LibTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
@ -128,20 +128,20 @@ class Functions2Test extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('νεο',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* isValidMailDomain
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsValidMailDomain()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* isValidURL
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsValidUrl()
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file test/phpunit/FunctionsTest.php
|
||||
* \file test/phpunit/FunctionsLibTest.php
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
@ -48,7 +48,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class FunctionsTest extends PHPUnit_Framework_TestCase
|
||||
class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
177
test/phpunit/LangTest.php
Executable file
177
test/phpunit/LangTest.php
Executable file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file test/phpunit/LangTest.php
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
|
||||
|
||||
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class LangTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return SecurityTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testBank
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function testLang()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||
|
||||
$filesarray = scandir(DOL_DOCUMENT_ROOT.'/langs');
|
||||
foreach($filesarray as $key => $code)
|
||||
{
|
||||
if (! preg_match('/^[a-z]+_[A-Z]+$/',$code)) continue;
|
||||
|
||||
print 'Check language file for code='.$code."\n";
|
||||
$tmplangs=new Translate('',$conf);
|
||||
$langcode=$code;
|
||||
$tmplangs->setDefaultLang($langcode);
|
||||
$tmplangs->load("main");
|
||||
|
||||
$result=$tmplangs->trans("SeparatorDecimal");
|
||||
print __METHOD__." SeparatorDecimal=".$result."\n";
|
||||
$this->assertContains($result,array('.',',','/',' ','','None'));
|
||||
|
||||
$result=$tmplangs->trans("SeparatorThousand");
|
||||
print __METHOD__." SeparatorThousand=".$result."\n";
|
||||
$this->assertContains($result,array('.',',','/',' ','','None','SeparatorThousand')); // SeparatorThousand is returned when SeparatorThousand=Space
|
||||
|
||||
// Test java string contains only d,M,y,/,-,. and not m,...
|
||||
$result=$tmplangs->trans("FormatDateShortJava");
|
||||
print __METHOD__." FormatDateShortJava=".$result."\n";
|
||||
$this->assertRegExp('/^[dMy\/\-\.]+$/',$result);
|
||||
$result=$tmplangs->trans("FormatDateShortJavaInput");
|
||||
print __METHOD__." FormatDateShortJavaInput=".$result."\n";
|
||||
$this->assertRegExp('/^[dMy\/\-\.]+$/',$result);
|
||||
|
||||
unset($tmplangs);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user