Start to work on feature to select stock id for increase/decrease.

This commit is contained in:
Laurent Destailleur 2011-11-06 15:42:53 +01:00
parent 8d46ae1d35
commit 83f2061e0e
10 changed files with 67 additions and 52 deletions

View File

@ -131,7 +131,7 @@ if ($conf->stock->enabled)
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
$formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1); print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1);
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -99,7 +99,7 @@ if ($conf->stock->enabled)
print '<td>'; print '<td>';
$disabled=0; $disabled=0;
if (! empty($conf->global->CASHDESK_ID_WAREHOUSE)) $disabled=1; // If a particular stock is defined, we disable choice if (! empty($conf->global->CASHDESK_ID_WAREHOUSE)) $disabled=1; // If a particular stock is defined, we disable choice
$formproduct->selectWarehouses(GETPOST('warehouseid')?GETPOST('warehouseid'):$conf->global->CASHDESK_ID_WAREHOUSE,'warehouseid','',!$disabled,$disabled); print $formproduct->selectWarehouses(GETPOST('warehouseid')?GETPOST('warehouseid'):$conf->global->CASHDESK_ID_WAREHOUSE,'warehouseid','',!$disabled,$disabled);
//print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />'; //print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -1462,7 +1462,18 @@ else
$text.='<br>'; $text.='<br>';
$text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid); $text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid);
} }
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', '', 0, 1); if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && '1' == 'TODO')
{
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
$formproduct=new FormProduct($db);
$formquestion=array(
//'text' => $langs->trans("ConfirmClone"),
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
}
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1);
} }
/* /*

View File

@ -2168,15 +2168,15 @@ class Form
/** /**
* Show a confirmation HTML form or AJAX popup * Show a confirmation HTML form or AJAX popup
* *
* @param page Url of page to call if confirmation is OK * @param string $page Url of page to call if confirmation is OK
* @param title title * @param string $title Title
* @param question question * @param string $question Question
* @param action action * @param string $action Action
* @param formquestion an array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , )) * @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
* @param selectedchoice "" or "no" or "yes" * @param string $selectedchoice "" or "no" or "yes"
* @param useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No * @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No
* @param height Force height of box * @param int $height Force height of box
* @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form * @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form
*/ */
function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500) function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500)
{ {

View File

@ -749,7 +749,7 @@ if ($action == 'create')
// Show warehous // Show warehous
if ($_REQUEST["entrepot_id"]) if ($_REQUEST["entrepot_id"])
{ {
$formproduct->selectWarehouses($_REQUEST["entrepot_id"],'entl'.$indiceAsked,'',1,0,$line->fk_product); print $formproduct->selectWarehouses($_REQUEST["entrepot_id"],'entl'.$indiceAsked,'',1,0,$line->fk_product);
//print $stock.' '.$quantityToBeDelivered; //print $stock.' '.$quantityToBeDelivered;
//if ($stock >= 0 && $stock < $quantityToBeDelivered) //if ($stock >= 0 && $stock < $quantityToBeDelivered)
if ($stock < $quantityToBeDelivered) if ($stock < $quantityToBeDelivered)
@ -759,7 +759,7 @@ if ($action == 'create')
} }
else else
{ {
$formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product); print $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product);
} }
} }
else else

View File

