Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2015-11-08 15:39:10 +01:00
20 changed files with 238 additions and 166 deletions

View File

@@ -106,7 +106,7 @@ if ($action == 'add' || $action == 'update')
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='create';
}
}
@@ -147,7 +147,7 @@ if ($action == 'add' || $action == 'update')
else
{
$reload = 0;
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action= "edit";
}
}

View File

@@ -105,7 +105,7 @@ if (empty($reshook))
$result=$object->fetch($id);
$object->code_compta=$_POST["customeraccountancycode"];
$result=$object->update($object->id,$user,1,1,0);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// conditions de reglement
@@ -113,7 +113,7 @@ if (empty($reshook))
{
$object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// mode de reglement
@@ -121,7 +121,7 @@ if (empty($reshook))
{
$object->fetch($id);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// assujetissement a la TVA
@@ -130,7 +130,7 @@ if (empty($reshook))
$object->fetch($id);
$object->tva_assuj=$_POST['assujtva_value'];
$result=$object->update($object->id);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// set prospect level
@@ -157,7 +157,7 @@ if (empty($reshook))
$object->fetch($id);
$object->outstanding_limit=GETPOST('outstanding_limit');
$result=$object->set_OutstandingBill($user);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
}

View File

@@ -359,7 +359,7 @@ if (empty($reshook))
{
$statut=2; // Status 'sent partially' (because at least one error)
if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
}
else
{

View File

@@ -6,7 +6,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2010-2015 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>
@@ -131,7 +131,7 @@ if (empty($reshook))
{
if (! GETPOST('socid', 3))
{
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
@@ -141,7 +141,7 @@ if (empty($reshook))
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit();
} else {
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
@@ -157,7 +157,7 @@ if (empty($reshook))
exit();
} else {
$langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -211,8 +211,8 @@ if (empty($reshook))
}
} else {
$langs->load("errors");
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
else setEventMessage($langs->trans($object->error), 'errors');
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
else setEventMessages($langs->trans($object->error), null, 'errors');
}
}
@@ -318,7 +318,7 @@ if (empty($reshook))
$id = $object->create_from($user);
} else {
setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors');
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
}
} else {
$object->ref = GETPOST('ref');
@@ -507,7 +507,7 @@ if (empty($reshook))
if ($result < 0)
{
$error++;
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
}
}
@@ -671,7 +671,7 @@ if (empty($reshook))
if ($object->id > 0) {
$result = $object->insert_discount($_POST["remise_id"]);
if ($result < 0) {
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@@ -875,7 +875,7 @@ if (empty($reshook))
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessage($mesg, 'errors');
setEventMessages($mesg, null, '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, $fk_unit);
@@ -929,13 +929,13 @@ if (empty($reshook))
} else {
$db->rollback();
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
}
// Mise a jour d'une ligne dans la propale
// Update a line within proposal
else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save'))
{
// Define info_bits
@@ -991,7 +991,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors');
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error ++;
}
} else {
@@ -1040,7 +1040,7 @@ if (empty($reshook))
} else {
$db->rollback();
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@@ -1137,9 +1137,9 @@ if (empty($reshook))
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else {
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@@ -1636,13 +1636,13 @@ if ($action == 'create')
else if ($action == 'validate') {
$error = 0;
// on verifie si l'objet est en numerotation provisoire
// We verifie whether the object is provisionally numbering
$ref = substr($object->ref, 1, 4);
if ($ref == 'PROV') {
$numref = $object->getNextNumRef($soc);
if (empty($numref)) {
$error ++;
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$numref = $object->ref;

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.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
@@ -54,12 +54,12 @@ if ($id > 0 || ! empty($ref))
if ($ret == 0)
{
$langs->load("errors");
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
$error++;
}
else if ($ret < 0)
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
@@ -75,7 +75,7 @@ else
/*
* Ajout d'un nouveau contact
* Add a new contact
*/
if ($action == 'addcontact' && $user->rights->propale->creer)
@@ -96,16 +96,16 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// Bascule du statut d'un contact
// Toggle the status of a contact
else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
if ($object->id > 0)
@@ -114,7 +114,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer)
}
}
// Efface un contact
// Deletes a contact
else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
$result = $object->delete_contact($lineid);

View File

@@ -65,17 +65,17 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
if (! $res > 0)
{
$error++;
setEventMessage($langs->trans("ErrorFailedToLoadDiscount"), 'errors');
setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors');
}
if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc)
{
$error++;
setEventMessage($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), 'errors');
setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
}
if (! $error && $discount->fk_facture_line)
{
$error++;
setEventMessage($langs->trans("ErrorCantSplitAUsedDiscount"), 'errors');
setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
}
if (! $error)
{
@@ -166,13 +166,13 @@ if ($action == 'setremise')
else
{
$error++;
setEventMessage($soc->error, 'errors');
setEventMessages($soc->error, $soc->errors, 'errors');
}
}
}
else
{
setEventMessage($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), 'errors');
setEventMessages($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), null, 'errors');
}
}
@@ -194,7 +194,7 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes')
}
else
{
setEventMessage($discount->error, 'errors');
setEventMessages($discount->error, $discount->errors, 'errors');
$db->rollback();
}
}
@@ -216,7 +216,7 @@ if ($socid > 0)
$object->fetch($socid);
/*
* Affichage onglets
* Display tabs
*/
$head = societe_prepare_head($object);
@@ -300,7 +300,7 @@ if ($socid > 0)
}
/*
* Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture)
* Liste remises fixes restant en cours (= liees a aucune facture ni ligne de facture)
*/
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
$sql.= " rc.datec as dc, rc.description,";

