Fix: Optimieze Price by Customer
This commit is contained in:
parent
ed52fc20d6
commit
67a7a210fd
@ -9,6 +9,7 @@
|
||||
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@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
|
||||
@ -151,7 +152,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -171,7 +172,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -461,7 +462,7 @@ else if ($action == 'add' && $user->rights->propal->creer) {
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -548,11 +549,11 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
// Recipient was provided from combo list
|
||||
if ($_POST ['receiver'] == 'thirdparty') // Id of third party
|
||||
{
|
||||
$sendto = $object->client->email;
|
||||
$sendto = $object->thirdparty->email;
|
||||
$sendtoid = 0;
|
||||
} else // Id du contact
|
||||
{
|
||||
$sendto = $object->client->contact_get_property($_POST ['receiver'], 'email');
|
||||
$sendto = $object->thirdparty->contact_get_property($_POST ['receiver'], 'email');
|
||||
$sendtoid = $_POST ['receiver'];
|
||||
}
|
||||
}
|
||||
@ -656,7 +657,7 @@ if ($action == 'modif' && $user->rights->propal->creer) {
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -742,18 +743,22 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// If prices fields are update
|
||||
$tva_tx = get_default_tva($mysoc, $object->client, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
|
||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
|
||||
// On defini prix unitaire
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level)
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
|
||||
{
|
||||
$pu_ht = $prod->multiprices [$object->client->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
|
||||
$price_min = $prod->multiprices_min [$object->client->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
|
||||
$pu_ht = $prod->multiprices [$object->thirdparty->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc [$object->thirdparty->price_level];
|
||||
$price_min = $prod->multiprices_min [$object->thirdparty->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type [$object->thirdparty->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
}
|
||||
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
@ -761,12 +766,11 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
|
||||
$prodcustprice = new Productcustomerprice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id);
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$found = true;
|
||||
$pu_ht = price($prodcustprice->lines [0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines [0]->price_base_type;
|
||||
@ -774,13 +778,6 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
}
|
||||
|
||||
// if price ht is forced (ie: calculated by margin rate and cost price)
|
||||
if (! empty($price_ht)) {
|
||||
@ -807,7 +804,7 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
if (empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if (empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -852,8 +849,8 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
$date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
|
||||
|
||||
// Local Taxes
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->client);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->client);
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
|
||||
|
||||
$info_bits = 0;
|
||||
if ($tva_npr)
|
||||
@ -874,7 +871,7 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -933,8 +930,8 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
|
||||
// Define vat_rate
|
||||
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->client);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->client);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
|
||||
$pu_ht = GETPOST('price_ht');
|
||||
|
||||
// Add buying price
|
||||
@ -969,8 +966,8 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
|
||||
$type = $product->type;
|
||||
|
||||
$price_min = $product->price_min;
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
|
||||
$price_min = $product->multiprices_min [$object->client->price_level];
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
|
||||
$price_min = $product->multiprices_min [$object->thirdparty->price_level];
|
||||
|
||||
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
||||
|
||||
@ -1002,7 +999,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -1044,7 +1041,7 @@ else if ($action == 'builddoc' && $user->rights->propal->creer) {
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -1130,7 +1127,7 @@ else if ($action == 'up' && $user->rights->propal->creer) {
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -1149,7 +1146,7 @@ else if ($action == 'down' && $user->rights->propal->creer) {
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
@ -2302,7 +2299,7 @@ if ($action == 'create') {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
|
||||
if (!empty($newlang))
|
||||
{
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@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
|
||||
@ -170,7 +171,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -476,7 +477,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = GETPOST('lang_id', 'alpha');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -581,18 +582,22 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// Update if prices fields are defined
|
||||
$tva_tx = get_default_tva($mysoc, $object->client, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
|
||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
|
||||
// multiprix
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
|
||||
{
|
||||
$pu_ht = $prod->multiprices [$object->client->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
|
||||
$price_min = $prod->multiprices_min [$object->client->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
|
||||
$pu_ht = $prod->multiprices [$object->thirdparty->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc [$object->thirdparty->price_level];
|
||||
$price_min = $prod->multiprices_min [$object->thirdparty->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type [$object->thirdparty->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
}
|
||||
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
@ -600,12 +605,11 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
|
||||
$prodcustprice = new Productcustomerprice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id);
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$found = true;
|
||||
$pu_ht = price($prodcustprice->lines [0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines [0]->price_base_type;
|
||||
@ -613,14 +617,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
}
|
||||
|
||||
|
||||
// if price ht is forced (ie: calculated by margin rate and cost price)
|
||||
if (! empty($price_ht)) {
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
@ -646,7 +643,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
if (empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if (empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -688,8 +685,8 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
$buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
|
||||
|
||||
// Local Taxes
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->client);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->client);
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
|
||||
|
||||
$desc = dol_htmlcleanlastbr($desc);
|
||||
|
||||
@ -712,7 +709,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = GETPOST('lang_id', 'alpha');
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -778,8 +775,8 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
|
||||
|
||||
// Define vat_rate
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->client);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->client);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
|
||||
|
||||
// Add buying price
|
||||
$fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : '');
|
||||
@ -805,8 +802,8 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
|
||||
$type = $product->type;
|
||||
|
||||
$price_min = $product->price_min;
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
|
||||
$price_min = $product->multiprices_min [$object->client->price_level];
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
|
||||
$price_min = $product->multiprices_min [$object->thirdparty->price_level];
|
||||
|
||||
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
||||
|
||||
@ -836,7 +833,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -902,7 +899,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -947,7 +944,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1013,7 +1010,7 @@ else if ($action == 'up' && $user->rights->commande->creer) {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1035,7 +1032,7 @@ else if ($action == 'down' && $user->rights->commande->creer) {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1064,7 +1061,7 @@ else if ($action == 'builddoc') // In get or post
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1179,11 +1176,11 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
// Recipient was provided from combo list
|
||||
if (GETPOST('receiver') == 'thirdparty') // Id of third party
|
||||
{
|
||||
$sendto = $object->client->email;
|
||||
$sendto = $object->thirdparty->email;
|
||||
$sendtoid = 0;
|
||||
} else // Id du contact
|
||||
{
|
||||
$sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email');
|
||||
$sendto = $object->thirdparty->contact_get_property(GETPOST('receiver'), 'email');
|
||||
$sendtoid = GETPOST('receiver');
|
||||
}
|
||||
}
|
||||
@ -2444,7 +2441,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
|
||||
if (!empty($newlang))
|
||||
{
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@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
|
||||
@ -182,7 +183,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -393,7 +394,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -468,7 +469,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1145,18 +1146,22 @@ else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// Update if prices fields are defined
|
||||
$tva_tx = get_default_tva($mysoc, $object->client, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
|
||||
|
||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
|
||||
// We define price for product
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
|
||||
{
|
||||
$pu_ht = $prod->multiprices [$object->client->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
|
||||
$price_min = $prod->multiprices_min [$object->client->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
|
||||
$pu_ht = $prod->multiprices [$object->thirdparty->price_level];
|
||||
$pu_ttc = $prod->multiprices_ttc [$object->thirdparty->price_level];
|
||||
$price_min = $prod->multiprices_min [$object->thirdparty->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type [$object->thirdparty->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
}
|
||||
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
@ -1164,12 +1169,11 @@ else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
|
||||
$prodcustprice = new Productcustomerprice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id);
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$found = true;
|
||||
$pu_ht = price($prodcustprice->lines [0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines [0]->price_base_type;
|
||||
@ -1177,14 +1181,7 @@ else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
}
|
||||
|
||||
|
||||
// if price ht is forced (ie: calculated by margin rate and cost price)
|
||||
if (! empty($price_ht)) {
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
@ -1210,7 +1207,7 @@ else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
if (empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if (empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1252,8 +1249,8 @@ else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
$buyingprice = price2num(GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
|
||||
|
||||
// Local Taxes
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->client);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->client);
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
|
||||
|
||||
$info_bits = 0;
|
||||
if ($tva_npr)
|
||||
@ -1272,7 +1269,7 @@ else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
$outputlangs = $langs;
|
||||
$newlang = GETPOST('lang_id', 'alpha');
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1342,8 +1339,8 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
||||
|
||||
// Define vat_rate
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->client);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->client);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
|
||||
|
||||
// Add buying price
|
||||
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
|
||||
@ -1370,8 +1367,8 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
||||
$type = $product->type;
|
||||
|
||||
$price_min = $product->price_min;
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
|
||||
$price_min = $product->multiprices_min [$object->client->price_level];
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
|
||||
$price_min = $product->multiprices_min [$object->thirdparty->price_level];
|
||||
|
||||
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
||||
|
||||
@ -1403,7 +1400,7 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1448,7 +1445,7 @@ else if ($action == 'up' && $user->rights->facture->creer) {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1470,7 +1467,7 @@ else if ($action == 'down' && $user->rights->facture->creer) {
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -1546,11 +1543,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
// Recipient was provided from combo list
|
||||
if ($_POST['receiver'] == 'thirdparty') // Id of third party
|
||||
{
|
||||
$sendto = $object->client->email;
|
||||
$sendto = $object->thirdparty->email;
|
||||
$sendtoid = 0;
|
||||
} else // Id du contact
|
||||
{
|
||||
$sendto = $object->client->contact_get_property($_POST['receiver'], 'email');
|
||||
$sendto = $object->thirdparty->contact_get_property($_POST['receiver'], 'email');
|
||||
$sendtoid = $_POST['receiver'];
|
||||
}
|
||||
}
|
||||
@ -1692,7 +1689,7 @@ else if ($action == 'builddoc') // En get ou en post
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("", $conf);
|
||||
@ -3670,7 +3667,7 @@ if ($action == 'create')
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->client->default_lang;
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
|
||||
if (!empty($newlang))
|
||||
{
|
||||
|
||||
@ -277,7 +277,7 @@ if ($action == 'add' && $user->rights->contrat->creer)
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
||||
if (empty($newlang)) $newlang=$srcobject->client->default_lang;
|
||||
if (empty($newlang)) $newlang=$srcobject->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
@ -441,7 +441,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
|
||||
|
||||
$prodcustprice = new Productcustomerprice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id);
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user