[CORE] maj du code + ajout d'une fonction pour le module (#new_ask_price).

This commit is contained in:
phf 2015-01-30 16:50:46 +01:00
parent 3b0fd5ec98
commit 9a289537be
4 changed files with 48 additions and 23 deletions

View File

@ -177,7 +177,7 @@ if (empty($reshook))
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->validate)))
)
{
{
$result = $object->valid($user);
if ($result >= 0)
{
@ -543,19 +543,6 @@ if (empty($reshook))
}
}
// Close proposal
else if ($action == 'setstatut' && $user->rights->askpricesupplier->cloturer && ! GETPOST('cancel')) {
if (! GETPOST('statut')) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors');
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
if ($object->statut == 1) {
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
}
}
// Classify billed
else if ($action == 'classifybilled' && $user->rights->askpricesupplier->cloturer) {
$object->cloture($user, 4, '');
@ -1284,9 +1271,11 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
// Ref customer
/* PHFAVRE retrait en temporaire
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td colspan="2">';
print '<input type="text" name="ref_client" value=""></td>';
print '</tr>';
*/
// Third party
print '<tr>';
@ -1355,15 +1344,19 @@ if ($action == 'create')
}
// What trigger creation
/* PHFAVRE retrait en temporaire
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
$form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1);
print '</td></tr>';
*/
// Delivery delay
/* PHFAVRE retrait en temporaire
print '<tr><td>' . $langs->trans('AvailabilityPeriod') . '</td><td colspan="2">';
$form->selectAvailabilityDelay('', 'availability_id', '', 1);
print '</td></tr>';
*/
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td colspan="2">';
@ -1372,6 +1365,7 @@ if ($action == 'create')
}
// Delivery date (or manufacturing)
/* PHFAVRE retrait en temporaire
print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>';
print '<td colspan="2">';
if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") {
@ -1384,7 +1378,8 @@ if ($action == 'create')
$form->select_date(-1, 'liv_', '', '', '', "addask", 1, 1);
}
print '</td></tr>';
*/
// Model
print '<tr>';
print '<td>' . $langs->trans("DefaultModel") . '</td>';

View File

@ -31,6 +31,7 @@
* \brief File of class to manage proposals
*/
require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php';
@ -1784,6 +1785,10 @@ class AskPriceSupplier extends CommonObject
$this->db->rollback();
return -2;
}
else
{
$this->updatePriceFournisseur();
}
}
if ($statut == 4)
{
@ -1828,6 +1833,31 @@ class AskPriceSupplier extends CommonObject
}
}
function updatePriceFournisseur()
{
$productsupplier = new ProductFournisseur($this->db);
dol_syslog(get_class($this)."::updatePriceFournisseur", 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;
}
}
}
/**
* Class invoiced the Propal
*

View File

@ -152,7 +152,7 @@ else
/*
* Draft proposals
*/
if (! empty($conf->propal->enabled))
if (! empty($conf->askpricesupplier->enabled))
{
$sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c";
@ -258,7 +258,7 @@ if ($resql)
print '<td width="16" align="right" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
@ -291,7 +291,7 @@ if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier
$now=dol_now();
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as askpricesupplierid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -325,7 +325,7 @@ if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier
// Ref
print '<td class="nowrap" width="140">';
$askpricesupplierstatic->id=$obj->propalid;
$askpricesupplierstatic->id=$obj->askpricesupplierid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';

View File

@ -357,7 +357,7 @@ if ($result)
if (! empty($objp->note_private))
{
print ' <span class="note">';
print '<a href="'.DOL_URL_ROOT.'/comm/propal/note.php?id='.$objp->askpricesupplierid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
print '<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/note.php?id='.$objp->askpricesupplierid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
print '</span>';
}
print '</td>';
@ -365,7 +365,7 @@ if ($result)
// Ref
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($objp->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref);
$filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($objp->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->askpricesupplierid;
print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
print '</td></tr></table>';