Merge remote-tracking branch 'Upstream/develop' into develop-Devcamp

This commit is contained in:
aspangaro 2015-04-22 07:18:52 +02:00
commit b35c929cad
69 changed files with 1471 additions and 217 deletions

91
.mailmap Normal file
View File

@ -0,0 +1,91 @@
# This is mapping list between real user name/email and entry into sources files
# If you don't want to have your real email appears here, just send a Pull Request to
# replace the second field between <> with <secret>
Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <eldy@users.sourceforge.net>
Laurent Destailleur <eldy@destailleur.fr> eldy <eldy@destailleur.fr>
Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <ldestailleur@teclib.com>
Laurent Destailleur <eldy@destailleur.fr> eldy10 <eldy10@master8.(none)>
Laurent Destailleur <eldy@destailleur.fr> Laurent Destailleur <ephpcsdy@destailleur.fr>
Regis Houssin <regis.houssin@capnetworks.com> Regis Houssin <regis@dolibarr.fr>
Regis Houssin <regis.houssin@capnetworks.com> Régis Houssin <regishoussin@device5.home>
Juanjo Menent <jmenent@2byte.es> simnandez <jmenent@2byte.es>
Juanjo Menent <jmenent@2byte.es> Juanjo Menent <simnandez@gmail.com>
Juanjo Menent <jmenent@2byte.es> Simnandez <jmenent@2byte.es>
Juanjo Menent <jmenent@2byte.es> juanjo <juanjo@samsung>
Juanjo Menent <jmenent@2byte.es> juanjo <juanjo@alienware>
Marcos García de La Fuente <marcosgdf@gmail.com> Marcos García <marcosgdf@gmail.com>
Marcos García de La Fuente <marcosgdf@gmail.com> Marcos García <marcosgdf@gmail.com>
Florian Henry <florian.henry@open-concept.pro> fhenry <florian.henry@open-concept.pro>
Florian Henry <florian.henry@open-concept.pro> Florian HENRY <florian.henry@open-concept.pro>
Florian Henry <florian.henry@open-concept.pro> FHenry <florian.henry.mail@gmail.com>
Florian Henry <florian.henry@open-concept.pro> Florian HENRY <florian.henry@open-conept.pro>
Florian Henry <florian.henry@open-concept.pro> FHenry <florian.henry@open-concept.pro>
Florian Henry <florian.henry@open-concept.pro> HENRY Florian <florian.henry@open-concept.pro>
Alexandre Spangaro <alexandre.spangaro@gmail.com> aspangaro <alexandre.spangaro@gmail.com>
Alexandre Spangaro <alexandre.spangaro@gmail.com> Spangaro Alexandre <alexandre.spangaro@gmail.com>
Alexandre Spangaro <alexandre.spangaro@gmail.com> Alexandre SPANGARO <alexandre.spangaro@gmail.com>
Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> Raphaël Doursenaud <rdoursenaud@free.fr>
Philippe Grand <philippe.grand@atoo-net.com> Grand Philippe <contact@atoo-net.com>
Philippe Grand <philippe.grand@atoo-net.com> Philippe GRAND <philippe.grand@atoo-net.com>
Philippe Grand <philippe.grand@atoo-net.com> philippe grand <philippe.grand@atoo-net.com>
Philippe Grand <philippe.grand@atoo-net.com> philippe <philippe.grand@atoo-net.com>
Philippe Grand <philippe.grand@atoo-net.com> unknown <Philippe@grandoc.(none)>
Philippe Grand <philippe.grand@atoo-net.com> philippe <philippe@PC-de-philippe>
Philippe Grand <philippe.grand@atoo-net.com> Philippe Grand <contact@atoo-net.com>
Jean-François Ferry <jfefe@aternatik.fr> jfefe <jfefe@aternatik.fr>
Jean-François Ferry <jfefe@aternatik.fr> jfefe <jf.ferry@aternatik.fr>
Jean-François Ferry <jfefe@aternatik.fr> JF FERRY <jfefe@aternatik.fr>
Jean-François Ferry <jfefe@aternatik.fr> JF FERRY <meos@devmachine.(none)>
Charles Benke <charles.fr@benke.fr> BENKE Charles <charles.fr@benke.fr>
Charles Benke <charles.fr@benke.fr> BENKE Charlie <charles.fr@benke.fr>
Charles Benke <charles.fr@benke.fr> defrance69 <charles.fr@benke.fr>
Maxime Kohlhaas <mko@atm-consulting.fr> MAxime Kohlhaas <maxime@atm-consulting.fr>
Frédéric France <frederic.france@free.fr> Frédéric FRANCE <frederic.france@free.fr>
Frédéric France <frederic.france@free.fr> frederic34 <frederic.france@free.fr>
Frédéric France <frederic.france@free.fr> FRANCE Frédéric <frederic.france@free.fr>
Frédéric France <frederic.france@free.fr> frederic34 <fred@ubuntuserver.(none)>
Cyrille de Lambert <cyrille.delambert@auguria.net> cdelambert <cdelambert>
Cédric Gross <c.gross@kreiz-it.fr> KreizIT <KreizIT@users.noreply.github.com>
Cédric Gross <c.gross@kreiz-it.fr> Cedric <c.gross@kreiz-it.fr>
Cédric Gross <c.gross@kreiz-it.fr> Cedric GROSS <c.gross@kreiz-it.fr>
Jean Heimburger <jean@tiaris.info> jean <jean@tiaris.info>
Jean Heimburger <jean@tiaris.info> tiaris <tiaris>
Benoit Mortier <benoit.mortier@opensides.be> opensides <opensides>
Eric Seigne <contact@ryxeo.com> erics <erics>
Jean-Louis Bergamo <jl@bergamo.fr> jlb <jlb>
Remco Gerbrands <remco@artoge.nl> r2gnl <r2gnl>
Phf <phf@atm-consulting.fr> phf <phf@atm-consulting.fr>
Yannick Warnier <ywarnier@beeznest.org> ywarnier <ywarnier>
Jerome Warnier <jwarnier@beeznest.org> jwarnier <jwarnier>
Franky Van Liedekerke <liedekef@telenet.be> liedekef <liedekef>
Lalaina Rasamoelina <lalaina.rasamoelina@biblibre.com> lalaina rasamoelina <lalaina.rasamoelina@biblibre.com>
Marc Ocebo <marc_ocebo> marc_ocebo <marc_ocebo>
Unknown <secret> box7890 <box7890>
Unknown <secret> beedauchon <beedauchon>
Loic <secret> loic <loic>
Christophe Combelle <ccomb>
Unknown <secret> activdev <activdev>
Unknown <secret> bouba <bouba>
Unknown <secret> bcroq <bcroq>
Unknown <secret> dutoit <dutoit>
Unknown <secret> bureau2crea <bureau2crea>
Unknown <secret> unknown <mne02@.modula71.local>
Simon Tosser <secret> simontosser <simontosser>
Unknown <secret> tipaul <tipaul>
Raphaël Bertrand <secret> raphael_bertrand <raphael_bertrand>
Claudio Aschieri <c.aschieri@19.coop> cla <c.aschieri@19.coop>
Tommaso Basilici <t.basilici@19.coop> kaos <t.basilici@19.coop>
Tommaso Basilici <t.basilici@19.coop> Tommaso Basilici <t.basilici@19.coop>
Faust <faust@19.coop> faust <faust@19.coop>
Ferran Marcet <secret> fmarcet <fmarcet@imedia>
Geoffrey Girard <geoffre.girard@atm-consulting.fr> geoffrey.girard <geoffre.girard@atm-consulting.fr>
Bernard Paquier <eshop.bpaquier@gmail.com> BadPixxel <eshop.bpaquier@gmail.com>
Patrick Delcroix <delcroip@gmail.com> delcroix Patrick <delcroip@gmail.com>
Damien Clochard <damien@dalibo.com> damien clochard <damien@dalibo.info>
Damien Clochard <damien@dalibo.com> damien clochard <damien@dalibo.com>
Grégory David <groolot@groolot.net> Grégory DAVID <groolot@groolot.net>
Grégory David <groolot@groolot.net> Gregory DAVID <groolot@groolot.net>
Baffir Abbes <bafbes@users.noreply.github.com> bafbes <bafbes@users.noreply.github.com>
Kevin Guerrier <guerrier.k@gmail.com> GUERRIER Kevin <guerrier.k@gmail.com>
Remy Younes <ryounes@gmail.com> remy <ryounes@gmail.com>
Estephe Loridan <github@estephe.me> Estephe L. <github@estephe.me>

View File

@ -66,7 +66,24 @@ before_script:
- sh -c "if [ '$PHPV' = '5.4' ]; then echo 'zend_extension_ts = xdebug.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- cat ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- echo Mysql version
# INSTALL MYSQL 5.6
# (https://github.com/piwik/piwik/commit/20bd2e1c24e5d673dce3feb256204ad48c29f160)
# TODO: Remove when mysql 5.6 is provided by travis.
# Otherwise, our migrations will raise a syntax error.
- "sudo apt-get remove mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5"
- "sudo apt-get autoremove"
- "sudo apt-get install libaio1"
- "wget -O mysql-5.6.14.deb http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-x86_64.deb/from/http://cdn.mysql.com/"
- "sudo dpkg -i mysql-5.6.14.deb"
- "sudo cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server"
- "sudo ln -s /opt/mysql/server-5.6/bin/* /usr/bin/"
- "sudo sed -i'' 's/table_cache/table_open_cache/' /etc/mysql/my.cnf"
- "sudo sed -i'' 's/log_slow_queries/slow_query_log/' /etc/mysql/my.cnf"
- "sudo sed -i'' 's/basedir[^=]\\+=.*$/basedir = \\/opt\\/mysql\\/server-5.6/' /etc/mysql/my.cnf"
- "sudo /etc/init.d/mysql.server start"
- mysql --version
- mysql -e "SELECT VERSION();"
# /END MYSQL 5.6- mysql --version
- echo Init database
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS myapp_test;' -U postgres; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE myapp_test;' -U postgres; fi"
@ -90,7 +107,6 @@ before_script:
- echo Install apache server
- sudo apt-get update
- sudo apt-get install -y --force-yes apache2 libapache2-mod-php5 php5-curl php5-mysql php5-pgsql php5-intl
- sudo apt-get install mysql-server-5.6 mysql-client-5.6
- sudo sed -i -e "s,/var/www,$(pwd)/htdocs,g" /etc/apache2/sites-available/default
- echo Show default virtual host
- sudo cat /etc/apache2/sites-available/default
@ -112,9 +128,9 @@ script:
- php upgrade.php 3.6.0 3.7.0 ignoredbversion > upgrade360370.log
- php upgrade2.php 3.6.0 3.7.0 ignoredbversion > upgrade360370-2.log
- php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log
- cat upgrade370380.log
# - cat upgrade370380.log
- php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log
- cat upgrade370380-2.log
# - cat upgrade370380-2.log
- cd ../..
- date
- phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php

View File

