Skip to content

Commit

Permalink
Start to work on feature to select stock id for increase/decrease.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 6, 2011
1 parent 8d46ae1 commit 83f2061
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 52 deletions.
2 changes: 1 addition & 1 deletion htdocs/cashdesk/admin/cashdesk.php
Expand Up @@ -131,7 +131,7 @@
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>';
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>';
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/cashdesk/index.php
Expand Up @@ -99,7 +99,7 @@
print '<td>';
$disabled=0;
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 '</td>';
print "</tr>\n";
Expand Down
13 changes: 12 additions & 1 deletion htdocs/commande/fiche.php
Expand Up @@ -1462,7 +1462,18 @@
$text.='<br>';
$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);
}

/*
Expand Down
18 changes: 9 additions & 9 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -2168,15 +2168,15 @@ function form_confirm($page, $title, $question, $action, $formquestion='', $sele
/**
* Show a confirmation HTML form or AJAX popup
*
* @param page Url of page to call if confirmation is OK
* @param title title
* @param question question
* @param action action
* @param formquestion an array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
* @param selectedchoice "" or "no" or "yes"
* @param useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No
* @param height Force height of box
* @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form
* @param string $page Url of page to call if confirmation is OK
* @param string $title Title
* @param string $question Question
* @param string $action Action
* @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
* @param string $selectedchoice "" or "no" or "yes"
* @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No
* @param int $height Force height of box
* @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)
{
Expand Down
4 changes: 2 additions & 2 deletions htdocs/expedition/fiche.php
Expand Up @@ -749,7 +749,7 @@
// Show warehous
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;
//if ($stock >= 0 && $stock < $quantityToBeDelivered)
if ($stock < $quantityToBeDelivered)
Expand All @@ -759,7 +759,7 @@
}
else
{
$formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product);
print $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product);
}
}
else
Expand Down
6 changes: 3 additions & 3 deletions htdocs/expedition/shipment.php
Expand Up @@ -624,8 +624,8 @@
{
print '<td>'.$langs->trans("WarehouseSource").'</td>';
print '<td>';
$result=$formproduct->selectWarehouses(-1,'entrepot_id','',1);
if ($result <= 0)
print $formproduct->selectWarehouses(-1,'entrepot_id','',1);
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>';
}
Expand Down Expand Up @@ -653,7 +653,7 @@
print '</div>';
}
}

show_list_sending_receive('commande',$commande->id);
}
else
Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/en_US/admin.lang
Expand Up @@ -82,7 +82,7 @@ DetailMenuIdParent=ID of parent menu (0 for a top menu)
DetailPosition=Sort number to define menu position
PersonalizedMenusNotSupported=Personalized menus not supported
AllMenus=All
NotConfigured=Numbering module not configured
NotConfigured=Module not configured
Setup=Setup
Activation=Activation
Active=Active
Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/fr_FR/admin.lang
Expand Up @@ -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
PersonalizedMenusNotSupported= Menus personnalisés non gérés
AllMenus= Tous
NotConfigured=Module numérotation non configuré
NotConfigured=Module non configuré
Setup= Configuration
Activation= Activation
Active= Actif
Expand Down
62 changes: 33 additions & 29 deletions htdocs/product/class/html.formproduct.class.php
Expand Up @@ -39,22 +39,24 @@ class FormProduct


/**
* \brief Constructeur
* \param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function FormProduct($DB)
function FormProduct($db)
{
$this->db = $DB;
$this->db = $db;

return 1;
}


/**
* \brief 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.
* \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
* Load in cache array list of warehouses
* 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)
{
Expand All @@ -73,7 +75,7 @@ function loadWarehouses($fk_product=0)
$sql.= " WHERE statut = 1";
$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);
if ($resql)
{
Expand All @@ -98,39 +100,41 @@ function loadWarehouses($fk_product=0)
}

/**
* \brief Return list of possible payments modes
* \param selected Id du mode de paiement pre-selectionne
* \param htmlname Name of html select html
* \param filtertype For filtre
* \param empty 1=Can be empty, 0 if not
* \param disabled 1=Select is disabled
* \param fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
* \return int <0 if KO, Nb of product in list if OK
* Return list of possible payments modes
*
* @param int $selected Id du mode de paiement pre-selectionne
* @param string $htmlname Name of html select html
* @param string $filtertype For filter
* @param int $empty 1=Can be empty, 0 if not
* @param int $disabled 1=Select is disabled
* @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)
{
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);

print '<select class="flat"'.($disabled?' disabled="disabled"':'').' name="'.($htmlname.($disabled?'_disabled':'')).'">';
if ($empty) print '<option value="">&nbsp;</option>';
$out='<select class="flat"'.($disabled?' disabled="disabled"':'').' name="'.($htmlname.($disabled?'_disabled':'')).'">';
if ($empty) $out.='<option value="">&nbsp;</option>';
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
if ($selected == $id) print ' selected="selected"';
print '>';
print $arraytypes['label'];
if ($fk_product) print ' ('.$langs->trans("Stock").': '.($arraytypes['stock']>0?$arraytypes['stock']:'?').')';
print '</option>';
if ($selected == $id) $out.=' selected="selected"';
$out.='>';
$out.=$arraytypes['label'];
if ($fk_product) $out.=' ('.$langs->trans("Stock").': '.($arraytypes['stock']>0?$arraytypes['stock']:'?').')';
$out.='</option>';
}
print '</select>';
if ($disabled) print '<input type="hidden" name="'.$htmlname.'" value="'.$selected.'">';
$out.='</select>';
if ($disabled) $out.='<input type="hidden" name="'.$htmlname.'" value="'.$selected.'">';

return count($this->cache_warehouses);
//count($this->cache_warehouses);
return $out;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions htdocs/product/stock/product.php
Expand Up @@ -327,7 +327,7 @@
print '<tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td width="20%">';
$formproduct->selectWarehouses($_GET["dwid"],'id_entrepot','',1);
print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot','',1);
print '</td>';
print '<td width="20%">';
print '<select name="mouvement" class="flat">';
Expand Down Expand Up @@ -366,10 +366,10 @@

print '<tr>';
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 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 width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>';
print '</tr>';
Expand Down Expand Up @@ -403,7 +403,7 @@
print '<input type="hidden" name="action" value="create_stock">';
print '<table class="border" width="100%"><tr>';
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 '<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>';
Expand Down

0 comments on commit 83f2061

Please sign in to comment.