Merge remote-tracking branch 'origin/3.5' into develop
Conflicts: htdocs/comm/action/fiche.php
This commit is contained in:
commit
908c39098d
@ -56,6 +56,8 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
|
||||
|
||||
|
||||
***** ChangeLog for 3.5.1 compared to 3.5.0 *****
|
||||
Fix: Do not report trigger errors twice.
|
||||
Fix: Error when creating event was not reported.
|
||||
Fix: Bug of import of agenda when using https link
|
||||
Fix: Field nature not saved correctly
|
||||
Fix: Substituion of extra field was ko for order
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# \file build/makepack-dolibarrmodule.pl
|
||||
# \brief Package builder (tgz, zip, rpm, deb, exe)
|
||||
# \author (c)2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
# \author (c)2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
use Cwd;
|
||||
@ -20,8 +20,8 @@ $GROUP="ldestailleur";
|
||||
|
||||
|
||||
use vars qw/ $REVISION $VERSION /;
|
||||
$REVISION='1.20';
|
||||
$VERSION="1.0 (build $REVISION)";
|
||||
$REVISION='1.0';
|
||||
$VERSION="3.5 (build $REVISION)";
|
||||
|
||||
|
||||
|
||||
@ -245,18 +245,30 @@ foreach my $PROJECT (@PROJECTLIST) {
|
||||
if (! $result) { die "Error: Can't open conf file makepack-".$PROJECT.".conf for reading.\n"; }
|
||||
while(<IN>)
|
||||
{
|
||||
if ($_ =~ /^#/) { next; } # Do not process comments
|
||||
$entry=$_;
|
||||
|
||||
if ($entry =~ /^#/) { next; } # Do not process comments
|
||||
|
||||
$_ =~ s/\n//;
|
||||
$_ =~ /^(.*)\/[^\/]+/;
|
||||
$entry =~ s/\n//;
|
||||
|
||||
if ($entry =~ /^!(.*)$/) # Exclude so remove file/dir
|
||||
{
|
||||
print "Remove $BUILDROOT/$PROJECTLC/$1\n";
|
||||
$ret=`rm -fr "$BUILDROOT/$PROJECTLC/"$1`;
|
||||
if ($? != 0) { die "Failed to delete a file to exclude declared into makepack-".$PROJECT.".conf file (Fails on line ".$entry.")\n"; }
|
||||
next;
|
||||
}
|
||||
|
||||
$entry =~ /^(.*)\/[^\/]+/;
|
||||
print "Create directory $BUILDROOT/$PROJECTLC/$1\n";
|
||||
$ret=`mkdir -p "$BUILDROOT/$PROJECTLC/$1"`;
|
||||
if ($_ !~ /version\-/)
|
||||
if ($entry !~ /version\-/)
|
||||
{
|
||||
print "Copy $SOURCE/$_ into $BUILDROOT/$PROJECTLC/$_\n";
|
||||
$ret=`cp -pr "$SOURCE/$_" "$BUILDROOT/$PROJECTLC/$_"`;
|
||||
if ($? != 0) { die "Failed to make copy of a file declared into makepack-".$PROJECT.".conf file (Fails on line ".$_.")\n"; }
|
||||
print "Copy $SOURCE/$entry into $BUILDROOT/$PROJECTLC/$entry\n";
|
||||
$ret=`cp -pr "$SOURCE/$entry" "$BUILDROOT/$PROJECTLC/$entry"`;
|
||||
if ($? != 0) { die "Failed to make copy of a file declared into makepack-".$PROJECT.".conf file (Fails on line ".$entry.")\n"; }
|
||||
}
|
||||
|
||||
}
|
||||
close IN;
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ $tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_fac
|
||||
$tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c";
|
||||
$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, p.code as country_code, p.libelle as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_pays as p WHERE e.fk_pays=p.rowid and p.active=1";
|
||||
$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
|
||||
$tabsql[16]= "SELECT code, label as libelle, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||
$tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||
$tabsql[17]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_fees";
|
||||
$tabsql[18]= "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
|
||||
$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
|
||||
@ -201,7 +201,7 @@ $tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
|
||||
$tabfield[13]= "code,libelle,type";
|
||||
$tabfield[14]= "code,libelle,price,organization,country_id,country";
|
||||
$tabfield[15]= "code,libelle,width,height,unit";
|
||||
$tabfield[16]= "code,libelle";
|
||||
$tabfield[16]= "code,libelle,sortorder";
|
||||
$tabfield[17]= "code,libelle";
|
||||
$tabfield[18]= "code,libelle,tracking";
|
||||
$tabfield[19]= "code,libelle";
|
||||
@ -229,7 +229,7 @@ $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
|
||||
$tabfieldvalue[13]= "code,libelle,type";
|
||||
$tabfieldvalue[14]= "code,libelle,price,organization,country";
|
||||
$tabfieldvalue[15]= "code,libelle,width,height,unit";
|
||||
$tabfieldvalue[16]= "code,libelle";
|
||||
$tabfieldvalue[16]= "code,libelle,sortorder";
|
||||
$tabfieldvalue[17]= "code,libelle";
|
||||
$tabfieldvalue[18]= "code,libelle,tracking";
|
||||
$tabfieldvalue[19]= "code,libelle";
|
||||
@ -257,7 +257,7 @@ $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
|
||||
$tabfieldinsert[13]= "code,libelle,type";
|
||||
$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
|
||||
$tabfieldinsert[15]= "code,label,width,height,unit";
|
||||
$tabfieldinsert[16]= "code,label";
|
||||
$tabfieldinsert[16]= "code,label,sortorder";
|
||||
$tabfieldinsert[17]= "code,libelle";
|
||||
$tabfieldinsert[18]= "code,libelle,tracking";
|
||||
$tabfieldinsert[19]= "code,libelle";
|
||||
@ -440,6 +440,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
|
||||
if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';
|
||||
if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
|
||||
if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
|
||||
|
||||
setEventMessage($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),'errors');
|
||||
}
|
||||
@ -767,6 +768,7 @@ if ($id)
|
||||
if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountparent"); }
|
||||
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 ($valuetoshow != '')
|
||||
{
|
||||
print '<td align="'.$align.'">';
|
||||
@ -881,10 +883,11 @@ if ($id)
|
||||
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
|
||||
if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; }
|
||||
if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; }
|
||||
if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
|
||||
if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
|
||||
if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); }
|
||||
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"); }
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
|
||||
@ -226,7 +226,7 @@ if ($action == 'add_action')
|
||||
|
||||
// On cree l'action
|
||||
$idaction=$object->add($user);
|
||||
|
||||
|
||||
if ($idaction > 0)
|
||||
{
|
||||
if (! $object->error)
|
||||
@ -261,8 +261,10 @@ if ($action == 'add_action')
|
||||
{
|
||||
$db->rollback();
|
||||
$langs->load("errors");
|
||||
|
||||
if (! empty($object->error)) setEventMessage($langs->trans($object->error), 'errors');
|
||||
if (count($object->errors)) setEventMessage($object->errors, 'errors');
|
||||
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1135,7 +1135,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
$price_ht = '';
|
||||
$tva_tx = '';
|
||||
}
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
if (GETPOST('usenewaddlineform')) { // TODO Remove this
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):'')));
|
||||
$price_ht = GETPOST('price_ht');
|
||||
@ -1314,8 +1314,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
}
|
||||
|
||||
// Margin
|
||||
$fournprice=(GETPOST('fournprice'.$predef)?GETPOST('fournprice'.$predef):'');
|
||||
$buyingprice=(GETPOST('buying_price'.$predef)?GETPOST('buying_price'.$predef):'');
|
||||
$fournprice=price2num(GETPOST('fournprice'.$predef)?GETPOST('fournprice'.$predef):'');
|
||||
$buyingprice=price2num(GETPOST('buying_price'.$predef)?GETPOST('buying_price'.$predef):'');
|
||||
|
||||
// Local Taxes
|
||||
$localtax1_tx= get_localtax($tva_tx, 1, $object->client);
|
||||
@ -1436,8 +1436,8 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
||||
$localtax2_rate=get_localtax($vat_rate,2,$object->client);
|
||||
|
||||
// Add buying price
|
||||
$fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
|
||||
$buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
|
||||
$fournprice=price2num(GETPOST('fournprice')?GETPOST('fournprice'):'');
|
||||
$buyingprice=price2num(GETPOST('buying_price')?GETPOST('buying_price'):'');
|
||||
|
||||
//Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
|
||||
@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("banks");
|
||||
$langs->load("bills");
|
||||
|
||||
// Security check
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
|
||||
@ -30,6 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
$langs->load("other");
|
||||
$langs->load("compta");
|
||||
$langs->load("banks");
|
||||
$langs->load("bills");
|
||||
|
||||
$year=GETPOST("year","int");
|
||||
if ($year == 0)
|
||||
|
||||
@ -262,43 +262,57 @@ if (! empty($usemargins) && $user->rights->margins->creer)
|
||||
return false;
|
||||
}
|
||||
|
||||
var np_price = 0;
|
||||
if (remise.val().replace(',','.') != 100)
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
if (npRate == "np_marginRate")
|
||||
np_price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
else {
|
||||
if (npRate == "np_markRate")
|
||||
np_price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
}
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "marginRate")
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht']:first").val(roundFloat(np_price));
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO This works for french numbers only
|
||||
function roundFloat(num)
|
||||
{
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding = <?php echo min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>;
|
||||
|
||||
var amount = num.toString().replace(',','.'); // should be useless
|
||||
var nbdec = 0;
|
||||
var rounding = main_rounding;
|
||||
var pos = amount.indexOf('.');
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0)
|
||||
decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
nbdec = decpart.length;
|
||||
if (nbdec > rounding)
|
||||
rounding = nbdec;
|
||||
// Si on depasse max
|
||||
if (rounding > main_max_dec_shown)
|
||||
{
|
||||
rounding = main_max_dec_shown;
|
||||
}
|
||||
//amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
|
||||
@ -629,47 +629,63 @@ function checkFreeLine(e, npRate)
|
||||
return false;
|
||||
}
|
||||
|
||||
var np_price = 0;
|
||||
if (remise.val().replace(',','.') != 100)
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "np_marginRate")
|
||||
np_price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
else {
|
||||
if (npRate == "np_markRate")
|
||||
np_price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
}
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "np_markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht']:first").val(formatFloat(np_price));
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
update_price('price_ht', 'price_ttc');
|
||||
|
||||
return true;
|
||||
}
|
||||
function roundFloat(num) {
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding = <?php echo min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>;
|
||||
|
||||
var amount = num.toString().replace(',','.'); // should be useless
|
||||
var nbdec = 0;
|
||||
var rounding = main_rounding;
|
||||
var pos = amount.indexOf('.');
|
||||
|
||||
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0)
|
||||
decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
nbdec = decpart.length;
|
||||
if (nbdec > rounding)
|
||||
rounding = nbdec;
|
||||
// Si on depasse max
|
||||
if (rounding > main_max_dec_shown)
|
||||
{
|
||||
rounding = main_max_dec_shown;
|
||||
}
|
||||
//amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
function formatFloat(num) {
|
||||
return roundFloat(num).replace('.', ',');
|
||||
}
|
||||
<?php } ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -471,41 +471,55 @@ if (! empty($conf->margin->enabled))
|
||||
}
|
||||
|
||||
var price = 0;
|
||||
if (remise.val().replace(',','.') != 100)
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "marginRate")
|
||||
price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
else {
|
||||
if (npRate == "markRate")
|
||||
price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
}
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht']:first").val(roundFloat(price));
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO This works for french numbers only
|
||||
function roundFloat(num) {
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding = <?php echo min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>;
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var amount = num.toString().replace(',','.'); // should be useless
|
||||
var nbdec = 0;
|
||||
var rounding = main_rounding;
|
||||
var pos = amount.indexOf('.');
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0)
|
||||
decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
nbdec = decpart.length;
|
||||
if (nbdec > rounding)
|
||||
rounding = nbdec;
|
||||
// Si on depasse max
|
||||
if (rounding > main_max_dec_shown)
|
||||
{
|
||||
rounding = main_max_dec_shown;
|
||||
}
|
||||
//amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
|
||||
@ -270,42 +270,56 @@ if (! empty($usemargins) && $user->rights->margins->creer)
|
||||
return false;
|
||||
}
|
||||
|
||||
var np_price = 0;
|
||||
if (remise.val().replace(',','.') != 100)
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "np_marginRate_predef")
|
||||
np_price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
else {
|
||||
if (npRate == "np_markRate_predef")
|
||||
np_price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
|
||||
}
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "np_markRate_predef")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht_predef']:last").val(roundFloat(np_price));
|
||||
$("input[name='price_ht_predef']:last").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO This works for french numbers only
|
||||
function roundFloat(num) {
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding = <?php echo min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>;
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var amount = num.toString().replace(',','.'); // should be useless
|
||||
var nbdec = 0;
|
||||
var rounding = main_rounding;
|
||||
var pos = amount.indexOf('.');
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0)
|
||||
decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
nbdec = decpart.length;
|
||||
if (nbdec > rounding)
|
||||
rounding = nbdec;
|
||||
// Si on depasse max
|
||||
if (rounding > main_max_dec_shown)
|
||||
{
|
||||
rounding = main_max_dec_shown;
|
||||
}
|
||||
//amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
|
||||
@ -1315,9 +1315,24 @@ else if ($id > 0 || ! empty($ref))
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
if ($action == 'editline')
|
||||
{
|
||||
print '<input type="hidden" name="action" value="updateline">';
|
||||
print '<input type="hidden" name="line_id" value="'.GETPOST('line_id','int').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="action" value="addline">';
|
||||
}
|
||||
|
||||
/*
|
||||
* Lignes d'intervention
|
||||
*/
|
||||
*/
|
||||
$sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
|
||||
$sql.= ' ft.date as date_intervention';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
|
||||
@ -1405,11 +1420,6 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Ligne en mode update
|
||||
if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid)
|
||||
{
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$objp->rowid.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="updateline">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="line_id" value="'.GETPOST('line_id','int').'">';
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
@ -1433,8 +1443,6 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
$i++;
|
||||
@ -1459,12 +1467,6 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<td colspan="4"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Ajout ligne d'intervention
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#add" name="addinter" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="addline">';
|
||||
|
||||
$var=false;
|
||||
|
||||
print '<tr '.$bc[$var].">\n";
|
||||
@ -1492,8 +1494,6 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
if (! $num) print '</table>';
|
||||
}
|
||||
|
||||
@ -1504,6 +1504,8 @@ else if ($id > 0 || ! empty($ref))
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
print '</div>';
|
||||
print "\n";
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||
* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||
* Copyright (C) 2012-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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
|
||||
@ -87,7 +87,7 @@ class Holiday extends CommonObject
|
||||
$this->updateSoldeCP();
|
||||
|
||||
// Vérifie le nombre d'utilisateur et mets à jour si besoin
|
||||
$this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser'));
|
||||
$this->verifNbUsers($this->countActiveUsersWithoutCP(),$this->getConfCP('nbUser'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -923,13 +923,13 @@ class Holiday extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this).'::updateSoldeCP sql='.$sql2);
|
||||
$result= $this->db->query($sql2);
|
||||
|
||||
|
||||
if ($result) return 1;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mise à jour pour un utilisateur
|
||||
@ -942,7 +942,7 @@ class Holiday extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this).'::updateSoldeCP sql='.$sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
|
||||
if ($result) return 1;
|
||||
else return -1;
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ class Holiday extends CommonObject
|
||||
|
||||
$sql = "SELECT u.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE statut > '0'";
|
||||
$sql.= " WHERE statut > 0";
|
||||
|
||||
dol_syslog(get_class($this)."::fetchUsers sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -1143,7 +1143,7 @@ class Holiday extends CommonObject
|
||||
|
||||
$sql = "SELECT u.rowid, u.lastname, u.firstname";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE statut > '0'";
|
||||
$sql.= " WHERE statut > 0";
|
||||
|
||||
dol_syslog(get_class($this)."::fetchUsers sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -1229,7 +1229,23 @@ class Holiday extends CommonObject
|
||||
|
||||
$sql = "SELECT count(u.rowid) as compteur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE statut > '0'";
|
||||
$sql.= " WHERE u.statut > 0";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
$objet = $this->db->fetch_object($result);
|
||||
return $objet->compteur;
|
||||
|
||||
}
|
||||
/**
|
||||
* Compte le nombre d'utilisateur actifs dans Dolibarr sans CP
|
||||
*
|
||||
* @return int retourne le nombre d'utilisateur
|
||||
*/
|
||||
function countActiveUsersWithoutCP() {
|
||||
|
||||
$sql = "SELECT count(u.rowid) as compteur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)";
|
||||
$sql.= " WHERE u.statut > 0 AND hu.fk_user IS NULL ";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
$objet = $this->db->fetch_object($result);
|
||||
@ -1240,17 +1256,17 @@ class Holiday extends CommonObject
|
||||
/**
|
||||
* Compare le nombre d'utilisateur actif de Dolibarr à celui des utilisateurs des congés payés
|
||||
*
|
||||
* @param int $userDolibarr nombre d'utilisateur actifs dans Dolibarr
|
||||
* @param int $userCP nombre d'utilisateur actifs dans le module congés payés
|
||||
* @param int $userDolibarrWithoutCP Number of active users in Dolibarr without holidays
|
||||
* @param int $userCP Number of active users into table of holidays
|
||||
* @return void
|
||||
*/
|
||||
function verifNbUsers($userDolibarr,$userCP) {
|
||||
function verifNbUsers($userDolibarrWithoutCP,$userCP) {
|
||||
|
||||
if (empty($userCP)) $userCP=0;
|
||||
dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarr.' userCP='.$userCP);
|
||||
|
||||
// Si il y a plus d'utilisateur Dolibarr que dans le module CP
|
||||
if ($userDolibarr > $userCP)
|
||||
// On vérifie les users Dolibarr sans CP
|
||||
if ($userDolibarrWithoutCP > 0)
|
||||
{
|
||||
$this->updateConfCP('nbUser',$userDolibarr);
|
||||
|
||||
@ -1311,7 +1327,7 @@ class Holiday extends CommonObject
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// On ajoute l'utilisateur
|
||||
// On supprime l'utilisateur
|
||||
$this->deleteCPuser($obj->fk_user);
|
||||
|
||||
$i++;
|
||||
@ -1654,7 +1670,7 @@ class Holiday extends CommonObject
|
||||
$sql.= " cpl.new_solde";
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl";
|
||||
$sql.= " WHERE cpl.rowid > '0'"; // Hack pour la recherche sur le tableau
|
||||
$sql.= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria
|
||||
|
||||
// Filtrage de séléction
|
||||
if(!empty($filter)) {
|
||||
|
||||
@ -173,8 +173,8 @@ CustomCode=Customs code
|
||||
CountryOrigin=Origin country
|
||||
HiddenIntoCombo=Hidden into select lists
|
||||
Nature=Nature
|
||||
ProductCodeModel=Product code template
|
||||
ServiceCodeModel=Service code template
|
||||
ProductCodeModel=Product ref template
|
||||
ServiceCodeModel=Service ref template
|
||||
AddThisProductCard=Create product card
|
||||
HelpAddThisProductCard=This option allows you to create or clone a product if it does not exist.
|
||||
AddThisServiceCard=Create service card
|
||||
@ -217,4 +217,4 @@ DefinitionOfBarCodeForThirdpartyNotComplete=Definition of type or value of bar c
|
||||
BarCodeDataForProduct=Barcode information of product %s :
|
||||
BarCodeDataForThirdparty=Barcode information of thirdparty %s :
|
||||
BarcodeStickersMask=xxx
|
||||
|
||||
|
||||
|
||||
@ -56,9 +56,9 @@ $pagenext = $page + 1;
|
||||
$startdate=$enddate='';
|
||||
|
||||
if (!empty($_POST['startdatemonth']))
|
||||
$startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']));
|
||||
$startdate = dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
|
||||
if (!empty($_POST['enddatemonth']))
|
||||
$enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']));
|
||||
$enddate = dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -90,16 +90,16 @@ print $form->select_dolusers($agentid,'agentid',1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Start date
|
||||
print '<td>'.$langs->trans('StartDate').'</td>';
|
||||
print '<td>'.$langs->trans('StartDate').' ('.$langs->trans("DateValidation").')</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($startdate,'startdate','','',1,"sel",1,1);
|
||||
print '</td>';
|
||||
print '<td width="20%">'.$langs->trans('EndDate').'</td>';
|
||||
print '<td width="20%">'.$langs->trans('EndDate').' ('.$langs->trans("DateValidation").')</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($enddate,'enddate','','',1,"sel",1,1);
|
||||
print '</td>';
|
||||
print '<td style="text-align: center;">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Launch').'" />';
|
||||
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Launch')).'" />';
|
||||
print '</td></tr>';
|
||||
print "</table>";
|
||||
print '</form>';
|
||||
@ -131,9 +131,9 @@ if ($agentid > 0) {
|
||||
$sql .= " AND sc.fk_user = ".$agentid;
|
||||
}
|
||||
if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
|
||||
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0";
|
||||
$sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
|
||||
|
||||
@ -49,9 +49,9 @@ $pagenext = $page + 1;
|
||||
$startdate=$enddate='';
|
||||
|
||||
if (!empty($_POST['startdatemonth']))
|
||||
$startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']));
|
||||
$startdate = dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
|
||||
if (!empty($_POST['enddatemonth']))
|
||||
$enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']));
|
||||
$enddate = dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -119,33 +119,39 @@ if (! $sortfield)
|
||||
}
|
||||
|
||||
// Start date
|
||||
print '<td>'.$langs->trans('StartDate').'</td>';
|
||||
print '<td>'.$langs->trans('StartDate').' ('.$langs->trans("DateValidation").')</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($startdate,'startdate','','',1,"sel",1,1);
|
||||
print '</td>';
|
||||
print '<td width="20%">'.$langs->trans('EndDate').'</td>';
|
||||
print '<td width="20%">'.$langs->trans('EndDate').' ('.$langs->trans("DateValidation").')</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($enddate,'enddate','','',1,"sel",1,1);
|
||||
print '</td>';
|
||||
print '<td style="text-align: center;">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Launch').'" />';
|
||||
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Launch')).'" />';
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Total Margin
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<tr><td width="20%">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<tr><td width="20%">'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<tr><td width="20%">'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -167,11 +173,11 @@ $sql.= " AND f.fk_statut > 0";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
if ($client)
|
||||
$sql.= " AND f.fk_soc = $socid";
|
||||
$sql.= " AND f.fk_soc = ".$socid;
|
||||
if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
|
||||
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
@ -210,7 +216,7 @@ if ($result)
|
||||
|
||||
$cumul_achat = 0;
|
||||
$cumul_vente = 0;
|
||||
|
||||
|
||||
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
|
||||
if ($num > 0)
|
||||
@ -284,7 +290,7 @@ if ($result)
|
||||
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
|
||||
}
|
||||
|
||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||
print '<tr class="liste_total">';
|
||||
if ($client)
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
@ -316,11 +322,9 @@ $db->close();
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$("div.fiche form input.button[type=submit]").hide();
|
||||
|
||||
$("#socid").change(function() {
|
||||
$("div.fiche form").submit();
|
||||
});
|
||||
$("#socid").change(function() {
|
||||
$("div.fiche form").submit();
|
||||
});
|
||||
|
||||
$("#totalMargin").html("<?php echo price($totalMargin, null, null, null, null, $rounding); ?>");
|
||||
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%"); ?>");
|
||||
|
||||
@ -71,9 +71,10 @@ $pagenext = $page + 1;
|
||||
$startdate=$enddate='';
|
||||
|
||||
if (!empty($_POST['startdatemonth']))
|
||||
$startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']));
|
||||
$startdate = dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
|
||||
if (!empty($_POST['enddatemonth']))
|
||||
$enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']));
|
||||
$enddate = dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -121,33 +122,39 @@ else {
|
||||
}
|
||||
|
||||
// Start date
|
||||
print '<td>'.$langs->trans('StartDate').'</td>';
|
||||
print '<td>'.$langs->trans('StartDate').' ('.$langs->trans("DateValidation").')</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($startdate,'startdate','','',1,"sel",1,1);
|
||||
print '</td>';
|
||||
print '<td width="20%">'.$langs->trans('EndDate').'</td>';
|
||||
print '<td width="20%">'.$langs->trans('EndDate').' ('.$langs->trans("DateValidation").')</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($enddate,'enddate','','',1,"sel",1,1);
|
||||
print '</td>';
|
||||
print '<td style="text-align: center;">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Launch').'" />';
|
||||
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Launch')).'" />';
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Total Margin
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<tr><td width="20%">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<tr><td width="20%">'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<tr><td width="20%">'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -174,9 +181,9 @@ $sql.= " AND d.fk_facture = f.rowid";
|
||||
if ($id > 0)
|
||||
$sql.= " AND d.fk_product =".$id;
|
||||
if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
|
||||
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
@ -185,6 +192,7 @@ if ($id > 0)
|
||||
$sql.= " ORDER BY ".$sortfield." ".$sortorder;
|
||||
// TODO: calculate total to display then restore pagination
|
||||
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||
|
||||
dol_syslog('margin::productMargins.php sql='.$sql,LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -289,7 +297,7 @@ if ($result)
|
||||
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
|
||||
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
|
||||
}
|
||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||
print '<tr class="liste_total">';
|
||||
if ($id > 0)
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
|
||||
@ -349,7 +349,7 @@ class Product extends CommonObject
|
||||
$sql.= ", '".$this->accountancy_code_buy."'";
|
||||
$sql.= ", '".$this->accountancy_code_sell."'";
|
||||
$sql.= ", '".$this->canvas."'";
|
||||
$sql.= ", ".((! isset($this->finished) || $this->finished < 0)?'null':$this->finished);
|
||||
$sql.= ", ".((! isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : $this->finished);
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::Create sql=".$sql);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user