@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,0,25);
$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,0,25,0,26);
// Name of SQL tables of dictionaries
$tabname=array();
@ -99,6 +99,7 @@ $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
$tabname[23]= MAIN_DB_PREFIX."c_revenuestamp";
$tabname[24]= MAIN_DB_PREFIX."c_type_resource";
$tabname[25]= MAIN_DB_PREFIX."c_email_templates";
$tabname[26]= MAIN_DB_PREFIX."c_units";
// Dictionary labels
$tablib=array();
@ -127,6 +128,7 @@ $tablib[22]= "DictionarySource";
$tablib[23]= "DictionaryRevenueStamp";
$tablib[24]= "DictionaryResourceType";
$tablib[25]= "DictionaryEMailTemplates";
$tablib[26]= "DictionnaryUnits";
// Requests to extract data
$tabsql=array();
@ -155,6 +157,7 @@ $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
$tabsql[23]= "SELECT t.rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates";
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
// Criteria to sort dictionaries
$tabsqlsort=array();
@ -183,6 +186,7 @@ $tabsqlsort[22]="code ASC, label ASC";
$tabsqlsort[23]="country ASC, taux ASC";
$tabsqlsort[24]="code ASC,label ASC";
$tabsqlsort[25]="label ASC";
$tabsqlsort[26]="code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@ -211,6 +215,7 @@ $tabfield[22]= "code,label";
$tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24]= "code,label";
$tabfield[25]= "label,type_template,private,position,topic,content";
$tabfield[26]= "code,label,short_label";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@ -239,6 +244,7 @@ $tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24]= "code,label";
$tabfieldvalue[25]= "label,type_template,private,position,topic,content";
$tabfieldvalue[26]= "code,label,short_label";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@ -267,6 +273,7 @@ $tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24]= "code,label";
$tabfieldinsert[25]= "label,type_template,private,position,topic,content";
$tabfieldinsert[26]= "code,label,short_label";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@ -297,6 +304,7 @@ $tabrowid[22]= "rowid";
$tabrowid[23]= "";
$tabrowid[24]= "";
$tabrowid[25]= "";
$tabrowid[26]= "";
// Condition to show dictionary in setup page
$tabcond=array();
@ -325,6 +333,7 @@ $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl
$tabcond[23]= true;
$tabcond[24]= ! empty($conf->resource->enabled);
$tabcond[25]= true; // && ! empty($conf->global->MAIN_EMAIL_EDIT_TEMPLATE_FROM_DIC);
$tabcond[26]= $conf->product->enabled;
// List of help for fields
$tabhelp=array();
@ -858,6 +867,7 @@ if ($id)
if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); }
if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); }
if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); }
if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); }
if ($id == 2) // Special cas for state page
{
@ -995,6 +1005,7 @@ if ($id)
if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); }
if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); }
if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); }
if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); }
// Affiche nom du champ
if ($showfield)
@ -1159,7 +1170,14 @@ if ($id)
else if ($fieldlist[$field]=='unicode') {
$valuetoshow = $langs->getCurrencySymbol($obj->code,1);
}
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
$langs->load("products");
$valuetoshow=$langs->trans($obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
$langs->load("products");
$valuetoshow = $langs->trans($obj->$fieldlist[$field]);
}
else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))
{
$key = $langs->trans('SizeUnit'.strtolower($obj->unit));

View File

@ -8,6 +8,7 @@
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
*
@ -451,7 +452,7 @@ if (empty($reshook))
$tva_tx=get_default_tva($mysoc, $object->thirdparty);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit);
if ($result > 0) {
$lineid = $result;
@ -726,6 +727,7 @@ if (empty($reshook))
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
// Replaces $fk_unit with the product unit
if (! empty($idprod)) {
$prod = new Product($db);
$prod->fetch($idprod);
@ -834,6 +836,7 @@ if (empty($reshook))
}
$type = $prod->type;
$fk_unit = $prod->fk_unit;
} else {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
@ -842,6 +845,8 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit = GETPOST('units', 'alpha');
}
// Margin
@ -864,7 +869,7 @@ if (empty($reshook))
setEventMessage($mesg, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit);
if ($result > 0) {
$db->commit();
@ -898,6 +903,7 @@ if (empty($reshook))
unset($_POST['np_markRate']);
unset($_POST['dp_desc']);
unset($_POST['idprod']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
@ -992,7 +998,7 @@ if (empty($reshook))
if (! $error) {
$db->begin();
$result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options);
$result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"]);
if ($result >= 0) {
$db->commit();
@ -1374,7 +1380,7 @@ if ($action == 'create')
$absolute_discount = $soc->getAvailableDiscounts();
print '. ';
if ($absolute_discount)
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency" . $conf->currency));
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount, 0, $langs, 1, -1, -1, $conf->currency));
else
print $langs->trans("CompanyHasNoAbsoluteDiscount");
print '.';
@ -1516,18 +1522,18 @@ if ($action == 'create')
$newclassname = 'Intervention';
print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td colspan="2">' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td colspan="2">' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1) . "</td></tr>";
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
}
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>";
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
}
print "</table>\n";
@ -1990,7 +1996,7 @@ if ($action == 'create')
print $langs->trans('OutstandingBill');
print '</td><td align=right colspan=3>';
print price($soc->get_OutstandingBill()) . ' / ';
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency);
print '</td>';
print '</tr>';
}
@ -2044,7 +2050,7 @@ if ($action == 'create')
// Amount HT
print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>';
print '<td align="right" class="nowrap" colspan="2"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
print '<td class="nowrap" colspan="2">' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
// Margin Infos
if (! empty($conf->margin->enabled)) {
@ -2056,26 +2062,26 @@ if ($action == 'create')
// Amount VAT
print '<tr><td height="10">' . $langs->trans('AmountVAT') . '</td>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
{
print '<tr><td height="10">' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2
{
print '<tr><td height="10">' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
}
// Amount TTC
print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>';
print '<td align="right" class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
// Statut

View File

@ -9,6 +9,7 @@
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
*
@ -32,6 +33,7 @@
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php";
require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
@ -284,6 +286,7 @@ class Propal extends CommonObject
$line->subprice=$price;
$line->remise_percent=$remise_percent;
$line->tva_tx=$tva_tx;
$line->fk_unit=$prod->fk_unit;
$this->lines[]=$line;
}
@ -396,11 +399,12 @@ class Propal extends CommonObject
* @param int $date_start Start date of the line
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int >0 if OK, <0 if KO
*
* @see add_product
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null)
{
global $mysoc;
@ -497,6 +501,7 @@ class Propal extends CommonObject
$this->line->product_type=$type;
$this->line->special_code=$special_code;
$this->line->fk_parent_line=$fk_parent_line;
$this->line->fk_unit=$fk_unit;
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
@ -578,9 +583,10 @@ class Propal extends CommonObject
* @param int $date_start Start date of the line
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int 0 if OK, <0 if KO
*/
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0)
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
{
global $mysoc;
@ -662,6 +668,7 @@ class Propal extends CommonObject
$this->line->special_code = $special_code;
$this->line->fk_parent_line = $fk_parent_line;
$this->line->skip_update_total = $skip_update_total;
$this->line->fk_unit = $fk_unit;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
@ -914,7 +921,8 @@ class Propal extends CommonObject
$this->lines[$i]->label,
$this->lines[$i]->date_start,
$this->lines[$i]->date_end,
$this->lines[$i]->array_options
$this->lines[$i]->array_options,
$this->lines[$i]->fk_unit
);
if ($result < 0)
@ -1286,6 +1294,7 @@ class Propal extends CommonObject
*/
$sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,";
$sql.= " d.fk_unit,";
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' d.date_start, d.date_end';
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
@ -1348,6 +1357,7 @@ class Propal extends CommonObject
$line->product_label = $objp->product_label;
$line->product_desc = $objp->product_desc; // Description produit
$line->fk_product_type = $objp->fk_product_type;
$line->fk_unit = $objp->fk_unit;
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
@ -1913,7 +1923,7 @@ class Propal extends CommonObject
if ( ! $error )
{
$this->statut = $statut;
$this->db->commit();
return 1;
}
@ -2770,6 +2780,7 @@ class Propal extends CommonObject
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
$sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,';
$sql.= ' pt.fk_unit,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
$sql.= ' p.description as product_desc,';
$sql.= ' p.entity';
@ -2820,6 +2831,7 @@ class Propal extends CommonObject
$this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->date_start = $this->db->jdate($obj->date_start);
$this->lines[$i]->date_end = $this->db->jdate($obj->date_end);
$this->lines[$i]->fk_unit = $obj->fk_unit;
$i++;
}
@ -2891,7 +2903,7 @@ class Propal extends CommonObject
* \class PropaleLigne
* \brief Class to manage commercial proposal lines
*/
class PropaleLigne extends CommonObject
class PropaleLigne extends CommonObjectLine
{
public $element='propaldet';
public $table_element='propaldet';
@ -2981,6 +2993,7 @@ class PropaleLigne extends CommonObject
$sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,';
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,';
$sql.= ' pd.fk_unit,';
$sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,';
$sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,';
$sql.= ' pd.date_start, pd.date_end, pd.product_type';
@ -3028,6 +3041,7 @@ class PropaleLigne extends CommonObject
$this->libelle = $objp->product_label; // deprecated
$this->product_label = $objp->product_label;
$this->product_desc = $objp->product_desc;
$this->fk_unit = $objp->fk_unit;
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
@ -3090,6 +3104,7 @@ class PropaleLigne extends CommonObject
$sql.= ' subprice, remise_percent, ';
$sql.= ' info_bits, ';
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,';
$sql.= ' fk_unit,';
$sql.= ' date_start, date_end)';
$sql.= " VALUES (".$this->fk_propal.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
@ -3116,6 +3131,7 @@ class PropaleLigne extends CommonObject
$sql.= " ".(isset($this->pa_ht)?"'".price2num($this->pa_ht)."'":"null").",";
$sql.= ' '.$this->special_code.',';
$sql.= ' '.$this->rang.',';
$sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit).',';
$sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= ')';
@ -3281,6 +3297,7 @@ class PropaleLigne extends CommonObject
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
$sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog(get_class($this)."::update", LOG_DEBUG);

View File