@ -624,8 +624,8 @@ if ($id > 0 || ! empty($ref))
{ {
print '<td>'.$langs->trans("WarehouseSource").'</td>'; print '<td>'.$langs->trans("WarehouseSource").'</td>';
print '<td>'; print '<td>';
$result=$formproduct->selectWarehouses(-1,'entrepot_id','',1); print $formproduct->selectWarehouses(-1,'entrepot_id','',1);
if ($result <= 0) if (count($formproduct->cache_warehouses) <= 0)
{ {
print ' &nbsp; No warehouse defined, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">add one</a>'; print ' &nbsp; No warehouse defined, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">add one</a>';
} }

View File

@ -82,7 +82,7 @@ DetailMenuIdParent=ID of parent menu (0 for a top menu)
DetailPosition=Sort number to define menu position DetailPosition=Sort number to define menu position
PersonalizedMenusNotSupported=Personalized menus not supported PersonalizedMenusNotSupported=Personalized menus not supported
AllMenus=All AllMenus=All
NotConfigured=Numbering module not configured NotConfigured=Module not configured
Setup=Setup Setup=Setup
Activation=Activation Activation=Activation
Active=Active Active=Active

View File

@ -83,7 +83,7 @@ DetailMenuIdParent= Id du menu parent (0 pour un menu du haut)
DetailPosition= Numéro d'ordre déterminant la position du menu DetailPosition= Numéro d'ordre déterminant la position du menu
PersonalizedMenusNotSupported= Menus personnalisés non gérés PersonalizedMenusNotSupported= Menus personnalisés non gérés
AllMenus= Tous AllMenus= Tous
NotConfigured=Module numérotation non configuré NotConfigured=Module non configuré
Setup= Configuration Setup= Configuration
Activation= Activation Activation= Activation
Active= Actif Active= Actif

View File

@ -39,22 +39,24 @@ class FormProduct
/** /**
* \brief Constructeur * Constructor
* \param DB Database handler *
* @param DoliDB $db Database handler
*/ */
function FormProduct($DB) function FormProduct($db)
{ {
$this->db = $DB; $this->db = $db;
return 1; return 1;
} }
/** /**
* \brief Load in cache array list of warehouses * Load in cache array list of warehouses
* \param fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * If fk_product is not 0, we do not use cache
* \return int Nb of loaded lines, 0 if already loaded, <0 if KO *
* \remarks If fk_product is not 0, we do not use cache * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/ */
function loadWarehouses($fk_product=0) function loadWarehouses($fk_product=0)
{ {
@ -73,7 +75,7 @@ class FormProduct
$sql.= " WHERE statut = 1"; $sql.= " WHERE statut = 1";
$sql.= " ORDER BY e.label"; $sql.= " ORDER BY e.label";
dol_syslog('FormProduct::loadWarehouses sql='.$sql,LOG_DEBUG); dol_syslog(get_class($this).'::loadWarehouses sql='.$sql,LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -98,39 +100,41 @@ class FormProduct
} }
/** /**
* \brief Return list of possible payments modes * Return list of possible payments modes
* \param selected Id du mode de paiement pre-selectionne *
* \param htmlname Name of html select html * @param int $selected Id du mode de paiement pre-selectionne
* \param filtertype For filtre * @param string $htmlname Name of html select html
* \param empty 1=Can be empty, 0 if not * @param string $filtertype For filter
* \param disabled 1=Select is disabled * @param int $empty 1=Can be empty, 0 if not
* \param fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * @param int $disabled 1=Select is disabled
* \return int <0 if KO, Nb of product in list if OK * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
* @return string HTML select
*/ */
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0) function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0)
{ {
global $langs,$user; global $langs,$user;
dol_syslog("Form::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG); dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG);
$this->loadWarehouses($fk_product); $this->loadWarehouses($fk_product);
print '<select class="flat"'.($disabled?' disabled="disabled"':'').' name="'.($htmlname.($disabled?'_disabled':'')).'">'; $out='<select class="flat"'.($disabled?' disabled="disabled"':'').' name="'.($htmlname.($disabled?'_disabled':'')).'">';
if ($empty) print '<option value="">&nbsp;</option>'; if ($empty) $out.='<option value="">&nbsp;</option>';
foreach($this->cache_warehouses as $id => $arraytypes) foreach($this->cache_warehouses as $id => $arraytypes)
{ {
print '<option value="'.$id.'"'; $out.='<option value="'.$id.'"';
// Si selected est text, on compare avec code, sinon avec id // Si selected est text, on compare avec code, sinon avec id
if ($selected == $id) print ' selected="selected"'; if ($selected == $id) $out.=' selected="selected"';
print '>'; $out.='>';
print $arraytypes['label']; $out.=$arraytypes['label'];
if ($fk_product) print ' ('.$langs->trans("Stock").': '.($arraytypes['stock']>0?$arraytypes['stock']:'?').')'; if ($fk_product) $out.=' ('.$langs->trans("Stock").': '.($arraytypes['stock']>0?$arraytypes['stock']:'?').')';
print '</option>'; $out.='</option>';
} }
print '</select>'; $out.='</select>';
if ($disabled) print '<input type="hidden" name="'.$htmlname.'" value="'.$selected.'">'; if ($disabled) $out.='<input type="hidden" name="'.$htmlname.'" value="'.$selected.'">';
return count($this->cache_warehouses); //count($this->cache_warehouses);
return $out;
} }
/** /**

View File

@ -327,7 +327,7 @@ if ($_GET["id"] || $_GET["ref"])
print '<tr>'; print '<tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td>'; print '<td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td width="20%">'; print '<td width="20%">';
$formproduct->selectWarehouses($_GET["dwid"],'id_entrepot','',1); print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot','',1);
print '</td>'; print '</td>';
print '<td width="20%">'; print '<td width="20%">';
print '<select name="mouvement" class="flat">'; print '<select name="mouvement" class="flat">';
@ -366,10 +366,10 @@ if ($_GET["id"] || $_GET["ref"])
print '<tr>'; print '<tr>';
print '<td width="20%">'.$langs->trans("WarehouseSource").'</td><td width="20%">'; print '<td width="20%">'.$langs->trans("WarehouseSource").'</td><td width="20%">';
$formproduct->selectWarehouses($_GET["dwid"],'id_entrepot_source','',1); print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot_source','',1);
print '</td>'; print '</td>';
print '<td width="20%">'.$langs->trans("WarehouseTarget").'</td><td width="20%">'; print '<td width="20%">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
$formproduct->selectWarehouses('','id_entrepot_destination','',1); print $formproduct->selectWarehouses('','id_entrepot_destination','',1);
print '</td>'; print '</td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>'; print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>';
print '</tr>'; print '</tr>';
@ -403,7 +403,7 @@ if ($_GET["id"] || $_GET["ref"])
print '<input type="hidden" name="action" value="create_stock">'; print '<input type="hidden" name="action" value="create_stock">';
print '<table class="border" width="100%"><tr>'; print '<table class="border" width="100%"><tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td><td width="40%">'; print '<td width="20%">'.$langs->trans("Warehouse").'</td><td width="40%">';
$formproduct->selectWarehouses('','id_entrepot','',1); print $formproduct->selectWarehouses('','id_entrepot','',1);
print '</td><td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>'; print '</td><td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;'; print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td></tr>'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td></tr>';