View File

@@ -258,7 +258,7 @@ class ExtraFields
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
{
if(is_array($param) and count($param) > 0)
if(is_array($param) && count($param) > 0)
{
$params = $this->db->escape(serialize($param));
}

View File

@@ -106,7 +106,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
$ref_prodserv = "";
if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
{
if ($prodser->isservice())
if ($prodser->isService())
{
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
}

View File

@@ -1166,7 +1166,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$ref_prodserv = "";
if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
{
if ($prodser->isservice())
if ($prodser->isService())
{
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
}

View File

@@ -98,7 +98,7 @@ function product_prepare_head($object)
$head[$h][2] = 'referers';
$h++;
if ($object->isproduct() || ($object->isservice() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
{
if (! empty($conf->stock->enabled) && $user->rights->stock->lire)
{

View File

@@ -5,6 +5,7 @@
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* 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
@@ -315,14 +316,39 @@ else {
<?php
if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
else $colspan = 9;
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
$colspan = 6;
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$colspan++;
}
if ($this->situation_cycle_ref) {
$colspan++;
}
// We add 1 if col total ttc
if (!empty($inputalsopricewithtax)) {
$colspan++;
}
if ($conf->global->PRODUCT_USE_UNITS) {
$colspan++;
}
if (count($object->lines)) {
//There will be an edit and a delete button
$colspan += 2;
// With this, there is a column move button ONLY if lines > 1
if (in_array($object->element, array(
'propal',
'askpricesupplier',
'facture',
'invoice',
'commande',
'order',
'order_supplier',
'invoice_supplier'
))) {
$colspan++;
}
}
if (! empty($usemargins))
{

View File

@@ -273,7 +273,7 @@ if ($resql)
if ($search_all)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall));
print $langs->transnoentities("FilterOnInto", $search_all, join(', ',$fieldstosearchall));
}
print '<table class="liste" width="100%">';

View File

@@ -29,5 +29,5 @@ CREATE TABLE llx_opensurvey_sondage (
allow_comments tinyint NOT NULL DEFAULT 1,
allow_spy tinyint NOT NULL DEFAULT 1,
tms TIMESTAMP,
sujet TEXT, -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions
sujet TEXT -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions
) ENGINE=InnoDB;

View File

@@ -1038,7 +1038,7 @@ else
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$type = $langs->trans('Product');
if ($object->isservice()) $type = $langs->trans('Service');
if ($object->isService()) $type = $langs->trans('Service');
//print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
// Main official, simple, and not duplicated code
@@ -1144,7 +1144,7 @@ else
// Stock
/*
if ($object->isproduct() && ! empty($conf->stock->enabled))
if ($object->isProduct() && ! empty($conf->stock->enabled))
{
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>';
print '<input name="seuil_stock_alerte" size="4" value="'.$object->seuil_stock_alerte.'">';
@@ -1169,7 +1169,7 @@ else
print '</td></tr>';
}
if ($object->isservice())
if ($object->isService())
{
// Duration
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">';
@@ -1435,7 +1435,7 @@ else
print '</td></tr>';
}
if ($object->isservice())
if ($object->isService())
{
// Duration
print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';

View File

@@ -3804,7 +3804,7 @@ class Product extends CommonObject
*
* @return boolean True if it's a product
*/
function isproduct()
function isProduct()
{
return ($this->type == Product::TYPE_PRODUCT ? true : false);
}
@@ -3814,7 +3814,7 @@ class Product extends CommonObject
*
* @return boolean True if it's a service
*/
function isservice()
function isService()
{
return ($this->type == Product::TYPE_SERVICE ? true : false);
}
@@ -4088,4 +4088,19 @@ class Product extends CommonObject
return 1;
}
/**
* Returns the rights used for this class
* @return stdClass
*/
public function getRights()
{
global $user;
if ($this->isProduct()) {
return $user->rights->produit;
} else {
return $user->rights->service;
}
}
}

View File

@@ -193,8 +193,8 @@ if ($id > 0 || ! empty($ref))
print "<tr>";
$nblignes=6;
if ($object->isproduct() && ! empty($conf->stock->enabled)) $nblignes++;
if ($object->isservice()) $nblignes++;
if ($object->isProduct() && ! empty($conf->stock->enabled)) $nblignes++;
if ($object->isService()) $nblignes++;
// Reference
print '<td width="25%">'.$langs->trans("Ref").'</td><td>';

View File

@@ -521,7 +521,7 @@ if ($id > 0 || $ref)
{
// Suppliers list title
print '<table class="noborder" width="100%">';
if ($object->isproduct()) $nblignefour=4;
if ($object->isProduct()) $nblignefour=4;
else $nblignefour=4;
$param="&id=".$object->id;

View File

@@ -113,86 +113,115 @@ if (empty($reshook))
$action='';
}
if (($action == 'update_price') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer))
if (($action == 'update_price') && !$cancel && $object->getRights()->creer)
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
$error = 0;
$pricestoupdate = array();
$psq = GETPOST('psqflag');
$psq = empty($newpsq) ? 0 : $newpsq;
$maxpricesupplier = $object->min_recommended_price();
$object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression
// MultiPrix
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
//Shall we generate prices using price rules?
$object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false;
$object->update($object->id, $user);
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
if (isset($_POST ["price_".$i])) {
$level = $i;
$newprice = price2num($_POST ["price_".$i], 'MU');
$newprice_min = price2num($_POST ["price_min_".$i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_".$i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_".$i]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
break; // We found submited price
}
}
} else {
$level = 0;
$newprice = price2num($_POST ["price"], 'MU');
$newprice_min = price2num($_POST ["price_min"], 'MU');
$newpricebase = $_POST ["price_base_type"];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx"]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) {
setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors');
$error ++;
$action = 'edit_price';
}
if ($newprice < $newprice_min && !empty($object->fk_price_expression)) {
$newprice = $newprice_min; //Set price same as min, the user will not see the
}
$res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq);
if ($res) {
if (!empty($conf->dynamicprices->enabled)) {
$object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression
if ($object->fk_price_expression != 0) {
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProduct($object);
if ($price_result < 0) { //Expression is not valid
if ($priceparser->parseProduct($object) < 0) {
$error ++;
$action = 'edit_price';
setEventMessage($priceparser->translatedError(), 'errors');
}
}
if (empty($error) && !empty($conf->dynamicprices->enabled)) {
$ret = $object->setPriceExpression($object->fk_price_expression);
if ($ret < 0) {
$error ++;
$action = 'edit_price';
setEventMessage($object->error, 'errors');
}
// Multiprices
if (!$error && !empty($conf->global->PRODUIT_MULTIPRICES)) {
$newprice = GETPOST('price', 'array');
$newprice_min = GETPOST('price_min', 'array');
$newpricebase = GETPOST('multiprices_base_type', 'array');
$newvattx = GETPOST('tva_tx', 'array');
//Shall we generate prices using price rules?
$object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false;
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
if (!isset($newprice[$i])) {
continue;
}
$newnpr = (preg_match('/\*/', $newvattx[$i] ? 1 : 0));
$newvat = str_replace('*', '', $newvattx[$i]);
$pricestoupdate[$i] = array(
'price' => $newprice[$i],
'price_min' => $newprice_min[$i],
'price_base_type' => $newpricebase[$i],
'vat_tx' => $newvat,
'npr' => $newnpr
);
//If autogeneration is enabled, then we only set the first level
if ($object->price_autogen) {
break;
}
}
if (empty($error)) {
$action = '';
setEventMessage($langs->trans("RecordSaved"));
} else {
$pricestoupdate[0] = array(
'price' => $_POST ["price"],
'price_min' => $_POST ["price_min"],
'price_base_type' => $_POST ["price_base_type"],
'vat_tx' => str_replace('*', '', $_POST ["tva_tx"]),
'npr' => preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0
);
}
if (!$error && $object->update($object->id, $user) < 1) {
$error++;
setEventMessage($object->error, 'errors');
$action = 'edit_price';
}
if (!$error) {
$db->begin();
foreach ($pricestoupdate as $key => $val) {
$newprice = $val['price'];
if ($val['price'] < $val['price_min'] && !empty($object->fk_price_expression)) {
$newprice = $val['price_min']; //Set price same as min, the user will not see the
}
$newprice = price2num($newprice, 'MU');
$newprice_min = price2num($val['price_min'], 'MU');
if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) {
setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors');
$error ++;
break;
}
$res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq);
if ($res < 0) {
$error ++;
setEventMessage($object->error, 'errors');
break;
}
}
}
if (empty($error)) {
$action = '';
setEventMessage($langs->trans("RecordSaved"));
$db->commit();
} else {
$action = 'edit_price';
setEventMessage($object->error, 'errors');
$db->rollback();
}
}
@@ -423,13 +452,13 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
// Selling price
print '<tr><td class="titlefield">' . $langs->trans("SellingPrice") . '</td>';
print '<td colspan="2">';
if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') {
print price($object->multiprices_ttc["$soc->price_level"]);
if ($object->multiprices_base_type[$soc->price_level] == 'TTC') {
print price($object->multiprices_ttc[$soc->price_level]);
} else {
print price($object->multiprices["$soc->price_level"]);
print price($object->multiprices[$soc->price_level]);
}
if ($object->multiprices_base_type["$soc->price_level"]) {
print ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]);
if ($object->multiprices_base_type[$soc->price_level]) {
print ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]);
} else {
print ' ' . $langs->trans($object->price_base_type);
}
@@ -437,18 +466,18 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
// Price min
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td colspan="2">';
if ($object->multiprices_base_type["$soc->price_level"] == 'TTC')
if ($object->multiprices_base_type[$soc->price_level] == 'TTC')
{
print price($object->multiprices_min_ttc["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]);
print price($object->multiprices_min_ttc[$soc->price_level]) . ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]);
} else {
print price($object->multiprices_min["$soc->price_level"]) . ' ' . $langs->trans(empty($object->multiprices_base_type["$soc->price_level"])?'HT':$object->multiprices_base_type["$soc->price_level"]);
print price($object->multiprices_min[$soc->price_level]) . ' ' . $langs->trans(empty($object->multiprices_base_type[$soc->price_level])?'HT':$object->multiprices_base_type[$soc->price_level]);
}
print '</td></tr>';
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
{
// TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td colspan="2">' . vatrate($object->multiprices_tva_tx["$soc->price_level"], true) . '</td></tr>';
print '<tr><td>' . $langs->trans("VATRate") . '</td><td colspan="2">' . vatrate($object->multiprices_tva_tx[$soc->price_level], true) . '</td></tr>';
}
else
{
@@ -482,28 +511,28 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
print '</td>';
if ($object->multiprices_base_type ["$i"] == 'TTC') {
print '<td style="text-align: right">' . price($object->multiprices_ttc["$i"]);
if ($object->multiprices_base_type [$i] == 'TTC') {
print '<td style="text-align: right">' . price($object->multiprices_ttc[$i]);
} else {
print '<td style="text-align: right">' . price($object->multiprices["$i"]);
print '<td style="text-align: right">' . price($object->multiprices[$i]);
}
if ($object->multiprices_base_type["$i"]) {
print ' '.$langs->trans($object->multiprices_base_type ["$i"]).'</td>';;
if ($object->multiprices_base_type[$i]) {
print ' '.$langs->trans($object->multiprices_base_type [$i]).'</td>';
} else {
print ' '.$langs->trans($object->price_base_type).'</td>';;
print ' '.$langs->trans($object->price_base_type).'</td>';
}
// Prix min
print '<td style="text-align: right">';
if (empty($object->multiprices_base_type["$i"])) $object->multiprices_base_type["$i"]="HT";
if ($object->multiprices_base_type["$i"] == 'TTC')
if (empty($object->multiprices_base_type[$i])) $object->multiprices_base_type[$i]="HT";
if ($object->multiprices_base_type[$i] == 'TTC')
{
print price($object->multiprices_min_ttc["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]);
print price($object->multiprices_min_ttc[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]);
}
else
{
print price($object->multiprices_min["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]);
print price($object->multiprices_min[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]);
}
print '</td></tr>';
@@ -877,7 +906,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
<script>
var showHidePriceRules = function () {
var otherPrices = $('div.fiche form:not(:first)');
var otherPrices = $('div.fiche form table:not(:first), div.fiche form table:first tr:not(:first)');
var minPrice1 = $('div.fiche form:first tr:eq(1)');
if (jQuery('input#usePriceRules').prop('checked')) {
@@ -897,11 +926,12 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
</script>
<?php
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
if ($i > 1) print '<br>';
if ($i > 1) print '<br>';
elseif (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) {
print $langs->trans('UseMultipriceRules'). ' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ? 'checked' : '').'><br><br>';
}
@@ -910,7 +940,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<input type="hidden" name="id" value="' . $object->id . '">';
if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))
{
print '<input type="hidden" name="tva_tx_' . $i . '" value="' . $object->tva_tx . '">';
print '<input type="hidden" name="tva_tx[' . $i . ']" value="' . $object->tva_tx . '">';
}
print '<table class="border" width="100%">';
@@ -919,7 +949,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense
{
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx["$i"], $mysoc, '', $object->id);
print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id);
print '</td></tr>';
}
@@ -928,22 +958,22 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
$text = $langs->trans('SellingPrice') . ' ' . $i;
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>';
if ($object->multiprices_base_type ["$i"] == 'TTC') {
print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices_ttc ["$i"]) . '">';
if ($object->multiprices_base_type [$i] == 'TTC') {
print '<input name="price[' . $i . ']" size="10" value="' . price($object->multiprices_ttc [$i]) . '">';
} else {
print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices ["$i"]) . '">';
print '<input name="price[' . $i . ']" size="10" value="' . price($object->multiprices [$i]) . '">';
}
print $form->selectPriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i);
print '&nbsp;'.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]");
print '</td></tr>';
// Min price
print '<tr><td>';
$text = $langs->trans('MinPrice') . ' ' . $i;
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
if ($object->multiprices_base_type ["$i"] == 'TTC') {
print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min_ttc ["$i"]) . '">';
if ($object->multiprices_base_type [$i] == 'TTC') {
print '<td><input name="price_min[' . $i . ']" size="10" value="' . price($object->multiprices_min_ttc [$i]) . '">';
} else {
print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min ["$i"]) . '">';
print '<td><input name="price_min[' . $i . ']" size="10" value="' . price($object->multiprices_min [$i]) . '">';
}
if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
@@ -951,15 +981,16 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
}
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></td></tr>';
print '</table>';
print '</form>';
}
print '<br><div style="text-align: center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
print '</form>';
dol_fiche_end();
}
}

View File

@@ -583,7 +583,7 @@ if (GETPOST("source") == 'contractline' && $valid)
$duration='';
if ($contractline->fk_product)
{
if ($product->isservice() && $product->duration_value > 0)
if ($product->isService() && $product->duration_value > 0)
{
$label=$langs->trans("Duration");

View File

@@ -720,7 +720,7 @@ if (GETPOST("source") == 'contractline' && $valid)
$duration='';
if ($contractline->fk_product)
{
if ($product->isservice() && $product->duration_value > 0)
if ($product->isService() && $product->duration_value > 0)
{
$label=$langs->trans("Duration");