@ -8,6 +8,7 @@
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
@ -348,7 +349,7 @@ if (empty($reshook))
$array_options = $lines[$i]->array_options;
}
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit);
if ($result < 0) {
$error++;
@ -713,6 +714,7 @@ if (empty($reshook))
}
$type = $prod->type;
$fk_unit = $prod->fk_unit;
} else {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
@ -721,6 +723,7 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit=GETPOST('units', 'alpha');
}
// Margin
@ -742,7 +745,7 @@ if (empty($reshook))
setEventMessage($mesg, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit);
if ($result > 0) {
$ret = $object->fetch($object->id); // Reload to get new records
@ -778,6 +781,7 @@ if (empty($reshook))
unset($_POST['np_markRate']);
unset($_POST['dp_desc']);
unset($_POST['idprod']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
@ -867,7 +871,7 @@ if (empty($reshook))
}
if (! $error) {
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options);
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options, GETPOST('units'));
if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {

View File

@ -6,6 +6,7 @@
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
*
@ -29,6 +30,7 @@
* \brief Fichier des classes de commandes
*/
include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php';
require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php";
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
@ -802,7 +804,8 @@ class Commande extends CommonOrder
$this->lines[$i]->fk_fournprice,
$this->lines[$i]->pa_ht,
$this->lines[$i]->label,
$this->lines[$i]->array_options
$this->lines[$i]->array_options,
$this->lines[$i]->fk_unit
);
if ($result < 0)
{
@ -1062,6 +1065,7 @@ class Commande extends CommonOrder
$line->rang = $object->lines[$i]->rang;
$line->special_code = $object->lines[$i]->special_code;
$line->fk_parent_line = $object->lines[$i]->fk_parent_line;
$line->fk_unit = $object->lines[$i]->fk_unit;
$line->date_start = $object->lines[$i]->date_start;
$line->date_end = $object->lines[$i]->date_end;
@ -1165,6 +1169,7 @@ class Commande extends CommonOrder
* @param int $pa_ht Buying price (without tax)
* @param string $label Label
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int >0 if OK, <0 if KO
*
* @see add_product
@ -1174,11 +1179,11 @@ class Commande extends CommonOrder
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null)
{
global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG);
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type, fk_unit=$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1295,6 +1300,7 @@ class Commande extends CommonOrder
$this->line->product_type=$type;
$this->line->special_code=$special_code;
$this->line->fk_parent_line=$fk_parent_line;
$this->line->fk_unit=$fk_unit;
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
@ -1398,6 +1404,7 @@ class Commande extends CommonOrder
$line->ref=$prod->ref;
$line->libelle=$prod->libelle;
$line->product_desc=$prod->description;
$line->fk_unit=$prod->fk_unit;
// Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
// Save the start and end date of the line in the object
@ -1654,6 +1661,7 @@ class Commande extends CommonOrder
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx,';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
$sql.= ' l.fk_unit,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
@ -1711,6 +1719,7 @@ class Commande extends CommonOrder
$line->product_label = $objp->product_label;
$line->product_desc = $objp->product_desc;
$line->fk_product_type = $objp->fk_product_type; // Produit ou service
$line->fk_unit = $objp->fk_unit;
$line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);
@ -2420,9 +2429,10 @@ class Commande extends CommonOrder
* @param string $label Label
* @param int $special_code Special code (also used by externals modules!)
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
{
global $conf, $mysoc;
@ -2442,6 +2452,7 @@ class Commande extends CommonOrder
if (empty($remise)) $remise=0;
if (empty($remise_percent)) $remise_percent=0;
if (empty($special_code) || $special_code == 3) $special_code=0;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu = price2num($pu);
@ -2514,6 +2525,7 @@ class Commande extends CommonOrder
$this->line->product_type=$type;
$this->line->fk_parent_line=$fk_parent_line;
$this->line->skip_update_total=$skip_update_total;
$this->line->fk_unit=$fk_unit;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
@ -3194,6 +3206,7 @@ class Commande extends CommonOrder
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,';
$sql.= ' l.date_start, l.date_end,';
$sql.= ' l.fk_unit,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
$sql.= ' p.description as product_desc, p.stock as stock_reel,';
$sql.= ' p.entity';
@ -3243,6 +3256,7 @@ class Commande extends CommonOrder
$this->lines[$i]->pa_ht = $marginInfos[0];
$this->lines[$i]->marge_tx = $marginInfos[1];
$this->lines[$i]->marque_tx = $marginInfos[2];
$this->lines[$i]->fk_unit = $obj->fk_unit;
$i++;
}
@ -3385,6 +3399,7 @@ class OrderLine extends CommonOrderLine
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
$sql.= ' cd.fk_unit,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
$sql.= ' cd.date_start, cd.date_end';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
@ -3430,6 +3445,7 @@ class OrderLine extends CommonOrderLine
$this->libelle = $objp->product_libelle; // deprecated
$this->product_label = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
$this->fk_unit = $objp->fk_unit;
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
@ -3546,7 +3562,8 @@ class OrderLine extends CommonOrderLine
$sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
$sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end)';
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
$sql.= ' fk_unit)';
$sql.= " VALUES (".$this->fk_commande.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
@ -3575,7 +3592,8 @@ class OrderLine extends CommonOrderLine
$sql.= " '".price2num($this->total_localtax2)."',";
$sql.= " '".price2num($this->total_ttc)."',";
$sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").',';
$sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
@ -3693,6 +3711,7 @@ class OrderLine extends CommonOrderLine
$sql.= " , product_type=".$this->product_type;
$sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog(get_class($this)."::update", LOG_DEBUG);

View File

@ -1083,7 +1083,7 @@ if (empty($reshook))
$localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->client);
$localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->client);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit);
if ($result > 0) {
$lineid = $result;
@ -1125,7 +1125,7 @@ if (empty($reshook))
$product->fetch($_POST['idprod' . $i]);
$startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']);
$endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']);
$result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
$result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit);
}
}
}
@ -1271,6 +1271,7 @@ if (empty($reshook))
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
// Ecrase $base_price_type par celui du produit
// Replaces $fk_unit with the product's
if (! empty($idprod)) {
$prod = new Product($db);
$prod->fetch($idprod);
@ -1366,6 +1367,7 @@ if (empty($reshook))
}
$type = $prod->type;
$fk_unit = $prod->fk_unit;
} else {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
@ -1374,6 +1376,7 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit= GETPOST('units', 'alpha');
}
// Margin
@ -1393,7 +1396,7 @@ if (empty($reshook))
setEventMessage($mesg, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress']);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit);
if ($result > 0)
{
@ -1431,6 +1434,7 @@ if (empty($reshook))
unset($_POST['np_markRate']);
unset($_POST['dp_desc']);
unset($_POST['idprod']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
@ -1547,7 +1551,10 @@ if (empty($reshook))
// Update line
if (! $error) {
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options, GETPOST('progress'));
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'),
$date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type,
GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options, GETPOST('progress'),
$_POST['units']);
if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@ -1584,6 +1591,7 @@ if (empty($reshook))
unset($_POST['dp_desc']);
unset($_POST['idprod']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);

View File

@ -1,8 +1,9 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
@ -97,7 +98,7 @@ class FactureRec extends Facture
// Clean parameters
$this->titre=trim($this->titre);
$this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice;
$this->db->begin();
// Charge facture modele
@ -162,7 +163,8 @@ class FactureRec extends Facture
$facsrc->lines[$i]->product_type,
$facsrc->lines[$i]->rang,
$facsrc->lines[$i]->special_code,
$facsrc->lines[$i]->label
$facsrc->lines[$i]->label,
$facsrc->lines[$i]->fk_unit
);
if ($result_insert < 0)
@ -300,6 +302,7 @@ class FactureRec extends Facture
$sql.= ' l.remise, l.remise_percent, l.subprice,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
$sql.= ' l.rang, l.special_code,';
$sql.= ' l.fk_unit,';
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
@ -342,6 +345,7 @@ class FactureRec extends Facture
$line->code_ventilation = $objp->fk_code_ventilation;
$line->rang = $objp->rang;
$line->special_code = $objp->special_code;
$line->fk_unit = $objp->fk_unit;
// Ne plus utiliser
$line->price = $objp->price;
@ -411,13 +415,14 @@ class FactureRec extends Facture
* @param int $rang Position of line
* @param int $special_code Special code
* @param string $label Label of the line
* @param string $fk_unit Unit
* @return int <0 if KO, Id of line if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='')
function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null)
{
$facid=$this->id;
dol_syslog("FactureRec::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
dol_syslog("FactureRec::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Check parameters
@ -477,6 +482,7 @@ class FactureRec extends Facture
$sql.= ", total_ttc";
$sql.= ", rang";
$sql.= ", special_code";
$sql.= ", fk_unit";
$sql.= ") VALUES (";
$sql.= "'".$facid."'";
$sql.= ", ".(! empty($label)?"'".$this->db->escape($label)."'":"null");
@ -493,7 +499,8 @@ class FactureRec extends Facture
$sql.= ", '".price2num($total_tva)."'";
$sql.= ", '".price2num($total_ttc)."'";
$sql.= ", ".$rang;
$sql.= ", ".$special_code.")";
$sql.= ", ".$special_code;
$sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")";
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
if ($this->db->query($sql))
@ -573,7 +580,7 @@ class FactureRec extends Facture
return $result;
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.

View File

@ -36,6 +36,7 @@
*/
include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php';
require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php";
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
@ -484,7 +485,8 @@ class Facture extends CommonInvoice
$this->lines[$i]->label,
$this->lines[$i]->array_options,
$this->lines[$i]->situation_percent,
$this->lines[$i]->fk_prev_id
$this->lines[$i]->fk_prev_id,
$this->lines[$i]->fk_unit
);
if ($result < 0)
{
@ -538,7 +540,9 @@ class Facture extends CommonInvoice
0,
$_facrec->lines[$i]->label,
null,
$_facrec->lines[$i]->situation_percent
$_facrec->lines[$i]->situation_percent,
'',
$_facrec->lines[$i]->fk_unit
);
if ( $result_insert < 0)
@ -830,6 +834,7 @@ class Facture extends CommonInvoice
$line->rang = $object->lines[$i]->rang;
$line->special_code = $object->lines[$i]->special_code;
$line->fk_parent_line = $object->lines[$i]->fk_parent_line;
$line->fk_unit = $object->lines[$i]->fk_unit;
$line->fk_fournprice = $object->lines[$i]->fk_fournprice;
$marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht);
@ -1096,6 +1101,7 @@ class Facture extends CommonInvoice
$sql.= ' l.rang, l.special_code,';
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
$sql.= ' l.fk_unit,';
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
@ -1153,6 +1159,7 @@ class Facture extends CommonInvoice
$line->fk_parent_line = $objp->fk_parent_line;
$line->situation_percent= $objp->situation_percent;
$line->fk_prev_id = $objp->fk_prev_id;
$line->fk_unit = $objp->fk_unit;
$this->lines[$i] = $line;
@ -2093,13 +2100,14 @@ class Facture extends CommonInvoice
* @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 if KO, Id of line if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='')
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null)
{
global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline facid=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
dol_syslog(get_class($this)."::addline facid=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
@ -2201,9 +2209,9 @@ class Facture extends CommonInvoice
$this->line->info_bits=$info_bits;
$this->line->fk_remise_except=$fk_remise_except;
$this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
$this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva);
$this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1);
$this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2);
$this->line->total_tva= $total_tva;
$this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
@ -2213,6 +2221,7 @@ class Facture extends CommonInvoice
$this->line->origin_id=$origin_id;
$this->line->situation_percent = $situation_percent;
$this->line->fk_prev_id = $fk_prev_id;
$this->line->fk_unit=$fk_unit;
// infos marge
$this->line->fk_fournprice = $fk_fournprice;
@ -2274,16 +2283,17 @@ class Facture extends CommonInvoice
* @param string $label Label of the line (deprecated, do not use)
* @param int $special_code Special code (also used by externals modules!)
* @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $situation_percent Situation advance percentage
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
global $mysoc;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line", LOG_DEBUG);
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line, $fk_unit", LOG_DEBUG);
if ($this->brouillon)
{
@ -2295,7 +2305,6 @@ class Facture extends CommonInvoice
if (empty($special_code) || $special_code == 3) $special_code=0;
if ($situation_percent > 100 || is_null($situation_percent) || $situation_percent == "") $situation_percent = 100;
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
@ -2354,9 +2363,9 @@ class Facture extends CommonInvoice
$this->line->date_start = $date_start;
$this->line->date_end = $date_end;
$this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
$this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva);
$this->line->total_localtax1 = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1);
$this->line->total_localtax2 = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2);
$this->line->total_tva = $total_tva;
$this->line->total_localtax1 = $total_localtax1;
$this->line->total_localtax2 = $total_localtax2;
$this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
$this->line->info_bits = $info_bits;
$this->line->special_code = $special_code;
@ -2364,7 +2373,7 @@ class Facture extends CommonInvoice
$this->line->fk_parent_line = $fk_parent_line;
$this->line->skip_update_total = $skip_update_total;
$this->line->situation_percent = $situation_percent;
$this->line->fk_unit = $fk_unit;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
@ -3425,6 +3434,7 @@ class Facture extends CommonInvoice
$sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
$sql.= ' l.date_start, l.date_end,';
$sql.= ' l.fk_unit,';
$sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,';
$sql.= ' p.description as product_desc,';
$sql.= ' p.entity';
@ -3476,6 +3486,7 @@ class Facture extends CommonInvoice
$this->lines[$i]->pa_ht = $marginInfos[0];
$this->lines[$i]->marge_tx = $marginInfos[1];
$this->lines[$i]->marque_tx = $marginInfos[2];
$this->lines[$i]->fk_unit = $obj->fk_unit;
$i++;
}
@ -3734,6 +3745,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,';
$sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,';
$sql.= ' fd.fk_code_ventilation,';
$sql.= ' fd.fk_unit,';
$sql.= ' fd.situation_percent, fd.fk_prev_id,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd';
@ -3781,6 +3793,7 @@ class FactureLigne extends CommonInvoiceLine
$this->libelle = $objp->product_libelle; // deprecated
$this->product_label = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
$this->fk_unit = $objp->fk_unit;
$this->situation_percent = $objp->situation_percent;
$this->fk_prev_id = $objp->fk_prev_id;
@ -3868,7 +3881,8 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ' date_start, date_end, fk_code_ventilation, ';
$sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
$sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
$sql.= ' situation_percent, fk_prev_id)';
$sql.= ' situation_percent, fk_prev_id,';
$sql.= ' fk_unit)';
$sql.= " VALUES (".$this->fk_facture.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
@ -3899,6 +3913,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= " ".price2num($this->total_localtax2);
$sql .= ", " . $this->situation_percent;
$sql .= ", " . $this->fk_prev_id;
$sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
@ -4063,6 +4078,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ",fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql .= ", situation_percent=" . $this->situation_percent;
$sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog(get_class($this)."::update", LOG_DEBUG);

