diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php
index 46533a84210..cf296ef9417 100644
--- a/htdocs/comm/askpricesupplier.php
+++ b/htdocs/comm/askpricesupplier.php
@@ -249,18 +249,12 @@ if (empty($reshook))
$datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
- $duration = GETPOST('duree_validite');
if (empty($datep)) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors');
$action = 'create';
$error ++;
}
- if (empty($duration)) {
- setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors');
- $action = 'create';
- $error ++;
- }
if ($socid < 1) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors');
@@ -969,7 +963,7 @@ if (empty($reshook))
}
}
- else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) {
+ else if ($action == 'updateligne' && $user->rights->askpricesupplier->creer && GETPOST('cancel') == $langs->trans('Cancel')) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition
exit();
}
@@ -1664,6 +1658,7 @@ if ($action == 'create')
print '';
// Ref customer
+ /* PHFAVRE retrait en temporaire
print '
';
print '| ';
print $langs->trans('RefCustomer') . ' | ';
@@ -1684,12 +1679,14 @@ if ($action == 'create')
}
print '';
print ' ';
-
+ */
+
// Company
- print '| ' . $langs->trans('Company') . ' | ' . $soc->getNomUrl(1) . ' | ';
+ print ' | ' . $langs->trans('Supplier') . ' | ' . $soc->getNomUrl(1) . ' | ';
print ' ';
// Ligne info remises tiers
+ /* PHFAVRE retrait en temporaire
print '| ' . $langs->trans('Discounts') . ' | ';
if ($soc->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
@@ -1716,7 +1713,8 @@ if ($action == 'create')
if (! $absolute_discount && ! $absolute_creditnote)
print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.';
print ' | ';
-
+ */
+
// Date of proposal
print '';
print '| ';
@@ -1744,6 +1742,7 @@ if ($action == 'create')
print ' | ';
// Date end proposal
+ /* PHFAVRE retrait en temporaire
print ' ';
print '';
print '| ';
@@ -1771,7 +1770,8 @@ if ($action == 'create')
}
print ' | ';
print ' ';
-
+ */
+
// Payment term
print '';
print '| ';
@@ -1790,6 +1790,7 @@ if ($action == 'create')
print ' | ';
// Delivery date
+ /* PHFAVRE retrait en temporaire
$langs->load('deliveries');
print '';
print '| ';
@@ -1811,8 +1812,10 @@ if ($action == 'create')
}
print ' | ';
print ' ';
-
+ */
+
// Delivery delay
+ /* PHFAVRE retrait en temporaire
print '';
print '| ';
print $langs->trans('AvailabilityPeriod');
@@ -1831,8 +1834,10 @@ if ($action == 'create')
print ' | ';
print ' ';
-
+ */
+
// Shipping Method
+ /* PHFAVRE retrait en temporaire
if (! empty($conf->expedition->enabled)) {
print '';
print '| ';
@@ -1850,8 +1855,10 @@ if ($action == 'create')
print ' | ';
print ' ';
}
-
+ */
+
// Origin of demand
+ /* PHFAVRE retrait en temporaire
print '';
print '| ';
print $langs->trans('Source');
@@ -1867,7 +1874,8 @@ if ($action == 'create')
}
print ' | ';
print ' ';
-
+ */
+
// Payment mode
print '';
print '| ';
@@ -1886,6 +1894,7 @@ if ($action == 'create')
print ' | ';
// Project
+ /*
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
print '| ';
@@ -1918,7 +1927,8 @@ if ($action == 'create')
}
print ' | ';
}
-
+ */
+
if ($soc->outstanding_limit)
{
// Outstanding Bill
@@ -1938,7 +1948,7 @@ if ($action == 'create')
print '| ';
print $langs->trans('BankAccount');
print ' | ';
- if ($action != 'editbankaccount' && $user->rights->propal->creer)
+ if ($action != 'editbankaccount' && $user->rights->askpricesupplier->creer)
print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).' | ';
print ' ';
print '';
@@ -2033,6 +2043,7 @@ if ($action == 'create')
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
// Form to add new line
+ /* PHFAVRE retrait en temporaire*/
if ($object->statut == 0 && $user->rights->askpricesupplier->creer)
{
if ($action != 'editline')
@@ -2046,7 +2057,25 @@ if ($action == 'create')
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
}
+
+
+ /*
+ // Form to add new line
+ if ($object->statut == 0 && $user->rights->askpricesupplier->creer)
+ {
+ // Add free products/services form
+ global $forceall, $senderissupplier, $dateSelector;
+ $forceall=1; $senderissupplier=1; $dateSelector=0;
+ $var = true;
+
+ // Add free products/services
+ $object->formAddObjectLine(1, $mysoc, $object);
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ }
+*/
print ' | ';
print "\n";
@@ -2065,8 +2094,8 @@ if ($action == 'create')
$form_close .= '';
$form_close .= '';
$form_close .= ' | ';
$form_close .= '| ' . $langs->trans('Note') . ' | | ';
print '';
@@ -2226,7 +2255,7 @@ if ($action == 'create')
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
- $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
+ $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
// Define output language
diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php
index 8ac09582339..43627601408 100644
--- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php
+++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php
@@ -1787,7 +1787,7 @@ class AskPriceSupplier extends CommonObject
}
else
{
- $this->updatePriceFournisseur();
+ $this->updateOrCreatePriceFournisseur($user);
}
}
if ($statut == 4)
@@ -1833,31 +1833,91 @@ class AskPriceSupplier extends CommonObject
}
}
- function updatePriceFournisseur()
- {
+ /**
+ * Choose between upate or create ProductFournisseur
+ *
+ * @param User $user Object user
+ * @return int <0 if KO, >0 if OK
+ */
+ function updateOrCreatePriceFournisseur($user)
+ {
$productsupplier = new ProductFournisseur($this->db);
- dol_syslog(get_class($this)."::updatePriceFournisseur", LOG_DEBUG);
+ dol_syslog(get_class($this)."::updateorCreatePriceFournisseur", LOG_DEBUG);
foreach ($this->lines as $product) {
$idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty);
$res = $productsupplier->fetch($idProductFourn);
- $price=price2num($product->subprice*$product->qty,'MU');
- //$qty=price2num($product->qty);
- $unitPrice = price2num($product->subprice,'MU');
-
- //$sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET price ='.$price.', quantity ='.$qty.', unitprice ='.$unitPrice.' WHERE rowid = '.$productsupplier->product_fourn_price_id;
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$productsupplier->product_fourn_price_id;
-
- $resql=$this->db->query($sql);
- if (!resql) {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -1;
+ if ($productsupplier->id) {
+ if ($productsupplier->fourn_qty == $product->qty) {
+ $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user);
+ } else {
+ $this->createPriceFournisseur($product, $user);
+ }
+ } else {
+ $this->createPriceFournisseur($product, $user);
}
}
}
+ /**
+ * Upate ProductFournisseur
+ *
+ * @param int $idProductFournPrice id of llx_product_fournisseur_price
+ * @param int $product contain informations to update
+ * @param User $user Object user
+ * @return int <0 if KO, >0 if OK
+ */
+ function updatePriceFournisseur($idProductFournPrice, $product, $user) {
+ $price=price2num($product->subprice*$product->qty,'MU');
+ $unitPrice = price2num($product->subprice,'MU');
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice;
+
+ $resql = $this->db->query($sql);
+ if (!resql) {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+ /**
+ * Create ProductFournisseur
+ *
+ * @param Product $product Object Product
+ * @param User $user Object user
+ * @return int <0 if KO, >0 if OK
+ */
+ function createPriceFournisseur($product, $user) {
+ $price=price2num($product->subprice*$product->qty,'MU');
+ $qty=price2num($product->qty);
+ $unitPrice = price2num($product->subprice,'MU');
+ $now=dol_now();
+
+ $values = array(
+ '`'.$this->db->idate($now).'`',
+ $product->fk_product,
+ $this->client->id,
+ '`'.$this->db->escape($product->ref).'`', //En attente de récupérer la bonne ref fournisseur sur le form
+ $price,
+ $qty,
+ $unitPrice,
+ $product->tva_tx,
+ $user->id
+ );
+
+ $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price ';
+ $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')';
+
+ $resql = $this->db->query($sql);
+ if (!resql) {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
/**
* Class invoiced the Propal
*
diff --git a/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php
index 096c5a3cec5..d1912b98a9a 100644
--- a/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php
+++ b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php
@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askprice
class mod_askpricesupplier_marbre extends ModeleNumRefAskPriceSupplier
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
- var $prefix='PR';
+ var $prefix='DF';
var $error='';
var $nom = "Marbre";
@@ -101,10 +101,10 @@ class mod_askpricesupplier_marbre extends ModeleNumRefAskPriceSupplier
* Return next value
*
* @param Societe $objsoc Object third party
- * @param Propal $propal Object commercial proposal
+ * @param Propal $askpricesupplier Object commercial proposal
* @return string Next value
*/
- function getNextValue($objsoc,$propal)
+ function getNextValue($objsoc,$askpricesupplier)
{
global $db,$conf;
diff --git a/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php
index 9bfffcee262..2aad00d9cd9 100644
--- a/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php
+++ b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php
@@ -25,13 +25,13 @@
* \brief File that contains the numbering module rules Saphir
*/
-require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_propale.php';
+require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askpricesupplier.php';
/**
* Class of file that contains the numbering module rules Saphir
*/
-class mod_propale_saphir extends ModeleNumRefAskPriceSupplier
+class mod_askpricesupplier_saphir extends ModeleNumRefAskPriceSupplier
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error = '';
@@ -123,7 +123,7 @@ class mod_propale_saphir extends ModeleNumRefAskPriceSupplier
$date=$askpricesupplier->datep;
$customercode=$objsoc->code_client;
- $numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date);
+ $numFinal=get_next_value($db,$mask,'askpricesupplier','ref','',$customercode,$date);
return $numFinal;
}
diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php
index 66861061981..1db1ca9c6c3 100644
--- a/htdocs/core/modules/modAskPriceSupplier.class.php
+++ b/htdocs/core/modules/modAskPriceSupplier.class.php
@@ -282,19 +282,5 @@ DROP TABLE llx_askpricesupplier_extrafields;
DROP TABLE llx_askpricesupplierdet_extrafields;
DROP TABLE llx_askpricesupplierdet;
DROP TABLE llx_askpricesupplier;
- *
- * CREATE TABLE IF NOT EXISTS llx_askpricesupplier (
- rowid INT AUTO_INCREMENT,
- fk_statut INT NOT NULL,
- fk_soc INT NOT NULL,
- price DOUBLE(24,8),
- date_create TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- date_send TIMESTAMP,
- PRIMARY KEY pk_rowid (rowid),
- CONSTRAINT fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)
-);
- *
- *
- *
*
*/
diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang
index 0f0e39b7c43..96b4c784cfc 100644
--- a/htdocs/langs/fr_FR/askpricesupplier.lang
+++ b/htdocs/langs/fr_FR/askpricesupplier.lang
@@ -59,8 +59,8 @@ AskpricesupplierStatusDraft=Brouillon (à valider)
AskpricesupplierStatusValidated=Validée (demande ouverte)
AskpricesupplierStatusOpened=Validée (demande ouverte)
AskpricesupplierStatusClosed=Fermée
-AskpricesupplierStatusSigned=Signée (à facturer)
-AskpricesupplierStatusNotSigned=Non signée (fermée)
+AskpricesupplierStatusSigned=Acceptée
+AskpricesupplierStatusNotSigned=Refusée
AskpricesupplierStatusBilled=Facturée
AskpricesupplierStatusDraftShort=Brouillon
AskpricesupplierStatusValidatedShort=Validée
|
|
|
|
|
|