View File

@ -5,6 +5,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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
@ -202,6 +203,7 @@ if ($action == 'create')
$sql.= ' l.date_start,';
$sql.= ' l.date_end,';
$sql.= ' l.product_type,';
$sql.= ' l.fk_unit,';
$sql.= ' p.ref, p.fk_product_type, p.label as product_label,';
$sql.= ' p.description as product_desc';
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as l";
@ -222,6 +224,9 @@ if ($action == 'create')
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center">'.$langs->trans("VAT").'</td>';
print '<td align="center">'.$langs->trans("Qty").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) {
print '<td width="8%" align="left">'.$langs->trans("Unit").'</td>';
}
print '<td>'.$langs->trans("ReductionShort").'</td>';
print '<td align="right">'.$langs->trans("TotalHT").'</td>';
print '<td align="right">'.$langs->trans("TotalVAT").'</td>';
@ -246,6 +251,7 @@ if ($action == 'create')
// Show product and description
$type=(isset($objp->product_type)?$objp->product_type:$objp->fk_product_type);
$product_static->fk_unit=$objp->fk_unit;
if ($objp->fk_product > 0)
{
@ -299,6 +305,10 @@ if ($action == 'create')
// Qty
print '<td align="center">'.$objp->qty.'</td>';
if ($conf->global->PRODUCT_USE_UNITS) {
print '<td align="left">'.$product_static->getLabelOfUnit().'</td>';
}
// Percent
if ($objp->remise_percent > 0)
{
@ -445,7 +455,11 @@ else
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Price").'</td>';
print '<td align="center">'.$langs->trans("ReductionShort").'</td>';
print '<td align="center">'.$langs->trans("Qty").'</td></tr>';
print '<td align="center">'.$langs->trans("Qty").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) {
print '<td align="left">'.$langs->trans("Unit").'</td>';
}
print '</tr>';
$num = count($object->lines);
$i = 0;
@ -512,7 +526,11 @@ else
}
print '<td align="right">'.price($object->lines[$i]->price).'</td>';
print '<td align="center">'.$object->lines[$i]->remise_percent.' %</td>';
print '<td align="center">'.$object->lines[$i]->qty.'</td></tr>'."\n";
print '<td align="center">'.$object->lines[$i]->qty.'</td>';
if ($conf->global->PRODUCT_USE_UNITS) {
print "<td align=\"left\">".$object->lines[$i]->getLabelOfUnit()."</td>";
}
print "</tr>\n";
$i++;
}
print '</table>';

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
*
* 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
@ -27,6 +28,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
$langs->load("compta");
$langs->load("banks");
@ -298,11 +301,8 @@ if ($action == 'create')
if ($id)
{
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$salpayment->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
$head=salaries_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), 0, 'payment');

View File

@ -0,0 +1,68 @@
<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
*
* 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 htdocs/compta/salaries/info.php
* \ingroup salaries
* \brief Page with info about salaries contribution
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("compta");
$langs->load("bills");
$langs->load("salaries");
$id=GETPOST('id','int');
$action=GETPOST("action");
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', '', '', '');
/*
* View
*/
$help_url='EN:Module_Salaries|FR:Module Fiche de paie|ES:M&oacute;dulo Salarios';
llxHeader("",$langs->trans("Salaries"),$help_url);
$salpayment = new PaymentSalary($db);
$result = $salpayment->fetch($id);
$salpayment->info($id);
$head = salaries_prepare_head($salpayment);
dol_fiche_head($head, 'info', $langs->trans("SalaryPayment"), 0, 'payment');
print '<table width="100%"><tr><td>';
dol_print_object_info($salpayment);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();

View File

@ -338,7 +338,9 @@ if ($action == 'add' && $user->rights->contrat->creer)
0,
$lines[$i]->info_bits,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht
$lines[$i]->pa_ht,
array(),
$lines[$i]->fk_unit
);
if ($result < 0)
@ -494,6 +496,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$desc=$prod->description;
$desc=dol_concatdesc($desc,$product_desc);
$fk_unit = $prod->fk_unit;
}
else
{
@ -502,6 +505,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$tva_tx=GETPOST('tva_tx')?str_replace('*','',GETPOST('tva_tx')):0; // tva_tx field may be disabled, so we use vat rate 0
$tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0;
$desc=$product_desc;
$fk_unit= GETPOST('units', 'alpha');
}
$localtax1_tx=get_localtax($tva_tx,1,$object->thirdparty);
@ -541,7 +545,8 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$info_bits,
$fk_fournprice,
$pa_ht,
$array_options
$array_options,
$fk_unit
);
}
@ -622,6 +627,8 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
else
$pa_ht = null;
$fk_unit = GETPOST('unit', 'alpha');
$objectline->description=GETPOST('product_desc');
$objectline->price_ht=GETPOST('elprice');
$objectline->subprice=GETPOST('elprice');
@ -638,6 +645,12 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
$objectline->fk_fournprice=$fk_fournprice;
$objectline->pa_ht=$pa_ht;
if ($fk_unit > 0) {
$objectline->fk_unit = GETPOST('unit');
} else {
$objectline->fk_unit = null;
}
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
@ -960,7 +973,7 @@ if ($action == 'create')
print '<input type="hidden" name="remise_percent" value="0">';
dol_fiche_head();
print '<table class="border" width="100%">';
// Ref
@ -1070,7 +1083,7 @@ if ($action == 'create')
print '<br>'.$langs->trans("Note").': '.$langs->trans("OnlyLinesWithTypeServiceAreUsed");
}
}
print "</form>\n";
}
else
@ -1274,7 +1287,7 @@ else
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
$var=false;
// Title line for service
$cursorline=1;
while ($cursorline <= $nbofservices)
@ -1294,6 +1307,7 @@ else
$sql.= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,";
$sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,";
$sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
$sql.= " cd.fk_unit,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
@ -1309,6 +1323,7 @@ else
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" align="left">'.$langs->trans("Unit").'</td>';
print '<td width="50" align="right">'.$langs->trans("ReductionShort").'</td>';
if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print '<td width="50" align="right">'.$langs->trans("BuyingPrice").'</td>';
print '<td width="30">&nbsp;</td>';
@ -1349,6 +1364,8 @@ else
print '<td align="right">'.($objp->subprice != '' ? price($objp->subprice) : '')."</td>\n";
// Quantite
print '<td align="center">'.$objp->qty.'</td>';
// Unit
if($conf->global->PRODUCT_USE_UNITS) print '<td align="left">'.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).'</td>';
// Remise
if ($objp->remise_percent > 0)
{
@ -1396,8 +1413,16 @@ else
// Dates de en service prevues et effectives
if ($objp->subprice >= 0)
{
$colspan = 6;
if ($conf->margin->enabled && $conf->global->PRODUCT_USE_UNITS) {
$colspan = 8;
} elseif ($conf->margin->enabled || $conf->global->PRODUCT_USE_UNITS) {
$colspan = 7;
}
print '<tr '.$bc[$var].'>';
print '<td colspan="'.($conf->margin->enabled?7:6).'">';
print '<td colspan="'.$colspan.'">';
// Date planned
print $langs->trans("DateStartPlanned").': ';
@ -1465,6 +1490,12 @@ else
print '</td>';
print '<td align="right"><input size="5" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
print '<td align="center"><input size="2" type="text" name="elqty" value="'.$objp->qty.'"></td>';
if ($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
print $form->selectUnits($objp->fk_unit, "unit");
print '</td>';
}
print '<td align="right" class="nowrap"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
if (! empty($usemargins))
{
@ -1478,6 +1509,7 @@ else
$colspan=5;
if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++;
if($conf->global->PRODUCT_USE_UNITS) $colspan++;
// Ligne dates prevues
print "<tr ".$bc[$var].">";

View File

@ -30,6 +30,7 @@
*/
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php";
require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php';
@ -635,7 +636,8 @@ class Contrat extends CommonObject
$sql.= " d.date_fin_validite, d.date_cloture,";
$sql.= " d.fk_user_author,";
$sql.= " d.fk_user_ouverture,";
$sql.= " d.fk_user_cloture";
$sql.= " d.fk_user_cloture,";
$sql.= " d.fk_unit";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid";
$sql.= " ORDER by d.rowid ASC";
@ -680,6 +682,7 @@ class Contrat extends CommonObject
$line->fk_user_author = $objp->fk_user_author;
$line->fk_user_ouverture= $objp->fk_user_ouverture;
$line->fk_user_cloture = $objp->fk_user_cloture;
$line->fk_unit = $objp->fk_unit;
$line->ref = $objp->ref;
$line->libelle = $objp->label; // Label produit
@ -738,7 +741,8 @@ class Contrat extends CommonObject
$sql.= " d.date_fin_validite, d.date_cloture,";
$sql.= " d.fk_user_author,";
$sql.= " d.fk_user_ouverture,";
$sql.= " d.fk_user_cloture";
$sql.= " d.fk_user_cloture,";
$sql.= " d.fk_unit";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d";
$sql.= " WHERE d.fk_contrat = ".$this->id;
$sql.= " AND (d.fk_product IS NULL OR d.fk_product = 0)"; // fk_product = 0 gardee pour compatibilitee
@ -791,6 +795,7 @@ class Contrat extends CommonObject
$line->date_debut_reel = $this->db->jdate($objp->date_ouverture);
$line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite);
$line->date_fin_reel = $this->db->jdate($objp->date_cloture);
$line->fk_unit = $objp->fk_unit;
if ($line->statut == 0) $this->nbofserviceswait++;
if ($line->statut == 4 && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++;
@ -1231,9 +1236,10 @@ class Contrat extends CommonObject
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 si erreur, >0 si ok
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null)
{
global $user, $langs, $conf, $mysoc;
@ -1250,6 +1256,7 @@ class Contrat extends CommonObject
if (! $info_bits) $info_bits=0;
if (! $pu_ht) $pu_ht=0;
if (! $pu_ttc) $pu_ttc=0;
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht);
@ -1313,6 +1320,7 @@ class Contrat extends CommonObject
$sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht";
if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; }
if ($date_end > 0) { $sql.= ",date_fin_validite"; }
$sql.= ", fk_unit";
$sql.= ") VALUES ($this->id, '', '" . $this->db->escape($desc) . "',";
$sql.= ($fk_product>0 ? $fk_product : "null").",";
$sql.= " '".$qty."',";
@ -1331,6 +1339,7 @@ class Contrat extends CommonObject
else $sql.= ' null';
if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; }
if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; }
$sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null");
$sql.= ")";
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
@ -1409,9 +1418,10 @@ class Contrat extends CommonObject
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 si erreur, > 0 si ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null)
{
global $user, $conf, $langs, $mysoc;
@ -1502,6 +1512,7 @@ class Contrat extends CommonObject
else { $sql.=",date_ouverture=null"; }
if ($date_fin_reel > 0) { $sql.= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; }
else { $sql.=",date_cloture=null"; }
$sql .= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null");
$sql .= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
@ -2135,7 +2146,7 @@ class Contrat extends CommonObject
/**
* Classe permettant la gestion des lignes de contrats
*/
class ContratLigne extends CommonObject
class ContratLigne extends CommonObjectLine
{
var $id;
@ -2355,7 +2366,8 @@ class ContratLigne extends CommonObject
$sql.= " t.fk_user_author,";
$sql.= " t.fk_user_ouverture,";
$sql.= " t.fk_user_cloture,";
$sql.= " t.commentaire";
$sql.= " t.commentaire,";
$sql.= " t.fk_unit";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as t";
if ($id) $sql.= " WHERE t.rowid = ".$id;
if ($ref) $sql.= " WHERE t.rowid = '".$this->db->escape($ref)."'";
@ -2404,6 +2416,7 @@ class ContratLigne extends CommonObject
$this->fk_fournprice = $obj->fk_fournprice;
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->fk_fournprice, $obj->pa_ht);
$this->pa_ht = $marginInfos[0];
$this->fk_unit = $obj->fk_unit;
}
$this->db->free($resql);
@ -2461,7 +2474,7 @@ class ContratLigne extends CommonObject
if (empty($this->total_ht)) $this->total_ht = 0;
if (empty($this->total_tva)) $this->total_tva = 0;
if (empty($this->total_ttc)) $this->total_ttc = 0;
// Check parameters
// Put here code to add control on parameters values
@ -2519,6 +2532,7 @@ class ContratLigne extends CommonObject
$sql.= " fk_user_ouverture=".($this->fk_user_ouverture > 0?$this->fk_user_ouverture:"NULL").",";
$sql.= " fk_user_cloture=".($this->fk_user_cloture > 0?$this->fk_user_cloture:"NULL").",";
$sql.= " commentaire='".$this->db->escape($this->commentaire)."'";
$sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);

View File

@ -118,7 +118,7 @@ class box_actions extends ModeleBoxes
$this->info_box_contents[$line][] = array(
'td' => 'align="left"',
'text' => $societestatic->getNomUrl(1),
'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''),
'asis' => 1,
);

View File

@ -408,6 +408,7 @@ abstract class CommonDocGenerator
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
'line_product_ref'=>$line->product_ref,
'line_product_label'=>$line->product_label,
'line_product_type'=>$line->product_type,
'line_desc'=>$line->desc,
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
'line_up'=>price2num($line->subprice),

View File

@ -8,6 +8,7 @@
* Copyright (C) 2011-2014 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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
@ -2719,6 +2720,11 @@ abstract class CommonObject
// Qty
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left" width="50">'.$langs->trans('Unit').'</td>';
}
// Reduction short
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
@ -2918,7 +2924,7 @@ abstract class CommonObject
*/
function printOriginLinesList()
{
global $langs, $hookmanager;
global $langs, $hookmanager, $conf;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
@ -2926,6 +2932,10 @@ abstract class CommonObject
print '<td align="right">'.$langs->trans('VAT').'</td>';
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>';
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">'.$langs->trans('Unit').'</td>';
}
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
$num = count($this->lines);
@ -2966,7 +2976,7 @@ abstract class CommonObject
*/
function printOriginLine($line,$var)
{
global $conf,$langs,$bc;
global $conf,$langs,$bc, $conf;
//var_dump($line);
if (!empty($line->date_start))
@ -3053,6 +3063,7 @@ abstract class CommonObject
$this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
$this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : '&nbsp;';
if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long');
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
// Output template part (modules that overwrite templates must declare this into descriptor)

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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
@ -37,12 +38,61 @@ abstract class CommonObjectLine extends CommonObject
/**
* Id of the line
* @var int
* @deprecated Try to use id property as possible
* @deprecated Try to use id property as possible (even if field into database is still rowid)
*/
public $rowid;
// TODO
//! Database handler
public $db;
/**
* Product/service unit code ('km', 'm', 'p', ...)
* @var string
*/
public $fk_unit;
/**
* Returns the text label from units dictionnary
*
* @param string $type Label type (long or short)
* @return string|int <0 if ko, label if ok
*/
public function getLabelOfUnit($type='long')
{
global $langs;
if (!$this->fk_unit) {
return '';
}
$langs->load('products');
$this->db->begin();
$label_type = 'label';
if ($type == 'short')
{
$label_type = 'short_label';
}
$sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
$resql = $this->db->query($sql);
if($resql && $this->db->num_rows($resql) > 0)
{
$res = $this->db->fetch_array($resql);
$label = $res[$label_type];
$this->db->free($resql);
return $label;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
return -1;
}
}
// Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code.
// For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.

View File

@ -448,7 +448,7 @@ class Conf
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,askpricesupplier,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
// Enable select2
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT)) $this->global->MAIN_USE_JQUERY_MULTISELECT='select2.min';
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT)) $this->global->MAIN_USE_JQUERY_MULTISELECT='select2';
// Timeouts
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10;

View File

@ -2822,6 +2822,44 @@ class Form
return $opt;
}
/**
* Creates HTML units selector (code => label)
*
* @param string $selected Preselected code ('km', 'm', 'l', 'p', ...)
* @param string $htmlname Select name
* @param int $showempty Add a nempty line
* @return string HTML select
*/
function selectUnits($selected = '', $htmlname = 'units', $showempty=0)
{
global $langs;
$langs->load('products');
$return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
$sql = 'select rowid, label from '.MAIN_DB_PREFIX.'c_units where active=1';
$resql = $this->db->query($sql);
if($resql && $this->db->num_rows($resql) > 0)
{
if ($showempty) $return .= '<option value="none"></option>';
while($res = $this->db->fetch_object($resql))
{
if ($selected == $res[0])
{
$return.='<option value="'.$res->code.'" selected="selected">'.$langs->trans($res->label).'</option>';
}
else
{
$return.='<option value="'.$res->code.'">'.$langs->trans($res->label).'</option>';
}
}
$return.='</select>';
}
return $return;
}
/**
* Return a HTML select list of bank accounts
*
@ -2961,7 +2999,7 @@ class Form
$add = '';
}
$output.= '<option '.$add.'value="'.$cate_arbo[$key]['id'].'">'.dol_trunc($cate_arbo[$key]['fulllabel'],$maxlength,'middle').'</option>';
$outarray[$cate_arbo[$key]['id']] = $cate_arbo[$key]['fulllabel'];
}
}

View File

@ -1433,6 +1433,43 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
}
}
/**
* Return line unit
*
* @param Object $object Object
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = false)
{
global $langs;
if ($object->lines[$i]->special_code != 3) {
if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
$special_code = $object->lines[$i]->special_code;
if (!empty($object->lines[$i]->fk_parent_line)) {
$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
}
$parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code
);
$action = '';
return $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object,
$action); // Note that $action and $object may have been modified by some hooks
} else {
if (empty($hidedetails) || $hidedetails > 1) {
return $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
}
}
}
}
/**
* Return line remise percent
*

View File

@ -0,0 +1,53 @@
<?php
/**
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
*
* 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/
*/
/**
* Returns an array with the tabs for the "salaries" section
* It loads tabs from modules looking for the entity salaries
*
* @param Paiement $object Current salaries object
* @return array Tabs for the salaries section
*/
function salaries_prepare_head($object) {
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'salaries';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries');
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove');
return $head;
}

View File

@ -4,6 +4,7 @@
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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
@ -68,6 +69,7 @@ class pdf_einstein extends ModelePDFCommandes
$langs->load("main");
$langs->load("bills");
$langs->load("products");
$this->db = $db;
$this->name = "einstein";
@ -103,9 +105,19 @@ class pdf_einstein extends ModelePDFCommandes
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
if($conf->global->PRODUCT_USE_UNITS)
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
}
else
{
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
}
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
@ -239,7 +251,7 @@ class pdf_einstein extends ModelePDFCommandes
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
@ -403,9 +415,26 @@ class pdf_einstein extends ModelePDFCommandes
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
// Enough for 6 chars
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
}
// Discount on line
$pdf->SetXY($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent)
{
$pdf->SetXY($this->posxdiscount-2, $curY);
@ -563,7 +592,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Show payments table
*
* @param PDF $pdf Object PDF
* @param TCPDF $pdf Object PDF
* @param Object $object Object order
* @param int $posy Position y in PDF
* @param Translate $outputlangs Object langs for output
@ -578,7 +607,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Show miscellaneous information (payment mode, payment term, ...)
*
* @param PDF $pdf Object PDF
* @param TCPDF $pdf Object PDF
* @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
@ -763,7 +792,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Show total to pay
*
* @param PDF $pdf Object PDF
* @param TCPDF $pdf Object PDF
* @param Facture $object Object invoice
* @param int $deja_regle Montant deja regle
* @param int $posy Position depart
@ -1020,7 +1049,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Show table for lines
*
* @param PDF $pdf Object PDF
* @param TCPDF $pdf Object PDF
* @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle)
* @param int $nexY Y (not used)
@ -1088,7 +1117,23 @@ class pdf_einstein extends ModelePDFCommandes
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
if($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
'C');
}
}
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
@ -1115,7 +1160,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Show top header of page.
*
* @param PDF $pdf Object PDF
* @param TCPDF $pdf Object PDF
* @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
@ -1294,7 +1339,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Show footer of page. Need this->emetteur object
*
* @param PDF $pdf PDF
* @param TCPDF $pdf PDF
* @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text

View File

@ -115,9 +115,19 @@ class pdf_crabe extends ModelePDFFactures
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
if($conf->global->PRODUCT_USE_UNITS)
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
}
else
{
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
}
$this->posxdiscount=162;
$this->posxprogress=174; // Only displayed for situation invoices
$this->postotalht=174;
@ -282,7 +292,7 @@ class pdf_crabe extends ModelePDFFactures
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
@ -486,7 +496,23 @@ class pdf_crabe extends ModelePDFFactures
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
// Enough for 6 chars
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
}
// Discount on line
if ($object->lines[$i]->remise_percent)
@ -1326,7 +1352,23 @@ class pdf_crabe extends ModelePDFFactures
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
if($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
'C');
}
}
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);

View File

@ -4,6 +4,7 @@
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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
@ -102,9 +103,19 @@ class pdf_azur extends ModelePDFPropales
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
if($conf->global->PRODUCT_USE_UNITS)
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
}
else
{
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
}
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
@ -265,7 +276,7 @@ class pdf_azur extends ModelePDFPropales
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
@ -459,9 +470,26 @@ class pdf_azur extends ModelePDFPropales
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
// Enough for 6 chars
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
}
// Discount on line
$pdf->SetXY($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent)
{
$pdf->SetXY($this->posxdiscount-2, $curY);
@ -1217,7 +1245,23 @@ class pdf_azur extends ModelePDFPropales
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
if($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
'C');
}
}
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);

View File

@ -97,6 +97,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->posxqty=145;
$this->posxdiscount=162;
$this->postotalht=174;
if($conf->global->PRODUCT_USE_UNITS) {
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
}
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
@ -237,7 +244,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
@ -382,9 +389,30 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, price($object->lines[$i]->pu_ht), 0, 'R', 0);
// Unit price before discount
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
// Quantity
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $object->lines[$i]->qty, 0, 'R');
// Enough for 6 chars
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
}
// Discount on line
$pdf->SetXY($this->posxdiscount, $curY);
@ -790,7 +818,23 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
if($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
'C');
}
}
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);

View File

@ -103,11 +103,21 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1;
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
$this->posxdiscount=162;
$this->postotalht=174;
if ($conf->global->PRODUCT_USE_UNITS)
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
} else {
$this->posxtva=112;
$this->posxup=126;
$this->posxqty=145;
}
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
@ -245,7 +255,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
@ -392,7 +402,23 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Quantity
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $object->lines[$i]->qty, 0, 'R');
// Enough for 6 chars
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
}
// Discount on line
$pdf->SetXY($this->posxdiscount, $curY);
@ -910,7 +936,23 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
else
{
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
if($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
'C');
}
}
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);

View File

@ -61,6 +61,15 @@ if (in_array($object->element,array('propal', 'askpricesupplier','facture','invo
<td align="right"><span id="title_up_ttc"><?php echo $langs->trans('PriceUTTC'); ?></span></td>
<?php } ?>
<td align="right"><?php echo $langs->trans('Qty'); ?></td>
<?php
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
print '<span id="title_units">';
print $langs->trans('Unit');
print '</span></td>';
}
?>
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
<?php
if ($this->situation_cycle_ref) {
@ -220,6 +229,14 @@ else {
<?php } ?>
<td align="right"><input type="text" size="2" name="qty" id="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>">
</td>
<?php
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
print $form->selectUnits($line->fk_unit, "units");
print '</td>';
}
?>
<td align="right" class="nowrap"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat" value="<?php echo (isset($_POST["remise_percent"])?$_POST["remise_percent"]:$buyer->remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
<?php
if ($this->situation_cycle_ref) {
@ -303,6 +320,9 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
if($this->situation_cycle_ref) $colspan++;
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
if ($conf->global->PRODUCT_USE_UNITS) {
$colspan++;
}
if (! empty($usemargins))
{
@ -577,6 +597,7 @@ function setforfree() {
jQuery("#np_markRate").show(); // May no exists
jQuery(".np_marginRate").show(); // May no exists
jQuery(".np_markRate").show(); // May no exists
jQuery("#units, #title_units").show();
}
function setforpredef() {
jQuery("#select_type").val(-1);
@ -593,6 +614,8 @@ function setforpredef() {
jQuery("#np_markRate").hide(); // May no exists
jQuery(".np_marginRate").hide(); // May no exists
jQuery(".np_markRate").hide(); // May no exists
jQuery(".np_markRate").hide(); // May no exists
jQuery("#units, #title_units").hide();
}
</script>

View File

@ -129,7 +129,6 @@ $coldisplay=-1; // We remove first td
print '></td>';
}
?>
<td align="right"><?php $coldisplay++; ?>
<?php if (($line->info_bits & 2) != 2) {
// I comment this because it shows info even when not required
@ -144,6 +143,15 @@ $coldisplay=-1; // We remove first td
<?php } ?>
</td>
<?php
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
print $form->selectUnits($line->fk_unit, "units");
print '</td>';
}
?>
<td align="right" nowrap><?php $coldisplay++; ?>
<?php if (($line->info_bits & 2) != 2) {
print '<input size="1" type="text" class="flat" name="remise_percent" id="remise_percent" value="' . $line->remise_percent . '"';

View File

@ -145,6 +145,18 @@ if (empty($usemargins)) $usemargins=0;
} else echo '&nbsp;'; ?>
</td>
<?php
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left" nowrap="nowrap">';
$label = $line->getLabelOfUnit('short');
if ($label !== '') {
print $langs->trans($label);
}
print '</td>';
}
?>
<?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
<td align="right"><?php
$coldisplay++;

View File

@ -24,6 +24,9 @@
<td align="right"><?php echo $this->tpl['vat_rate']; ?></td>
<td align="right"><?php echo $this->tpl['price']; ?></td>
<td align="right"><?php echo $this->tpl['qty']; ?></td>
<?php
if($conf->global->PRODUCT_USE_UNITS) echo '<td align="left">'.$langs->trans($this->tpl['unit']).'</td>';
?>
<td align="right"><?php echo $this->tpl['remise_percent']; ?></td>
</tr>
<!-- END PHP TEMPLATE originproductline.tpl.php -->
<!-- END PHP TEMPLATE originproductline.tpl.php -->

View File

@ -67,12 +67,15 @@ $conffiletoshow = "htdocs/conf/conf.php";
//$conffile = "/etc/dolibarr/conf.php";
//$conffiletoshow = "/etc/dolibarr/conf.php";
//replace conf filename with "conf" parameter on url by GET
if (!empty($_GET['conf'])) {
setcookie('dolconf', $_GET['conf'],0,'/');
$conffile = 'conf/' . $_GET['conf'] . '.php';
// Replace conf filename with "conf" parameter on url by GET
if (! empty($_GET['conf']))
{
$confname=basename($_GET['conf']);
setcookie('dolconf', $confname, 0, '/');
$conffile = 'conf/'.$confname.'.php';
} else {
$conffile = 'conf/' . (!empty($_COOKIE['dolconf']) ? $_COOKIE['dolconf'] : 'conf') . '.php';
$confname=basename(empty($_COOKIE['dolconf']) ? 'conf' : $_COOKIE['dolconf']);
$conffile = 'conf/'.$confname.'.php';
}
@ -81,6 +84,8 @@ $result=@include_once $conffile; // Keep @ because with some error reporting thi
if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session
{
// Note: If calling page was not into htdocs (index.php, ...), then this redirect will fails.
// There is no real solution, because the only way to know the apache url relative path is to have into conf file.
header("Location: install/index.php");
exit;
}

View File

@ -247,6 +247,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
$sql.= " l.fk_unit,";
$sql.= " l.date_start, l.date_end";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
@ -297,9 +298,10 @@ class CommandeFournisseur extends CommonOrder
$line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);
$line->fk_unit = $objp->fk_unit;
$this->special_line = $objp->special_line;
$this->fk_parent_line = $objp->fk_parent_line;
$this->special_line = $objp->special_line;
$this->fk_parent_line = $objp->fk_parent_line;
$this->rang = $objp->rang;
@ -1196,13 +1198,14 @@ class CommandeFournisseur extends CommonOrder
* @param int $date_start Date start of service
* @param int $date_end Date end of service
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <=0 if KO, >0 if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null)
{
global $langs,$mysoc;
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2. $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type");
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2. $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
@ -1305,7 +1308,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= " (fk_commande, label, description, date_start, date_end,";
$sql.= " fk_product, product_type,";
$sql.= " qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,";
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc";
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit";
$sql.= ")";
$sql.= " VALUES (".$this->id.", '" . $this->db->escape($label) . "','" . $this->db->escape($desc) . "',";
$sql.= " ".($date_start?"'".$this->db->idate($date_start)."'":"null").",";
@ -1323,7 +1326,8 @@ class CommandeFournisseur extends CommonOrder
$sql.= "'".price2num($total_tva)."',";
$sql.= "'".price2num($total_localtax1)."',";
$sql.= "'".price2num($total_localtax2)."',";
$sql.= "'".price2num($total_ttc)."'";
$sql.= "'".price2num($total_ttc)."',";
$sql.= ($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= ")";
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
@ -1988,13 +1992,14 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger Disable triggers
* @param timestamp $date_start Date start of service
* @param timestamp $date_end Date end of service
* @param array $array_options extrafields array
* @param array $array_options Extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if error, > 0 if ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
{
global $mysoc;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
if ($this->brouillon)
@ -2061,6 +2066,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ",total_localtax2='".price2num($total_localtax2)."'";
$sql.= ",total_ttc='".price2num($total_ttc)."'";
$sql.= ",product_type=".$type;
$sql.= ($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
@ -2493,7 +2499,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
$sql.= ' cd.total_localtax1, cd.total_localtax2,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
$sql.= ' cd.date_start, cd.date_end';
$sql.= ' cd.date_start, cd.date_end, cd.fk_unit';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
$sql.= ' WHERE cd.rowid = '.$rowid;
@ -2526,6 +2532,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
$this->fk_unit = $objp->fk_unit;
$this->db->free($result);
return 1;

View File

@ -480,7 +480,7 @@ class FactureFournisseur extends CommonInvoice
{
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
@ -531,6 +531,7 @@ class FactureFournisseur extends CommonInvoice
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
$this->lines[$i]->special_code = $obj->special_code;
$this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->fk_unit = $obj->fk_unit;
$i++;
}
@ -1117,13 +1118,14 @@ class FactureFournisseur extends CommonInvoice
* @param int $rang Position of line
* @param int $notrigger Disable triggers
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int >0 if OK, <0 if KO
*
* FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order.
*/
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0)
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null)
{
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type", LOG_DEBUG);
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
@ -1158,7 +1160,7 @@ class FactureFournisseur extends CommonInvoice
{
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options);
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options, $fk_unit);
if ($result > 0)
{
$this->rowid = $idligne;
@ -1213,12 +1215,13 @@ class FactureFournisseur extends CommonInvoice
* @param timestamp $date_start Date start of service
* @param timestamp $date_end Date end of service
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 if KO, >0 if OK
*/
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0)
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
{
global $mysoc;
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$pu = price2num($pu);
@ -1288,6 +1291,7 @@ class FactureFournisseur extends CommonInvoice
else $sql.= ", fk_product = null";
$sql.= ", product_type = ".$product_type;
$sql.= ", info_bits = ".$info_bits;
$sql.= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
@ -1877,7 +1881,7 @@ class FactureFournisseur extends CommonInvoice
/**
* Class to manage line invoices
*/
class SupplierInvoiceLine extends CommonInvoice
class SupplierInvoiceLine extends CommonObjectLine
{
public $element='facture_fourn_det';
public $table_element='facture_fourn_det';

View File

@ -347,7 +347,8 @@ if (empty($reshook))
'',
$date_start,
$date_end,
$array_options
$array_options,
$productsupplier->fk_unit
);
}
if ($idprod == -99 || $idprod == 0)
@ -375,6 +376,8 @@ if (empty($reshook))
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit= GETPOST('units', 'alpha');
$tva_tx = price2num($tva_tx); // When vat is text input field
// Local Taxes
@ -385,15 +388,16 @@ if (empty($reshook))
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end, $array_options);
$ttc = 0;
}
else
{
$ttc = price2num(GETPOST('price_ttc'));
$ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT';
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options);
}
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit);
}
//print "xx".$tva_tx; exit;
@ -513,7 +517,8 @@ if (empty($reshook))
false,
$date_start,
$date_end,
$array_options
$array_options,
$_POST['units']
);
unset($_POST['qty']);
unset($_POST['type']);
@ -525,6 +530,7 @@ if (empty($reshook))
unset($_POST['tva_tx']);
unset($_POST['date_start']);
unset($_POST['date_end']);
unset($_POST['units']);
unset($localtax1_tx);
unset($localtax2_tx);
@ -989,7 +995,9 @@ if (empty($reshook))
'',
'',
null,
null
null,
array(),
$lines[$i]->fk_unit
);
if ($result < 0) {

View File

@ -207,7 +207,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) {
$fk_parent_line = 0;
}
// FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit);
if ($result > 0) {
$lineid = $result;

View File

@ -444,7 +444,8 @@ if (empty($reshook))
$product_type,
$lines[$i]->rang,
1,
$lines[$i]->array_options
$lines[$i]->array_options,
$lines[$i]->fk_unit
);
if ($result < 0)
@ -587,7 +588,7 @@ if (empty($reshook))
}
}
$result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options);
$result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units']);
if ($result >= 0)
{
unset($_POST['label']);
@ -684,6 +685,7 @@ if (empty($reshook))
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
}
//Replaces $fk_unit with the product's
if ($idprod > 0)
{
$result=$productsupplier->fetch($idprod);
@ -703,7 +705,7 @@ if (empty($reshook))
$price_base_type = 'HT';
// TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first)
$result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1_tx, $localtax2_tx, $qty, $idprod, $remise_percent, '', '', 0, $npr, $price_base_type, $type, -1, 0, $array_options);
$result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1_tx, $localtax2_tx, $qty, $idprod, $remise_percent, '', '', 0, $npr, $price_base_type, $type, -1, 0, $array_options, $productsupplier->fk_unit);
}
if ($idprod == -2 || $idprod == 0)
{
@ -730,6 +732,8 @@ if (empty($reshook))
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit= GETPOST('units', 'alpha');
$tva_tx = price2num($tva_tx); // When vat is text input field
// Local Taxes
@ -740,18 +744,15 @@ if (empty($reshook))
{
$ht = price2num($_POST['price_ht']);
$price_base_type = 'HT';
//print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type, -1, 0, $array_options);
}
else
{
$ttc = price2num($_POST['price_ttc']);
$ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT';
//print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0
$result=$object->addline($product_desc, $ht, $tva_tx,$localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type, -1, 0, $array_options);
}
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit);
}
//print "xx".$tva_tx; exit;
@ -793,6 +794,7 @@ if (empty($reshook))
unset($_POST['np_markRate']);
unset($_POST['dp_desc']);
unset($_POST['idprodfournprice']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);

View File

@ -0,0 +1,31 @@
-- ========================================================================
-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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 2 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/>.
--
-- ========================================================================
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('P','piece','p', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('SET','set','se', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('S','second','s', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('H','hour','h', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('D','day','d', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('KG','kilogram','kg', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('G','gram','g', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M','meter','m', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('LM','linear meter','lm', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M2','square meter','m2', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M3','cubic meter','m3', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('L','liter','l', 1);

62
htdocs/install/mysql/migration/3.7.0-3.8.0.sql Normal file → Executable file
View File

@ -533,8 +533,68 @@ CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product (
) ENGINE=InnoDB;
-- Units
create table llx_c_units(
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3),
label varchar(50),
short_label varchar(5),
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
ALTER TABLE llx_c_units ADD UNIQUE uk_c_units_code(code);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('P','piece','p', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('SET','set','se', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('S','second','s', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('H','hour','h', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('D','day','d', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('KG','kilogram','kg', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('G','gram','g', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M','meter','m', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('LM','linear meter','lm', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M2','square meter','m2', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M3','cubic meter','m3', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('L','liter','l', 1);
alter table llx_product add fk_unit integer default NULL;
ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_facturedet_rec add fk_unit integer default NULL;
ALTER TABLE llx_facturedet_rec ADD CONSTRAINT fk_facturedet_rec_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_facturedet add fk_unit integer default NULL;
ALTER TABLE llx_facturedet ADD CONSTRAINT fk_facturedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_propaldet add fk_unit integer default NULL;
ALTER TABLE llx_propaldet ADD CONSTRAINT fk_propaldet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_commandedet add fk_unit integer default NULL;
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_contratdet add fk_unit integer default NULL;
ALTER TABLE llx_contratdet ADD CONSTRAINT fk_contratdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_commande_fournisseurdet add fk_unit integer default NULL;
ALTER TABLE llx_commande_fournisseurdet ADD CONSTRAINT fk_commande_fournisseurdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
alter table llx_facture_fourn_det add fk_unit integer default NULL;
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
ALTER TABLE llx_user DROP INDEX uk_user_fk_societe;
ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc);
-- Feature request: A page to merge two thirdparties into one #2613
ALTER TABLE llx_categorie_societe DROP FOREIGN KEY fk_categorie_societe_fk_soc;
ALTER TABLE llx_categorie_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL;
ALTER TABLE llx_categorie_societe ADD CONSTRAINT fk_categorie_societe_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_categorie_fournisseur DROP FOREIGN KEY fk_categorie_fournisseur_fk_soc;
ALTER TABLE llx_categorie_fournisseur CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL;
ALTER TABLE llx_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL;
ALTER TABLE llx_categorie_fournisseur ADD CONSTRAINT fk_categorie_fournisseur_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_user CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL;
ALTER TABLE llx_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL;

View File

@ -0,0 +1,21 @@
-- ========================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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 2 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/>.
--
-- ========================================================================
ALTER TABLE llx_c_units ADD UNIQUE uk_c_units_code(code);

View File

@ -0,0 +1,27 @@
-- ========================================================================
-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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 2 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/>.
--
-- ========================================================================
create table llx_c_units(
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3),
label varchar(50),
short_label varchar(5),
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;

View File

@ -66,5 +66,5 @@ create table llx_commande_fournisseur
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255) -- for stock other parameters with json format
)ENGINE=innodb;

View File

@ -0,0 +1,19 @@
-- ============================================================================
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
--
-- 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/>.
--
-- ============================================================================
ALTER TABLE llx_commande_fournisseurdet ADD CONSTRAINT fk_commande_fournisseurdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);

View File

@ -2,6 +2,7 @@
-- Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
--
-- 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
@ -47,5 +48,6 @@ create table llx_commande_fournisseurdet
info_bits integer DEFAULT 0, -- TVA NPR ou non
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0,
import_key varchar(14)
import_key varchar(14),
fk_unit integer DEFAULT NULL
)ENGINE=innodb;

View File

@ -1,6 +1,7 @@
-- ===================================================================
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
@ -22,4 +23,5 @@
ALTER TABLE llx_commandedet ADD INDEX idx_commandedet_fk_commande (fk_commande);
ALTER TABLE llx_commandedet ADD INDEX idx_commandedet_fk_product (fk_product);
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_commande FOREIGN KEY (fk_commande) REFERENCES llx_commande (rowid);

View File

@ -3,6 +3,7 @@
-- Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
@ -53,6 +54,7 @@ create table llx_commandedet
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0,
fk_unit integer DEFAULT NULL, -- lien vers table des unités
import_key varchar(14)
)ENGINE=innodb;

View File

@ -27,3 +27,5 @@ ALTER TABLE llx_contratdet ADD INDEX idx_contratdet_date_fin_validite (date_fin_
ALTER TABLE llx_contratdet ADD CONSTRAINT fk_contratdet_fk_contrat FOREIGN KEY (fk_contrat) REFERENCES llx_contrat (rowid);
ALTER TABLE llx_contratdet ADD CONSTRAINT fk_contratdet_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_contratdet ADD CONSTRAINT fk_contratdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);

View File

@ -61,6 +61,7 @@ create table llx_contratdet
fk_user_author integer NOT NULL DEFAULT 0,
fk_user_ouverture integer,
fk_user_cloture integer,
commentaire text
commentaire text,
fk_unit integer DEFAULT NULL
)ENGINE=innodb;

View File

@ -22,3 +22,4 @@
ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk_facture_fourn);
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid);
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);

View File

@ -48,5 +48,6 @@ create table llx_facture_fourn_det
fk_code_ventilation integer DEFAULT 0 NOT NULL,
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0,
import_key varchar(14)
import_key varchar(14),
fk_unit integer DEFAULT NULL
)ENGINE=innodb;

View File

@ -1,6 +1,7 @@
-- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
@ -25,3 +26,4 @@ ALTER TABLE llx_facturedet ADD INDEX idx_facturedet_fk_facture (fk_facture);
ALTER TABLE llx_facturedet ADD INDEX idx_facturedet_fk_product (fk_product);
ALTER TABLE llx_facturedet ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_except, fk_facture);
ALTER TABLE llx_facturedet ADD CONSTRAINT fk_facturedet_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facture (rowid);
ALTER TABLE llx_facturedet ADD CONSTRAINT fk_facturedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);

View File

@ -60,7 +60,8 @@ create table llx_facturedet
import_key varchar(14),
situation_percent real, -- % progression of lines invoicing
fk_prev_id integer -- id of the line in the previous situation
fk_prev_id integer, -- id of the line in the previous situation,
fk_unit integer DEFAULT NULL -- id of the unit code¡
)ENGINE=innodb;

View File

@ -0,0 +1,21 @@
-- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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 2 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/>.
--
-- ===================================================================
ALTER TABLE llx_facturedet_rec ADD CONSTRAINT fk_facturedet_rec_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);

View File

@ -3,6 +3,7 @@
-- Copyright (C) 2009-2014 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
@ -46,5 +47,6 @@ create table llx_facturedet_rec
info_bits integer DEFAULT 0, -- TVA NPR ou non
special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0, -- ordre d'affichage
fk_contract_line integer NULL -- id of contract line when predefined invoice comes from contract lines
fk_contract_line integer NULL, -- id of contract line when predefined invoice comes from contract lines
fk_unit integer DEFAULT NULL
)ENGINE=innodb;

View File

@ -2,6 +2,7 @@
-- Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
-- Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
--
-- This program is free software; you can redistribute it and/or modify
@ -30,7 +31,7 @@ ALTER TABLE llx_product ADD INDEX idx_product_fk_country (fk_country);
ALTER TABLE llx_product ADD INDEX idx_product_fk_user_author (fk_user_author);
ALTER TABLE llx_product ADD INDEX idx_product_fk_barcode_type (fk_barcode_type);
ALTER TABLE llx_product ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity);
ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid);
ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid);

View File

@ -2,8 +2,8 @@
-- Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2010 juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2012-2013 Cédric Salvador <csalvador@gpcsolutions.fr>
-- Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
--
-- This program is free software; you can redistribute it and/or modify
@ -77,5 +77,6 @@ create table llx_product
hidden tinyint DEFAULT 0, -- Not used. Deprecated.
import_key varchar(14), -- Import key
fk_price_expression integer, -- Link to the rule for dynamic price calculation
desiredstock integer DEFAULT 0
desiredstock integer DEFAULT 0,
fk_unit integer DEFAULT NULL
)ENGINE=innodb;

View File

@ -1,5 +1,6 @@
-- ===================================================================
-- Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
@ -21,4 +22,5 @@
ALTER TABLE llx_propaldet ADD INDEX idx_propaldet_fk_propal (fk_propal);
ALTER TABLE llx_propaldet ADD INDEX idx_propaldet_fk_product (fk_product);
ALTER TABLE llx_propaldet ADD CONSTRAINT fk_propaldet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
ALTER TABLE llx_propaldet ADD CONSTRAINT fk_propaldet_fk_propal FOREIGN KEY (fk_propal) REFERENCES llx_propal (rowid);

View File

@ -2,6 +2,7 @@
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
@ -51,7 +52,8 @@ create table llx_propaldet
fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created)
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0 -- ordre affichage sur la propal
rang integer DEFAULT 0, -- ordre affichage sur la propal
fk_unit integer DEFAULT NULL -- lien vers table des unités
)ENGINE=innodb;

View File

@ -21,7 +21,7 @@
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity);
ALTER TABLE llx_user ADD INDEX uk_user_fk_societe (fk_soc);
ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc);
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople);
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member);

View File

@ -1391,6 +1391,7 @@ UseSearchToSelectProduct=Use a search form to choose a product (rather than a dr
UseEcoTaxeAbility=Support Eco-Taxe (WEEE)
SetDefaultBarcodeTypeProducts=Default barcode type to use for products
SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties
UseUnits=Support units
ProductCodeChecker= Module for product code generation and checking (product or service)
ProductOtherConf= Product / Service configuration
##### Syslog #####

View File

@ -189,6 +189,32 @@ CustomCode=Customs code
CountryOrigin=Origin country
HiddenIntoCombo=Hidden into select lists
Nature=Nature
DictionnaryUnits=Units
ShortLabel=Short label
Unit=Unit
p=u.
set=set
se=set
second=second
s=s
hour=hour
h=h
day=day
d=d
kilogram=kilogram
kg=Kg
gram=gram
g=g
meter=meter
m=m
linear meter=linear meter
lm=lm
square meter=square meter
m2=m²
cubic meter=cubic meter
m3=m³
liter=liter
l=L
ProductCodeModel=Product ref template
ServiceCodeModel=Service ref template
AddThisProductCard=Create product card

View File

@ -1189,10 +1189,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext?'?'.$ext:'').'"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
}
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) // jQuery plugin "mutiselect", "multiple-select", "select2"...
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) // jQuery plugin "mutiselect", "multiple-select", "select2", ...
{
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/'.$tmpplugin.'.js'.($ext?'?'.$ext:'').'"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/'.$tmpplugin.'.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
}
// jQuery jMobile
if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || (! empty($conf->dol_use_jmobile) && $conf->dol_use_jmobile > 0))

View File

@ -6,7 +6,8 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
**
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.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
@ -180,6 +181,12 @@ else if ($action == 'set')
$res = dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $ecotaxe,'chaine',0,'',$conf->entity);
}*/
else if ($action == 'useUnits')
{
$useUnits = GETPOST('activate_units', 'alpha');
$res = dolibarr_set_const($db, "PRODUCT_USE_UNITS", $useUnits, 'chaine', 0, '', $conf->entity);
}
if($action)
{
if (! $res > 0) $error++;
@ -447,6 +454,21 @@ print '</td>';
print '</tr>';
print '</form>';
// Use units
$var=!$var;
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="useUnits">';
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("UseUnits").'</td>';
print '<td width="60" align="right">';
print $form->selectyesno("activate_units",$conf->global->PRODUCT_USE_UNITS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</td>';
print '</tr>';
print '</form>';
// View product description in thirdparty language
if (! empty($conf->global->MAIN_MULTILANGS))
{

View File

@ -7,7 +7,7 @@
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
@ -181,6 +181,8 @@ if (empty($reshook))
if (! $error)
{
$units = GETPOST('units', 'int');
$object->ref = $ref;
$object->libelle = GETPOST('libelle');
$object->price_base_type = GETPOST('price_base_type');
@ -223,14 +225,14 @@ if (empty($reshook))
$object->barcode_type_label = $stdobject->barcode_type_label;
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
$object->url = GETPOST('url');
$object->note = dol_htmlcleanlastbr(GETPOST('note'));
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
$object->duration_value = GETPOST('duration_value');
$object->duration_unit = GETPOST('duration_unit');
$object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0;
$object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0;
$object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0;
$object->canvas = GETPOST('canvas');
$object->weight = GETPOST('weight');
$object->weight_units = GETPOST('weight_units');
@ -242,6 +244,7 @@ if (empty($reshook))
$object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0;
$object->fk_unit = GETPOST('units');
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
@ -282,7 +285,7 @@ if (empty($reshook))
$cat->add_type($object, 'product');
}
}
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
@ -334,6 +337,14 @@ if (empty($reshook))
$object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0;
$units = GETPOST('units', 'int');
if ($units > 0) {
$object->fk_unit = $units;
} else {
$object->fk_unit = null;
}
$object->barcode_type = GETPOST('fk_barcode_type');
$object->barcode = GETPOST('barcode');
// Set barcode_type_xxx from barcode_type id
@ -366,18 +377,18 @@ if (empty($reshook))
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product";
$sql .= " WHERE fk_product = ".$object->id;
$db->query($sql);
// Then we add the associated categories
$categories = GETPOST('categories');
if(!empty($categories)) {
$cat = new Categorie($db);
foreach($categories as $id_category) {
$cat->fetch($id_category);
$cat->add_type($object, 'product');
}
}
$action = 'view';
}
else
@ -588,7 +599,19 @@ if (empty($reshook))
$object->id,
GETPOST('remise_percent'),
$price_base_type,
$pu_ttc
$pu_ttc,
0,
0,
-1,
0,
0,
0,
0,
'',
'',
'',
0,
$object->fk_unit
);
if ($result > 0)
{
@ -680,7 +703,18 @@ if (empty($reshook))
'',
'',
$price_base_type,
$pu_ttc
$pu_ttc,
'',
'',
0,
-1,
0,
0,
null,
0,
'',
0,
$object->fk_unit
);
if ($result > 0)
@ -773,7 +807,20 @@ if (empty($reshook))
'',
'',
$price_base_type,
$pu_ttc
$pu_ttc,
Facture::TYPE_STANDARD,
-1,
0,
'',
0,
0,
null,
0,
'',
0,
100,
'',
$object->fk_unit
);
if ($result > 0)
@ -1030,7 +1077,7 @@ else
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
$doleditor = new DolEditor('note', GETPOST('note'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, 70);
$doleditor->Create();
$doleditor->Create();
print "</td></tr>";
@ -1040,6 +1087,15 @@ else
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250);
print "</td></tr>";
// Units
if($conf->global->PRODUCT_USE_UNITS)
{
print '<tr><td>'.$langs->trans('Unit').'</td>';
print '<td colspan="3">';
print $form->selectUnits("units");
print '</td></tr>';
}
print '</table>';
print '<br>';
@ -1321,6 +1377,15 @@ else
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250);
print "</td></tr>";
// Units
if($conf->global->PRODUCT_USE_UNITS)
{
print '<tr><td>'.$langs->trans('Unit').'</td>';
print '<td colspan="3">';
print $form->selectUnits($object->fk_unit);
print '</td></tr>';
}
print '</table>';
print '<br>';
@ -1588,6 +1653,18 @@ else
print "</td></tr>\n";
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = $object->getLabelOfUnit();
print '<tr><td>'.$langs->trans('Unit').'</td><td>';
if ($unit !== '') {
print $langs->trans($unit);
}
print '</td></tr>';
}
// Custom code
if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO))
{
@ -1615,7 +1692,7 @@ else
$cat = new Categorie($db);
$categories = $cat->containing($object->id,0);
$catarray = $form->select_all_categories(0, '', 'parent', 64, 0, 1);
$toprint = array();
foreach($categories as $c) {
$toprint[] = $catarray[$c->id];

View File

@ -5,6 +5,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2007-2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2013-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
@ -175,6 +176,12 @@ class Product extends CommonObject
var $fk_price_expression;
/**
* Unit code ('km', 'm', 'l', 'p', ...)
* @var string
*/
public $fk_unit;
/**
* Regular product
*/
@ -382,6 +389,7 @@ class Product extends CommonObject
$sql.= ", canvas";
$sql.= ", finished";
$sql.= ", tobatch";
$sql.= ", fk_unit";
$sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."'";
$sql.= ", ".$conf->entity;
@ -402,6 +410,7 @@ class Product extends CommonObject
$sql.= ", '".$this->canvas."'";
$sql.= ", ".((! isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished);
$sql.= ", ".((empty($this->status_batch) || $this->status_batch < 0)? '0':$this->status_batch);
$sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ")";
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
@ -691,6 +700,7 @@ class Product extends CommonObject
$sql.= ", accountancy_code_buy = '" . $this->accountancy_code_buy."'";
$sql.= ", accountancy_code_sell= '" . $this->accountancy_code_sell."'";
$sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null");
$sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -1503,7 +1513,7 @@ class Product extends CommonObject
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
$sql.= " datec, tms, import_key, entity, desiredstock, tobatch";
$sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit";
$sql.= " ,ref_ext, fk_price_expression";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id);
@ -1582,6 +1592,7 @@ class Product extends CommonObject
$this->ref_ext = $obj->ref_ext;
$this->fk_price_expression = $obj->fk_price_expression;
$this->fk_unit = $obj->fk_unit;
$this->db->free($resql);
@ -3803,6 +3814,48 @@ class Product extends CommonObject
$this->barcode=-1; // Create barcode automatically
}
/**
* Returns the text label from units dictionnary
*
* @param string $type Label type (long or short)
* @return string|int <0 if ko, label if ok
*/
function getLabelOfUnit($type='long')
{
global $langs;
if (!$this->fk_unit) {
return '';
}
$langs->load('products');
$this->db->begin();
$label_type = 'label';
if ($type == 'short')
{
$label_type = 'short_label';
}
$sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
$resql = $this->db->query($sql);
if($resql && $this->db->num_rows($resql) > 0)
{
$res = $this->db->fetch_array($resql);
$label = $res[$label_type];
$this->db->free($resql);
return $label;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
return -1;
}
}
/**
* Return if object has a sell-by date or eat-by date
*

View File

@ -1796,11 +1796,11 @@ table.nobordernopadding {
}
table.nobordernopadding tr {
border: 0px !important;
padding: 0px 0px;
padding: 0px 0px !important;
}
table.nobordernopadding td {
border: 0px !important;
padding: 0px 0px;
padding: 0px 0px !important;
}
/* For lists */

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -135,52 +136,112 @@ class PricesTest extends PHPUnit_Framework_TestCase
global $mysoc;
$mysoc=new Societe($db);
/*
* Country France
*/
// qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value)
$mysoc->country_code='FR';
$mysoc->country_id=1;
$result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0);
print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1');
$this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1 FR');
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 1, 0% localtax2 type 0 (method we provide value)
/*
* Country Spain
*/
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (method we provide value)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=0;
$result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test1 ES');
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=0;
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test2 ES');
// --------------------------------------------------------
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (method we provide value)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=1;
$mysoc->localtax2_assuj=0;
$result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test2');
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 1, 0% localtax2 type 0 (other method autodetect)
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test3 ES');
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=1;
$mysoc->localtax2_assuj=0;
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test3 ES');
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, nor localtax2 (method we provide value)
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test4 ES');
// --------------------------------------------------------
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=0;
$result3=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result3,'Test4');
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 0);
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test5 ES');
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, nor localtax2 (other method autodetect)
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=0;
$result3=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result3,'Test5');
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test6 ES');
// --------------------------------------------------------
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10,- 91, 0, 19, 0, 1.90, 0, 0, 19),$result2,'Test7 ES');
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES';
$mysoc->country_id=4;
$mysoc->localtax1_assuj=0;
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10,- 91, 0, 19, 0, 1.90, 0, 0, 19),$result2,'Test8 ES');
/*
* Country Côte d'Ivoire
*/
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (method we provide value)
$mysoc->country_code='CI';
$mysoc->country_id=21;
@ -191,7 +252,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test6 CI');
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test9 CI');
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect)
$mysoc->country_code='CI';
@ -201,7 +262,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test7 CI');
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test10 CI');
return true;
}

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010-2015 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
@ -187,7 +187,7 @@ class UserTest extends PHPUnit_Framework_TestCase
$newlocalobject=new User($this->savdb);
$newlocalobject->initAsSpecimen();
$this->changeProperties($newlocalobject);
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','ref','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','socid','societe_id','ref','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected
return $localobject;
}
@ -301,7 +301,7 @@ class UserTest extends PHPUnit_Framework_TestCase
$oVarsB=get_object_vars($oB);
$aKeys=array_keys($oVarsA);
foreach($aKeys as $sKey) {
if (in_array($sKey,$fieldstoignorearray))
if (in_array($sKey,$fieldstoignorearray))
continue;
if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) {
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);